// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: compose_patch(cJSON*, unsigned char const*, unsigned char const*, unsigned char const*, cJSON const*)
static void compose_patch(cJSON * const patches, const unsigned char * const operation, const unsigned char * const path, const unsigned char *suffix, const cJSON * const value)
{
    cJSON *patch = NULL;

    if ((patches == NULL) || (operation == NULL) || (path == NULL))
    {
        return;
    }

    patch = cJSON_CreateObject();
    if (patch == NULL)
    {
        return;
    }
    cJSON_AddItemToObject(patch, "op", cJSON_CreateString((const char*)operation));

    if (suffix == NULL)
    {
        cJSON_AddItemToObject(patch, "path", cJSON_CreateString((const char*)path));
    }
    else
    {
        size_t suffix_length = pointer_encoded_length(suffix);
        size_t path_length = strlen((const char*)path);
        unsigned char *full_path = (unsigned char*)cJSON_malloc(path_length + suffix_length + sizeof("/"));

        sprintf((char*)full_path, "%s/", (const char*)path);
        encode_string_as_pointer(full_path + path_length + 1, suffix);

        cJSON_AddItemToObject(patch, "path", cJSON_CreateString((const char*)full_path));
        cJSON_free(full_path);
    }

    if (value != NULL)
    {
        cJSON_AddItemToObject(patch, "value", cJSON_Duplicate(value, 1));
    }
    cJSON_AddItemToArray(patches, patch);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdi, -0x30(%rbp)
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testq %rdx, %rdx
sete %al
orb %cl, %al
jne 0x622c
movq %r8, %r15
movq %rdx, %r13
movq %rsi, %r14
callq 0x4301
testq %rax, %rax
je 0x622c
movq %rax, %rbx
movq %r14, %rdi
callq 0x4132
leaq 0x2074(%rip), %rsi      # 0x8261
movq %rbx, %rdi
movq %rax, %rdx
callq 0x3b4d
testq %r12, %r12
movq %rbx, %r14
je 0x62d4
movq %r15, -0x38(%rbp)
xorl %r15d, %r15d
movq %r12, %rax
movzbl (%rax), %ecx
cmpl $0x2f, %ecx
je 0x6221
cmpl $0x7e, %ecx
je 0x6221
testl %ecx, %ecx
jne 0x6224
jmp 0x623b
incq %r15
incq %rax
incq %r15
jmp 0x620e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x2140
movq %r14, %rbx
movq %rax, %r14
leaq (%r15,%rax), %rdi
addq $0x2, %rdi
callq 0x5094
leaq 0x2024(%rip), %rsi      # 0x8281
movq %rax, %rdi
movq %r13, %rdx
movq %rax, %r13
xorl %eax, %eax
callq 0x22c0
movq %r13, %rax
addq %r14, %rax
movq %rbx, %r14
movq -0x38(%rbp), %r15
movq -0x30(%rbp), %rbx
movzbl (%r12), %ecx
cmpl $0x2f, %ecx
je 0x62a0
cmpl $0x7e, %ecx
je 0x6298
incq %rax
testl %ecx, %ecx
je 0x62ad
movb %cl, (%rax)
jmp 0x62a8
movw $0x317e, 0x1(%rax)      # imm = 0x317E
jmp 0x62a4
movb $0x31, 0x2(%rax)
addq $0x2, %rax
incq %r12
jmp 0x627e
movb $0x0, (%rax)
movq %r13, %rdi
callq 0x4132
leaq 0x1f90(%rip), %rsi      # 0x824f
movq %r14, %rdi
movq %rax, %rdx
callq 0x3b4d
movq %r13, %rdi
callq 0x509f
jmp 0x62f2
movq %r13, %rdi
callq 0x4132
leaq 0x1f6c(%rip), %rsi      # 0x824f
movq %r14, %rdi
movq %rax, %rdx
callq 0x3b4d
movq -0x30(%rbp), %rbx
testq %r15, %r15
je 0x6316
movq %r15, %rdi
movl $0x1, %esi
callq 0x4b97
leaq 0x1f49(%rip), %rsi      # 0x8254
movq %r14, %rdi
movq %rax, %rdx
callq 0x3b4d
movq %rbx, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3b17