// File: /workspace/github_c_makefile_star2_O0/lengjingzju[P]json/json.c
// Function: print_val_release
static int _print_val_release(json_print_t *print_ptr, bool free_all_flag, size_t *length, json_print_ptr_t *ptr)
{
#define _clear_free_ptr(ptr)    do { if (ptr) json_free(ptr); ptr = NULL; } while(0)
#define _clear_close_fd(fd)     do { if (fd >= 0) close(fd); fd = -1; } while(0)
    int ret = 0;
    size_t used = GET_BUF_USED_SIZE(print_ptr);

    if (print_ptr->fd >= 0) {
        if (!free_all_flag && used > 0) {
            if (used != (size_t)write(print_ptr->fd, print_ptr->ptr, used)) {
                JsonErr("write failed!\n");
                ret = -1;
            }
        }
        _clear_close_fd(print_ptr->fd);
        if (ptr) {
            ptr->size = print_ptr->size;
            ptr->p = print_ptr->ptr;
        } else {
            _clear_free_ptr(print_ptr->ptr);
        }
    } else {
        if (free_all_flag) {
            _clear_free_ptr(print_ptr->ptr);
        } else {
            if (length)
                *length = print_ptr->cur - print_ptr->ptr;
            *print_ptr->cur = '\0';


            if (ptr) {
                ptr->size = print_ptr->size;
                ptr->p = print_ptr->ptr;
            } else {
                /* Reduce size, never fail */
                print_ptr->ptr = (char *)json_realloc(print_ptr->ptr, used + 1);
            }
        }
    }

    return ret;
}

// Assembly:
subq $0x38, %rsp
movb %sil, %al
movq %rdi, 0x30(%rsp)
andb $0x1, %al
movb %al, 0x2f(%rsp)
movq %rdx, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x8(%rcx), %rcx
subq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
jl 0x481e
testb $0x1, 0x2f(%rsp)
jne 0x479e
cmpq $0x0, 0x8(%rsp)
jbe 0x479e
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq 0x30(%rsp), %rax
movl (%rax), %edi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsp), %rdx
callq 0x1090
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
je 0x479c
jmp 0x476c
leaq 0xc281(%rip), %rdi      # 0x109f4
leaq 0xc58f(%rip), %rsi      # 0x10d09
movl $0x6e7, %edx            # imm = 0x6E7
movb $0x0, %al
callq 0x10c0
leaq 0xc53e(%rip), %rdi      # 0x10ccb
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
jmp 0x479e
jmp 0x47a0
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
jl 0x47b6
movq 0x30(%rsp), %rax
movl (%rax), %edi
callq 0x1100
movq 0x30(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, 0x18(%rsp)
je 0x47ee
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x4819
jmp 0x47f0
movq 0x30(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x480a
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x1030
movq 0x30(%rsp), %rax
movq $0x0, 0x8(%rax)
jmp 0x4819
jmp 0x48d8
testb $0x1, 0x2f(%rsp)
je 0x4853
jmp 0x4827
movq 0x30(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4841
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x1030
movq 0x30(%rsp), %rax
movq $0x0, 0x8(%rax)
jmp 0x48d6
cmpq $0x0, 0x20(%rsp)
je 0x4878
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
subq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movb $0x0, (%rax)
cmpq $0x0, 0x18(%rsp)
je 0x48b1
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x48d4
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x8(%rsp), %rsi
addq $0x1, %rsi
callq 0x1180
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x48d6
jmp 0x48d8
movl 0x14(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)