// File: /workspace/github_c_makefile_star2_O0/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: merge_patch(cJSON*, cJSON const*, int)
static cJSON *merge_patch(cJSON *target, const cJSON * const patch, const cJSON_bool case_sensitive)
{
    cJSON *patch_child = NULL;

    if (!cJSON_IsObject(patch))
    {
        /* scalar value, array or NULL, just duplicate */
        cJSON_Delete(target);
        return cJSON_Duplicate(patch, 1);
    }

    if (!cJSON_IsObject(target))
    {
        cJSON_Delete(target);
        target = cJSON_CreateObject();
    }

    patch_child = patch->child;
    while (patch_child != NULL)
    {
        if (cJSON_IsNull(patch_child))
        {
            /* NULL is the indicator to remove a value, see RFC7396 */
            if (case_sensitive)
            {
                cJSON_DeleteItemFromObjectCaseSensitive(target, patch_child->string);
            }
            else
            {
                cJSON_DeleteItemFromObject(target, patch_child->string);
            }
        }
        else
        {
            cJSON *replace_me = NULL;
            cJSON *replacement = NULL;

            if (case_sensitive)
            {
                replace_me = cJSON_DetachItemFromObjectCaseSensitive(target, patch_child->string);
            }
            else
            {
                replace_me = cJSON_DetachItemFromObject(target, patch_child->string);
            }

            replacement = merge_patch(replace_me, patch_child, case_sensitive);
            if (replacement == NULL)
            {
                return NULL;
            }

            cJSON_AddItemToObject(target, patch_child->string, replacement);
        }
        patch_child = patch_child->next;
    }
    return target;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5e00
cmpl $0x0, %eax
jne 0x9229
movq -0x10(%rbp), %rdi
callq 0x31f0
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x5770
movq %rax, -0x8(%rbp)
jmp 0x932e
movq -0x10(%rbp), %rdi
callq 0x5e00
cmpl $0x0, %eax
jne 0x9249
movq -0x10(%rbp), %rdi
callq 0x31f0
callq 0x4bb0
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x9326
movq -0x28(%rbp), %rdi
callq 0x5d40
cmpl $0x0, %eax
je 0x929a
cmpl $0x0, -0x1c(%rbp)
je 0x9287
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x4e60
jmp 0x9298
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x4e30
jmp 0x9316
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x92c7
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x4df0
movq %rax, -0x30(%rbp)
jmp 0x92dc
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x4db0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x91e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x9301
movq $0x0, -0x8(%rbp)
jmp 0x932e
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x38(%rbp), %rdx
callq 0x42e0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x9255
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)