// File: /workspace/github_c_makefile_star2_O0/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: generate_merge_patch(cJSON*, cJSON*, int)
static cJSON *generate_merge_patch(cJSON * const from, cJSON * const to, const cJSON_bool case_sensitive)
{
    cJSON *from_child = NULL;
    cJSON *to_child = NULL;
    cJSON *patch = NULL;
    if (to == NULL)
    {
        /* patch to delete everything */
        return cJSON_CreateNull();
    }
    if (!cJSON_IsObject(to) || !cJSON_IsObject(from))
    {
        return cJSON_Duplicate(to, 1);
    }

    sort_object(from, case_sensitive);
    sort_object(to, case_sensitive);

    from_child = from->child;
    to_child = to->child;
    patch = cJSON_CreateObject();
    while (from_child || to_child)
    {
        int diff;
        if (from_child != NULL)
        {
            if (to_child != NULL)
            {
                diff = strcmp(from_child->string, to_child->string);
            }
            else
            {
                diff = -1;
            }
        }
        else
        {
            diff = 1;
        }

        if (diff < 0)
        {
            /* from has a value that to doesn't have -> remove */
            cJSON_AddItemToObject(patch, from_child->string, cJSON_CreateNull());

            from_child = from_child->next;
        }
        else if (diff > 0)
        {
            /* to has a value that from doesn't have -> add to patch */
            cJSON_AddItemToObject(patch, to_child->string, cJSON_Duplicate(to_child, 1));

            to_child = to_child->next;
        }
        else
        {
            /* object key exists in both objects */
            if (!compare_json(from_child, to_child, case_sensitive))
            {
                /* not identical --> generate a patch */
                cJSON_AddItemToObject(patch, to_child->string, cJSONUtils_GenerateMergePatch(from_child, to_child));
            }

            /* next key in the object */
            from_child = from_child->next;
            to_child = to_child->next;
        }
    }
    if (patch->child == NULL)
    {
        /* no patch generated */
        cJSON_Delete(patch);
        return NULL;
    }

    return patch;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x93e0
callq 0x4620
movq %rax, -0x8(%rbp)
jmp 0x95b4
movq -0x18(%rbp), %rdi
callq 0x5e00
cmpl $0x0, %eax
je 0x93fc
movq -0x10(%rbp), %rdi
callq 0x5e00
cmpl $0x0, %eax
jne 0x9413
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x5770
movq %rax, -0x8(%rbp)
jmp 0x95b4
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x9150
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x9150
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
callq 0x4bb0
movq %rax, -0x38(%rbp)
movb $0x1, %al
cmpq $0x0, -0x28(%rbp)
movb %al, -0x3d(%rbp)
jne 0x9463
cmpq $0x0, -0x30(%rbp)
setne %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x946f
jmp 0x958e
cmpq $0x0, -0x28(%rbp)
je 0x94a0
cmpq $0x0, -0x30(%rbp)
je 0x9497
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x2250
movl %eax, -0x3c(%rbp)
jmp 0x949e
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
jmp 0x94a7
movl $0x1, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x94e6
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x4620
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %rax, %rdx
callq 0x42e0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x9589
cmpl $0x0, -0x3c(%rbp)
jle 0x952b
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x5770
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x42e0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x9587
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x9a70
cmpl $0x0, %eax
jne 0x9571
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x9370
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq %rax, %rdx
callq 0x42e0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x9589
jmp 0x944c
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x95ac
movq -0x38(%rbp), %rdi
callq 0x31f0
movq $0x0, -0x8(%rbp)
jmp 0x95b4
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nop