// File: /workspace/github_c_makefile_star2_O2/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, %r12
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 0x6913
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), %r14
xorl %ebx, %ebx
movq %r12, %r15
xorl %ebp, %ebp
movslq %ebp, %r13
testl %ebp, %ebp
je 0x696e
movsbl (%r15), %esi
testl %esi, %esi
je 0x6a3b
leaq 0x5be4(%rip), %rdi      # 0xc541
pushq $0x5
popq %rdx
callq 0x22c0
testq %rax, %rax
jne 0x6a3b
testl %ebx, %ebx
je 0x6a77
movb (%r15), %al
cmpb $0x2a, %al
jne 0x69a6
cmpl $0x1, %ebx
je 0x69bb
cmpl $0x2, %ebx
jne 0x6b7e
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x69ee
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x69fc
movb %al, 0x30(%rsp,%r13)
cmpl $0xff, %ebp
jg 0x6b7e
incl %ebp
jmp 0x6a33
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x69d6
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x69e4
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %rdi
callq 0x2100
jmp 0x6a12
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl (%rax), %ecx
movq %r14, %rdi
pushq $0x40
popq %rsi
leaq 0x7232(%rip), %rdx      # 0xdc3d
xorl %eax, %eax
callq 0x2400
addl %eax, %ebp
cmpl $0x101, %ebp            # imm = 0x101
jge 0x6b7e
leaq (%rsp,%r13), %rdi
addq $0x30, %rdi
movslq %eax, %rdx
movq %r14, %rsi
callq 0x21e0
incq %r15
jmp 0x6943
movb $0x0, 0x30(%rsp,%r13)
movl %ebx, %eax
leaq 0x5a1e(%rip), %rcx      # 0xc468
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x461d
testl %eax, %eax
je 0x6b7e
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x38d1
jmp 0x6aa5
movq %r12, %r15
jmp 0x6ab3
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x460e
testl %eax, %eax
je 0x6b7e
leaq 0x30(%rsp), %rdi
callq 0x23e0
movq %rbx, %rdi
movl %eax, %esi
callq 0x3804
testq %rax, %rax
je 0x6b7e
movq %rax, 0x8(%rsp)
xorl %eax, %eax
cmpb $0x5d, (%r15)
sete %al
movzbl (%r15,%rax), %ecx
pushq $0x1
popq %rbx
cmpl $0x2e, %ecx
je 0x6ade
cmpl $0x3a, %ecx
je 0x6adb
cmpl $0x5b, %ecx
jne 0x6b73
pushq $0x2
jmp 0x6add
pushq $0x3
popq %rbx
addq %rax, %r15
incq %r15
movq %r15, %r12
jmp 0x6941
movb 0x30(%rsp), %al
cmpb $0x73, %al
movq 0x8(%rsp), %rbx
jne 0x6b09
movq %rbx, %rdi
callq 0x28ea
testl %eax, %eax
je 0x6b7e
movb 0x30(%rsp), %al
cmpb $0x6e, %al
jne 0x6b1d
movq %rbx, %rdi
callq 0x2912
testl %eax, %eax
je 0x6b7e
movb 0x30(%rsp), %al
cmpb $0x6f, %al
jne 0x6b31
movq %rbx, %rdi
callq 0x461d
testl %eax, %eax
je 0x6b7e
movb 0x30(%rsp), %al
cmpb $0x61, %al
jne 0x6b45
movq %rbx, %rdi
callq 0x460e
testl %eax, %eax
je 0x6b7e
movb 0x30(%rsp), %al
cmpb $0x62, %al
jne 0x6b59
movq %rbx, %rdi
callq 0x45f0
testl %eax, %eax
je 0x6b7e
movb 0x30(%rsp), %al
cmpb $0x21, %al
jne 0x6ab3
movq %rbx, %rdi
callq 0x45ff
testl %eax, %eax
jne 0x6ab3
jmp 0x6b7e
testl %ecx, %ecx
jne 0x6b7e
movq 0x8(%rsp), %rax
jmp 0x6b80
xorl %eax, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq