// File: /workspace/github_c_makefile_star2_O3/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 0x5863
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq %rdi, %r12
cmpq %rsi, %rdi
je 0x5898
movq 0x10(%r12), %r15
testq %r15, %r15
je 0x584e
xorl %r13d, %r13d
movq %r15, %rdi
movq %r14, %rsi
callq 0x5830
testq %rax, %rax
jne 0x58b2
incq %r13
movq (%r15), %r15
testq %r15, %r15
jne 0x587b
jmp 0x584e
leaq 0x2c0f(%rip), %rdi      # 0x84ae
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5999
movq %rax, %rbx
movq %r12, %rdi
callq 0x4e88
testl %eax, %eax
je 0x58f1
movq %rbx, %rdi
callq 0x2140
leaq 0x16(%rax), %rdi
callq 0x5094
movq %rax, %r14
leaq 0x296c(%rip), %rsi      # 0x8248
movq %rax, %rdi
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x22c0
jmp 0x597f
movq %r12, %rdi
callq 0x4e9c
testl %eax, %eax
je 0x598c
movq %rbx, %rdi
callq 0x2140
movq 0x38(%r15), %rdx
xorl %ecx, %ecx
movzbl (%rdx), %esi
cmpl $0x2f, %esi
je 0x5922
cmpl $0x7e, %esi
je 0x5922
testl %esi, %esi
jne 0x5925
jmp 0x592d
incq %rcx
incq %rdx
incq %rcx
jmp 0x590f
leaq (%rax,%rcx), %rdi
addq $0x2, %rdi
callq 0x5094
movq %rax, %r14
movb $0x2f, (%rax)
movq 0x38(%r15), %rcx
movzbl (%rcx), %edx
cmpl $0x2f, %edx
je 0x5964
cmpl $0x7e, %edx
je 0x595c
incq %rax
testl %edx, %edx
je 0x5971
movb %dl, (%rax)
jmp 0x596c
movw $0x317e, 0x1(%rax)      # imm = 0x317E
jmp 0x5968
movb $0x31, 0x2(%rax)
addq $0x2, %rax
incq %rcx
jmp 0x5944
movb $0x0, (%rax)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x509f
jmp 0x5851
movq %rbx, %rdi
callq 0x509f
jmp 0x584e