static char *json_escape_str(const char *s)

{

    static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};

    static const char json_subst[]  = {'"', '\\',  'b',  'f',  'n',  'r',  't', 0};

    char *ret, *p;

    int i, len = 0;



    // compute the length of the escaped string

    for (i = 0; s[i]; i++) {

        if (strchr(json_escape, s[i]))     len += 2; // simple escape

        else if ((unsigned char)s[i] < 32) len += 6; // handle non-printable chars

        else                               len += 1; // char copy

    }



    p = ret = av_malloc(len + 1);

    if (!p)

        return NULL;

    for (i = 0; s[i]; i++) {

        char *q = strchr(json_escape, s[i]);

        if (q) {

            *p++ = '\\';

            *p++ = json_subst[q - json_escape];

        } else if ((unsigned char)s[i] < 32) {

            snprintf(p, 7, "\\u00%02x", s[i] & 0xff);

            p += 6;

        } else {

            *p++ = s[i];

        }

    }

    *p = 0;

    return ret;

}

static char *json_escape_str(const char *s)

{

    static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};

    static const char json_subst[]  = {'"', '\\',  'b',  'f',  'n',  'r',  't', 0};

    char *ret, *p;

    int i, len = 0;



    

    for (i = 0; s[i]; i++) {

        if (strchr(json_escape, s[i]))     len += 2; 

        else if ((unsigned char)s[i] < 32) len += 6; 

        else                               len += 1; 

    }



    p = ret = av_malloc(len + 1);

    if (!p)

        return NULL;

    for (i = 0; s[i]; i++) {

        char *q = strchr(json_escape, s[i]);

        if (q) {

            *p++ = '\\';

            *p++ = json_subst[q - json_escape];

        } else if ((unsigned char)s[i] < 32) {

            snprintf(p, 7, "\\u00%02x", s[i] & 0xff);

            p += 6;

        } else {

            *p++ = s[i];

        }

    }

    *p = 0;

    return ret;

}

static char *json_escape_str(const char *s)     char *ret, *p;     int i, len = 0;     for (i = 0; s[i]; i++) {     p = ret = av_malloc(len + 1);     if (!p)         return NULL;     for (i = 0; s[i]; i++) {         char *q = strchr(json_escape, s[i]);         if (q) {             *p++ = '\\';             *p++ = json_subst[q - json_escape];         } else if ((unsigned char)s[i] < 32) {             snprintf(p, 7, "\\u00%02x", s[i] & 0xff);             p += 6;             *p++ = s[i];     *p = 0;     return ret;
static char *FUNC_0(const char *VAR_0)

{

    static const char VAR_1[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};

    static const char VAR_2[]  = {'"', '\\',  'b',  'f',  'n',  'r',  't', 0};

    char *VAR_3, *VAR_4;

    int VAR_5, VAR_6 = 0;



    

    for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) {

        if (strchr(VAR_1, VAR_0[VAR_5]))     VAR_6 += 2; 

        else if ((unsigned char)VAR_0[VAR_5] < 32) VAR_6 += 6; 

        else                               VAR_6 += 1; 

    }



    VAR_4 = VAR_3 = av_malloc(VAR_6 + 1);

    if (!VAR_4)

        return NULL;

    for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) {

        char *VAR_7 = strchr(VAR_1, VAR_0[VAR_5]);

        if (VAR_7) {

            *VAR_4++ = '\\';

            *VAR_4++ = VAR_2[VAR_7 - VAR_1];

        } else if ((unsigned char)VAR_0[VAR_5] < 32) {

            snprintf(VAR_4, 7, "\\u00%02x", VAR_0[VAR_5] & 0xff);

            VAR_4 += 6;

        } else {

            *VAR_4++ = VAR_0[VAR_5];

        }

    }

    *VAR_4 = 0;

    return VAR_3;

}

static char *FUNC_0(const char *VAR_0)
{ static const char VAR_1[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0}; static const char VAR_2[]  = {'"', '\\',  'b',  'f',  'n',  'r',  't', 0}; char *VAR_3, *VAR_4; int VAR_5, VAR_6 = 0; for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) { if (strchr(VAR_1, VAR_0[VAR_5]))     VAR_6 += 2; else if ((unsigned char)VAR_0[VAR_5] < 32) VAR_6 += 6; else                               VAR_6 += 1; } VAR_4 = VAR_3 = av_malloc(VAR_6 + 1); if (!VAR_4)
return NULL; for (VAR_5 = 0; VAR_0[VAR_5]; VAR_5++) { char *VAR_7 = strchr(VAR_1, VAR_0[VAR_5]); if (VAR_7) { *VAR_4++ = '\\'; *VAR_4++ = VAR_2[VAR_7 - VAR_1]; } else if ((unsigned char)VAR_0[VAR_5] < 32) { snprintf(VAR_4, 7, "\\u00%02x", VAR_0[VAR_5] & 0xff); VAR_4 += 6; } else { *VAR_4++ = VAR_0[VAR_5]; } } *VAR_4 = 0; return VAR_3; }