// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/processtab/tabparser.c
// Function: parseJSON
char *
parseJSON(FILE *in)
    {
    /* This is not a full JSON parser, but instead a simple brace-matcher.
       Its only intended use is to consume input through the end brace of a JSON string.
     */
    
    char ch;
    char buffer[JSON_LENGTH_MAX];
    int index = 0;
    int braceLevel = 0;
    bool inQuotes = false;
    bool jsonStarted = false;
    
    skipWhiteSpace(in);
    
    while ((ch = fgetc(in)))
        {
        if (index == JSON_LENGTH_MAX - 1)
            {
            Fatal("JSON string cannot be longer than %i characters\n", JSON_LENGTH_MAX - 1);
            return 0;
            }
        if (ch == EOF)
            {
            Fatal("unexpected EOF reading JSON string\n");
            return 0;
            }
        if (!jsonStarted && ch != '{')
            {
            Fatal("expected '{', found '%c' in JSON string\n", ch);
            return 0;
            }
        if (ch == '\\') 
            {
            // consume backslash and the next character
            buffer[index++] = ch;
            ch = fgetc(in);
            buffer[index++] = ch;
            if (ch == 'u') // consume 3 extra characters for unicode '\u####'
                {
                buffer[index++] = ch;
                ch = fgetc(in);
                buffer[index++] = ch;
                ch = fgetc(in);
                buffer[index++] = ch;
                ch = fgetc(in);
                }
            }
        else if (ch == '\"')
            {
            inQuotes = !inQuotes;
            buffer[index++] = ch;
            }   
        else if (ch == '{')
            {
            jsonStarted = true;
            if (!inQuotes) braceLevel++;
            buffer[index++] = ch;
            }
        else if (ch == '}')
            {
            if (!inQuotes) braceLevel--;
            buffer[index++] = ch;
            if (braceLevel == 0) break;
            }
        else
            {
            buffer[index++] = ch;
            }
        }
        buffer[index] = '\0';
        return StringDup(buffer);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10030, %rsp          # imm = 0x10030
movq %rdi, -0x10(%rbp)
movl $0x0, -0x10024(%rbp)
movl $0x0, -0x10028(%rbp)
movb $0x0, -0x10029(%rbp)
movb $0x0, -0x1002a(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3d60
movq -0x10(%rbp), %rdi
callq 0x10c0
movb %al, -0x11(%rbp)
cmpb $0x0, %al
je 0x4240
cmpl $0xffff, -0x10024(%rbp) # imm = 0xFFFF
jne 0x401a
leaq 0x3f8b(%rip), %rdi      # 0x7f8c
movl $0xffff, %esi           # imm = 0xFFFF
movb $0x0, %al
callq 0x63e0
movq $0x0, -0x8(%rbp)
jmp 0x425f
movsbl -0x11(%rbp), %eax
cmpl $-0x1, %eax
jne 0x403e
leaq 0x3f93(%rip), %rdi      # 0x7fbd
movb $0x0, %al
callq 0x63e0
movq $0x0, -0x8(%rbp)
jmp 0x425f
testb $0x1, -0x1002a(%rbp)
jne 0x406f
movsbl -0x11(%rbp), %eax
cmpl $0x7b, %eax
je 0x406f
movsbl -0x11(%rbp), %esi
leaq 0x3f86(%rip), %rdi      # 0x7fe1
movb $0x0, %al
callq 0x63e0
movq $0x0, -0x8(%rbp)
jmp 0x425f
movsbl -0x11(%rbp), %eax
cmpl $0x5c, %eax
jne 0x414b
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
movq -0x10(%rbp), %rdi
callq 0x10c0
movb %al, -0x11(%rbp)
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
movsbl -0x11(%rbp), %eax
cmpl $0x75, %eax
jne 0x4146
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
movq -0x10(%rbp), %rdi
callq 0x10c0
movb %al, -0x11(%rbp)
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
movq -0x10(%rbp), %rdi
callq 0x10c0
movb %al, -0x11(%rbp)
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
movq -0x10(%rbp), %rdi
callq 0x10c0
movb %al, -0x11(%rbp)
jmp 0x423b
movsbl -0x11(%rbp), %eax
cmpl $0x22, %eax
jne 0x4186
movb -0x10029(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x10029(%rbp)
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
jmp 0x4239
movsbl -0x11(%rbp), %eax
cmpl $0x7b, %eax
jne 0x41cd
movb $0x1, -0x1002a(%rbp)
testb $0x1, -0x10029(%rbp)
jne 0x41ae
movl -0x10028(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10028(%rbp)
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
jmp 0x4237
movsbl -0x11(%rbp), %eax
cmpl $0x7d, %eax
jne 0x4218
testb $0x1, -0x10029(%rbp)
jne 0x41ee
movl -0x10028(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10028(%rbp)
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
cmpl $0x0, -0x10028(%rbp)
jne 0x4216
jmp 0x4240
jmp 0x4235
movb -0x11(%rbp), %cl
movl -0x10024(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x10024(%rbp)
cltq
movb %cl, -0x10020(%rbp,%rax)
jmp 0x4237
jmp 0x4239
jmp 0x423b
jmp 0x3fda
movslq -0x10024(%rbp), %rax
movb $0x0, -0x10020(%rbp,%rax)
leaq -0x10020(%rbp), %rdi
callq 0x65f0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10030, %rsp          # imm = 0x10030
popq %rbp
retq
nopl (%rax)