// File: /workspace/github_c_makefile_star2_O0/tomcatzh[P]RealityBenchmark/external/cJSON.c
// Function: print
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
{
    static const size_t default_buffer_size = 256;
    printbuffer buffer[1];
    unsigned char *printed = NULL;

    memset(buffer, 0, sizeof(buffer));

    /* create buffer */
    buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size);
    buffer->length = default_buffer_size;
    buffer->format = format;
    buffer->hooks = *hooks;
    if (buffer->buffer == NULL)
    {
        goto fail;
    }

    /* print the value */
    if (!print_value(item, buffer))
    {
        goto fail;
    }
    update_offset(buffer);

    /* check if reallocate is available */
    if (hooks->reallocate != NULL)
    {
        printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
        if (printed == NULL) {
            goto fail;
        }
        buffer->buffer = NULL;
    }
    else /* otherwise copy the JSON over to a new buffer */
    {
        printed = (unsigned char*) hooks->allocate(buffer->offset + 1);
        if (printed == NULL)
        {
            goto fail;
        }
        memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1));
        printed[buffer->offset] = '\0'; /* just to be sure */

        /* free the buffer */
        hooks->deallocate(buffer->buffer);
    }

    return printed;

fail:
    if (buffer->buffer != NULL)
    {
        hooks->deallocate(buffer->buffer);
    }

    if (printed != NULL)
    {
        hooks->deallocate(printed);
    }

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2130
movq -0x20(%rbp), %rax
movl $0x100, %edi            # imm = 0x100
callq *(%rax)
movq %rax, -0x60(%rbp)
movq $0x100, -0x58(%rbp)     # imm = 0x100
movl -0x14(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x7032
jmp 0x711a
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x7260
cmpl $0x0, %eax
jne 0x7049
jmp 0x711a
leaq -0x60(%rbp), %rdi
callq 0x9830
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x7090
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq $0x1, %rsi
callq *%rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x7083
jmp 0x711a
movq $0x0, -0x60(%rbp)
jmp 0x7110
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x50(%rbp), %rdi
addq $0x1, %rdi
callq *%rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x70ae
jmp 0x711a
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x70d9
movq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x70e5
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rdx
callq 0x21f0
movq -0x68(%rbp), %rax
movq -0x50(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x60(%rbp), %rdi
callq *%rax
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x714c
cmpq $0x0, -0x60(%rbp)
je 0x712f
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x60(%rbp), %rdi
callq *%rax
cmpq $0x0, -0x68(%rbp)
je 0x7144
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x68(%rbp), %rdi
callq *%rax
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)