// File: /workspace/github_c_makefile_star2_O1/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 0x63a3
movq %r8, %r15
movq %rdx, %r13
movq %rsi, %r14
callq 0x43b2
testq %rax, %rax
je 0x63a3
movq %rax, %rbx
movq %r14, %rdi
callq 0x41e3
leaq 0x1f05(%rip), %rsi      # 0x8269
movq %rbx, %rdi
movq %rax, %rdx
callq 0x3bde
testq %r12, %r12
movq %rbx, %r14
je 0x644b
movq %r15, -0x38(%rbp)
xorl %r15d, %r15d
movq %r12, %rax
movzbl (%rax), %ecx
cmpl $0x2f, %ecx
je 0x6398
cmpl $0x7e, %ecx
je 0x6398
testl %ecx, %ecx
jne 0x639b
jmp 0x63b2
incq %r15
incq %rax
incq %r15
jmp 0x6385
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 0x5169
leaq 0x1eb5(%rip), %rsi      # 0x8289
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 0x6417
cmpl $0x7e, %ecx
je 0x640f
incq %rax
testl %ecx, %ecx
je 0x6424
movb %cl, (%rax)
jmp 0x641f
movw $0x317e, 0x1(%rax)      # imm = 0x317E
jmp 0x641b
movb $0x31, 0x2(%rax)
addq $0x2, %rax
incq %r12
jmp 0x63f5
movb $0x0, (%rax)
movq %r13, %rdi
callq 0x41e3
leaq 0x1e21(%rip), %rsi      # 0x8257
movq %r14, %rdi
movq %rax, %rdx
callq 0x3bde
movq %r13, %rdi
callq 0x5174
jmp 0x6469
movq %r13, %rdi
callq 0x41e3
leaq 0x1dfd(%rip), %rsi      # 0x8257
movq %r14, %rdi
movq %rax, %rdx
callq 0x3bde
movq -0x30(%rbp), %rbx
testq %r15, %r15
je 0x648d
movq %r15, %rdi
movl $0x1, %esi
callq 0x4c70
leaq 0x1dda(%rip), %rsi      # 0x825c
movq %r14, %rdi
movq %rax, %rdx
callq 0x3bde
movq %rbx, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3ba8