// File: /workspace/github_c_makefile_star2_O2/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 0x50cf
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, %r13
cmpq %rsi, %rdi
je 0x50fe
leaq 0x10(%r13), %r15
xorl %r12d, %r12d
movq (%r15), %r15
testq %r15, %r15
je 0x50ba
movq %r15, %rdi
movq %r14, %rsi
callq 0x509c
testq %rax, %rax
jne 0x5118
incq %r12
jmp 0x50e1
leaq 0x23a9(%rip), %rdi      # 0x74ae
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51b9
movq %rax, %rbx
movq %r13, %rdi
callq 0x48cc
testl %eax, %eax
je 0x5154
movq %rbx, %rdi
callq 0x2140
leaq 0x16(%rax), %rdi
callq 0x4abb
movq %rax, %r14
leaq 0x2106(%rip), %rsi      # 0x7248
movq %rax, %rdi
movq %r12, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x22d0
jmp 0x519f
movq %r13, %rdi
callq 0x48e0
testl %eax, %eax
je 0x51ac
movq %rbx, %rdi
callq 0x2140
movq %rax, %r14
movq 0x38(%r15), %rdi
callq 0x51f2
leaq (%r14,%rax), %rdi
addq $0x2, %rdi
callq 0x4abb
movq %rax, %r14
movb $0x2f, (%rax)
leaq 0x1(%rax), %rdi
movq 0x38(%r15), %rsi
callq 0x5218
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x4ac6
jmp 0x50bd
movq %rbx, %rdi
callq 0x4ac6
jmp 0x50ba