// File: /workspace/github_c_makefile_star2_O3/antirez[P]stonky/stonky.c
// Function: cJSON_Select
cJSON *cJSON_Select(cJSON *o, const char *fmt, ...) {
    int next = JSEL_INVALID;        /* Type of the next selector. */
    char token[JSEL_MAX_TOKEN+1];   /* Current token. */
    int tlen;                       /* Current length of the token. */
    va_list ap;

    va_start(ap,fmt);
    const char *p = fmt;
    tlen = 0;
    while(1) {
        /* Our four special chars (plus the end of the string) signal the
         * end of the previous token and the start of the next one. */
        if (tlen && (*p == '\0' || strchr(".[]:",*p))) {
            token[tlen] = '\0';
            if (next == JSEL_INVALID) {
                goto notfound;
            } else if (next == JSEL_ARRAY) {
                if (!cJSON_IsArray(o)) goto notfound;
                int idx = atoi(token); /* cJSON API index is int. */
                if ((o = cJSON_GetArrayItem(o,idx)) == NULL)
                    goto notfound;
            } else if (next == JSEL_OBJ) {
                if (!cJSON_IsObject(o)) goto notfound;
                if ((o = cJSON_GetObjectItemCaseSensitive(o,token)) == NULL)
                    goto notfound;
            } else if (next == JSEL_TYPECHECK) {
                if (token[0] == 's' && !cJSON_IsString(o)) goto notfound;
                if (token[0] == 'n' && !cJSON_IsNumber(o)) goto notfound;
                if (token[0] == 'o' && !cJSON_IsObject(o)) goto notfound;
                if (token[0] == 'a' && !cJSON_IsArray(o)) goto notfound;
                if (token[0] == 'b' && !cJSON_IsBool(o)) goto notfound;
                if (token[0] == '!' && !cJSON_IsNull(o)) goto notfound;
            }
        } else if (next != JSEL_INVALID) {
            /* Otherwise accumulate characters in the current token, note that
             * the above check for JSEL_NEXT_INVALID prevents us from
             * accumulating at the start of the fmt string if no token was
             * yet selected. */
            if (*p != '*') {
                token[tlen] = *p++;
                tlen++;
                if (tlen > JSEL_MAX_TOKEN) goto notfound;
                continue;
            } else {
                /* The "*" character is special: if we are in the context
                 * of an array, we read an integer from the variable argument
                 * list, then concatenate it to the current string.
                 *
                 * If the context is an object, we read a string pointer
                 * from the variable argument string and concatenate the
                 * string to the current token. */
                int len;
                char buf[64];
                char *s;
                if (next == JSEL_ARRAY) {
                    int idx = va_arg(ap,int);
                    len = snprintf(buf,sizeof(buf),"%d",idx);
                    s = buf;
                } else if (next == JSEL_OBJ) {
                    s = va_arg(ap,char*);
                    len = strlen(s);
                } else {
                    goto notfound;
                }
                /* Common path. */
                if (tlen+len > JSEL_MAX_TOKEN) goto notfound;
                memcpy(token+tlen,buf,len);
                tlen += len;
                p++;
                continue;
            }
        }
        /* Select the next token type according to its type specifier. */
        if (*p == ']') p++; /* Skip closing "]", it's just useless syntax. */
        if (*p == '\0') break;
        else if (*p == '.') next = JSEL_OBJ;
        else if (*p == '[') next = JSEL_ARRAY;
        else if (*p == ':') next = JSEL_TYPECHECK;
        else goto notfound;
        tlen = 0; /* A new token starts. */
        p++; /* Token starts at next character. */
    }

cleanup:
    va_end(ap);
    return o;

notfound:
    o = NULL;
    goto cleanup;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x180(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x7ae4
movaps %xmm0, 0x1b0(%rsp)
movaps %xmm1, 0x1c0(%rsp)
movaps %xmm2, 0x1d0(%rsp)
movaps %xmm3, 0x1e0(%rsp)
movaps %xmm4, 0x1f0(%rsp)
movaps %xmm5, 0x200(%rsp)
movaps %xmm6, 0x210(%rsp)
movaps %xmm7, 0x220(%rsp)
movq %rsi, 0x20(%rsp)
leaq 0x270(%rsp), %rax
movq %rax, 0x18(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, 0x10(%rsp)
leaq 0x140(%rsp), %r15
xorl %r12d, %r12d
movq %rbx, %r13
xorl %r14d, %r14d
testl %r14d, %r14d
je 0x7b42
movsbl (%r13), %esi
testl %esi, %esi
je 0x7c24
movl $0x5, %edx
leaq 0x6da5(%rip), %rdi      # 0xe8d9
callq 0x22c0
testq %rax, %rax
jne 0x7c24
testl %r12d, %r12d
je 0x7c63
movb (%r13), %al
cmpb $0x2a, %al
jne 0x7b7e
cmpl $0x1, %r12d
je 0x7b9a
cmpl $0x2, %r12d
jne 0x7d80
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x7bcd
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x7bdb
movslq %r14d, %rcx
movb %al, 0x30(%rsp,%rcx)
cmpl $0xff, %r14d
jg 0x7d80
incl %r14d
movl %r14d, %ebp
jmp 0x7c19
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x7bb5
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x7bc3
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %rdi
callq 0x2100
jmp 0x7bf3
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl (%rax), %ecx
movl $0x40, %esi
movq %r15, %rdi
leaq 0x83e9(%rip), %rdx      # 0xffd5
xorl %eax, %eax
callq 0x2400
leal (%rax,%r14), %ebp
cmpl $0x101, %ebp            # imm = 0x101
jge 0x7d80
movslq %r14d, %rcx
leaq (%rsp,%rcx), %rdi
addq $0x30, %rdi
movslq %eax, %rdx
movq %r15, %rsi
callq 0x21e0
incq %r13
movl %ebp, %r14d
jmp 0x7b16
movslq %r14d, %rax
movb $0x0, 0x30(%rsp,%rax)
movl %r12d, %eax
leaq 0x6b1a(%rip), %rcx      # 0xe750
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4c4c
testl %eax, %eax
je 0x7d80
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x39b8
jmp 0x7c96
movq %rbx, %r13
movq 0x8(%rsp), %rbx
jmp 0x7ca2
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4c3d
testl %eax, %eax
je 0x7d80
leaq 0x30(%rsp), %rdi
callq 0x23e0
movq %rbx, %rdi
movl %eax, %esi
callq 0x38b8
testq %rax, %rax
je 0x7d80
movq %rax, %rbx
xorl %edx, %edx
cmpb $0x5d, (%r13)
sete %dl
movzbl (%r13,%rdx), %ecx
cmpl $0x39, %ecx
jle 0x7cd2
cmpl $0x3a, %ecx
je 0x7ce2
cmpl $0x5b, %ecx
movl $0x0, %eax
jne 0x7d82
movl $0x2, %r12d
jmp 0x7ce8
movl $0x1, %r12d
cmpl $0x2e, %ecx
je 0x7ce8
jmp 0x7d94
movl $0x3, %r12d
movq %rbx, 0x8(%rsp)
addq %rdx, %r13
incq %r13
movq %r13, %rbx
jmp 0x7b13
movb 0x30(%rsp), %al
cmpb $0x73, %al
movq 0x8(%rsp), %rbx
jne 0x7d18
movq %rbx, %rdi
callq 0x29ca
testl %eax, %eax
je 0x7d80
movb 0x30(%rsp), %al
cmpb $0x6e, %al
jne 0x7d2c
movq %rbx, %rdi
callq 0x29f2
testl %eax, %eax
je 0x7d80
movb 0x30(%rsp), %al
cmpb $0x6f, %al
jne 0x7d40
movq %rbx, %rdi
callq 0x4c4c
testl %eax, %eax
je 0x7d80
movb 0x30(%rsp), %al
cmpb $0x61, %al
jne 0x7d54
movq %rbx, %rdi
callq 0x4c3d
testl %eax, %eax
je 0x7d80
movb 0x30(%rsp), %al
cmpb $0x62, %al
jne 0x7d68
movq %rbx, %rdi
callq 0x4c1f
testl %eax, %eax
je 0x7d80
movb 0x30(%rsp), %al
cmpb $0x21, %al
jne 0x7ca2
movq %rbx, %rdi
callq 0x4c2e
testl %eax, %eax
jne 0x7ca2
xorl %eax, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ecx, %ecx
movl $0x0, %eax
jne 0x7d82
movq %rbx, %rax
jmp 0x7d82