// File: /workspace/github_c_makefile_star2_O1/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: cJSONUtils_FindPointerFromObjectTo
CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const object, const cJSON * const target)
{
    size_t child_index = 0;
    cJSON *current_child = 0;

    if ((object == NULL) || (target == NULL))
    {
        return NULL;
    }

    if (object == target)
    {
        /* found */
        return (char*)cJSONUtils_strdup((const unsigned char*)"");
    }

    /* recursively search all children of the object or array */
    for (current_child = object->child; current_child != NULL; (void)(current_child = current_child->next), child_index++)
    {
        unsigned char *target_pointer = (unsigned char*)cJSONUtils_FindPointerFromObjectTo(current_child, target);
        /* found the target? */
        if (target_pointer != NULL)
        {
            if (cJSON_IsArray(object))
            {
                /* reserve enough memory for a 64 bit integer + '/' and '\0' */
                unsigned char *full_pointer = (unsigned char*)cJSON_malloc(strlen((char*)target_pointer) + 20 + sizeof("/"));
                /* check if conversion to unsigned long is valid
                 * This should be eliminated at compile time by dead code elimination
                 * if size_t is an alias of unsigned long, or if it is bigger */
                if (child_index > ULONG_MAX)
                {
                    cJSON_free(target_pointer);
                    return NULL;
                }
                sprintf((char*)full_pointer, "/%lu%s", (unsigned long)child_index, target_pointer); /* /<array_index><path> */
                cJSON_free(target_pointer);

                return (char*)full_pointer;
            }

            if (cJSON_IsObject(object))
            {
                unsigned char *full_pointer = (unsigned char*)cJSON_malloc(strlen((char*)target_pointer) + pointer_encoded_length((unsigned char*)current_child->string) + 2);
                full_pointer[0] = '/';
                encode_string_as_pointer(full_pointer + 1, (unsigned char*)current_child->string);
                strcat((char*)full_pointer, (char*)target_pointer);
                cJSON_free(target_pointer);

                return (char*)full_pointer;
            }

            /* reached leaf of the tree, found nothing */
            cJSON_free(target_pointer);
            return NULL;
        }
    }

    /* not found */
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x59b3
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
cmpq %rsi, %rdi
je 0x5ade
movq 0x10(%rdi), %r15
testq %r15, %r15
je 0x599e
movq %rdi, -0x30(%rbp)
xorl %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5980
movq %rax, %r12
testq %rax, %rax
je 0x5ac1
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x4f5d
testl %eax, %eax
je 0x5a26
movq %r12, %rdi
callq 0x2140
leaq 0x16(%rax), %rdi
callq 0x5169
movq %rax, %r14
movq %rax, %rdi
leaq 0x283c(%rip), %rsi      # 0x8250
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22c0
jmp 0x5ab9
movq %r14, %rdi
callq 0x4f71
testl %eax, %eax
je 0x5ab6
movq %r12, %rdi
callq 0x2140
movq 0x38(%r15), %rcx
xorl %edx, %edx
movzbl (%rcx), %esi
cmpl $0x2f, %esi
je 0x5a57
cmpl $0x7e, %esi
je 0x5a57
testl %esi, %esi
jne 0x5a5a
jmp 0x5a62
incq %rdx
incq %rcx
incq %rdx
jmp 0x5a44
leaq (%rax,%rdx), %rdi
addq $0x2, %rdi
callq 0x5169
movq %rax, %r14
movb $0x2f, (%rax)
movq 0x38(%r15), %rcx
movzbl (%rcx), %edx
cmpl $0x2f, %edx
je 0x5a99
cmpl $0x7e, %edx
je 0x5a91
incq %rax
testl %edx, %edx
je 0x5aa6
movb %dl, (%rax)
jmp 0x5aa1
movw $0x317e, 0x1(%rax)      # imm = 0x317E
jmp 0x5a9d
movb $0x31, 0x2(%rax)
addq $0x2, %rax
incq %rcx
jmp 0x5a79
movb $0x0, (%rax)
movq %r14, %rdi
movq %r12, %rsi
callq 0x21b0
jmp 0x5ab9
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x5174
testq %r12, %r12
jne 0x59a1
incq %r13
movq (%r15), %r15
testq %r15, %r15
jne 0x59cf
jmp 0x599e
leaq 0x29d1(%rip), %rdi      # 0x84b6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5af5