// File: /workspace/github_c_makefile_star2_O1/lengjingzju[P]json/json.c
// Function: json_parse_common
json_object *json_parse_common(json_parse_choice_t *choice)
{
    json_object *json = NULL;
    json_parse_t parse_val = {0};
    size_t mem_size = 0, total_size = 0;

    parse_val.read_size = parse_val.read_size ? parse_val.read_size : JSON_PARSE_READ_SIZE_DEF;
    parse_val.mem = choice->mem ? choice->mem : &s_invalid_json_mem;
    parse_val.fd = -1;
    if (choice->path) {
        if ((parse_val.fd = open(choice->path, O_RDONLY|O_BINARY)) < 0) {
            JsonErr("open(%s) failed!\n", choice->path);
            return NULL;
        }
        if (choice->str_len) {
            total_size = choice->str_len;
        } else {
            total_size = lseek(parse_val.fd, 0, SEEK_END);
            lseek(parse_val.fd, 0, SEEK_SET);
        }
        parse_val.skip_blank = _skip_blank;
        parse_val.parse_string = _json_parse_string;
        parse_val.parse_value = _json_parse_value;
    } else {
        parse_val.str = choice->str;
        total_size = choice->str_len ? choice->str_len : strlen(choice->str);
        parse_val.size = total_size;
        if (choice->mem) {
            parse_val.reuse_flag = choice->reuse_flag;
        }
        parse_val.skip_blank = _skip_blank_rapid;
        if (parse_val.reuse_flag) {
            parse_val.parse_string = _json_parse_string_reuse;
        } else {
            parse_val.parse_string = _json_parse_string_rapid;
        }
        parse_val.parse_value = _json_parse_value_rapid;
    }

    if (choice->mem && !choice->mem->valid) {
        pjson_memory_init(choice->mem);
        mem_size = total_size / JSON_PARSE_NUM_DIV_DEF;
        if (mem_size < choice->mem_size)
            mem_size = choice->mem_size;
        choice->mem->obj_mgr.mem_size = mem_size;
        choice->mem->key_mgr.mem_size = mem_size;
        choice->mem->str_mgr.mem_size = mem_size;
    }

#if !JSON_PARSE_SINGLE_VALUE
    parse_val.skip_blank(&parse_val);
    if (parse_val.str[parse_val.offset] != '{' && parse_val.str[parse_val.offset] != '[') {
        JsonErr("The first object isn't object or array\n");
        goto end;
    }
#endif

    if (parse_val.parse_value(&parse_val, &json) < 0) {
        if (choice->mem) {
            pjson_memory_free(choice->mem);
        } else {
            json_del_object(json);
        }
        json = NULL;
        goto end;
    }

#if !JSON_PARSE_FINISHED_CHAR
    parse_val.skip_blank(&parse_val);
    if (parse_val.str[parse_val.offset]) {
        JsonErr("Extra trailing characters!\n%s\n", parse_val.str + parse_val.offset);
        if (choice->mem) {
            pjson_memory_free(choice->mem);
        } else {
            json_del_object(json);
        }
        json = NULL;
        goto end;
    }
#endif

end:
    if (choice->path) {
        if (parse_val.str)
            json_free(parse_val.str);
        if (parse_val.fd >= 0)
            close(parse_val.fd);
    }
    return json;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rdi, %rbx
movq $0x0, (%rsp)
leaq 0x8(%rsp), %r14
movl $0x88, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x1100
movq 0x20(%r14), %rax
testq %rax, %rax
movl $0x2000, %ecx           # imm = 0x2000
cmovneq %rax, %rcx
movq %rcx, 0x20(%r14)
movq 0x20(%rbx), %r15
testq %r15, %r15
leaq 0xb63e(%rip), %rax      # 0x10238
cmovneq %r15, %rax
movq %rax, 0x38(%r14)
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x4c6f
xorl %esi, %esi
xorl %eax, %eax
callq 0x11b0
movl %eax, 0x8(%rsp)
testl %eax, %eax
js 0x4dc6
movq 0x10(%rbx), %r14
testq %r14, %r14
jne 0x4c4e
movl %eax, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x10f0
movq %rax, %r14
movl 0x8(%rsp), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10f0
leaq 0x1ea(%rip), %rax       # 0x4e3f
movq %rax, 0x48(%rsp)
leaq -0x3275(%rip), %rax     # 0x19ec
movq %rax, 0x50(%rsp)
leaq 0x239(%rip), %rax       # 0x4ea6
jmp 0x4cc9
movq 0x30(%rbx), %rdi
movq %rdi, 0x38(%rsp)
movq 0x10(%rbx), %r14
testq %r14, %r14
jne 0x4c89
callq 0x10c0
movq %rax, %r14
movq %r14, 0x10(%rsp)
testq %r15, %r15
je 0x4c9a
movb 0x18(%rbx), %al
movb %al, 0x30(%rsp)
leaq 0x710(%rip), %rax       # 0x53b1
movq %rax, 0x48(%rsp)
leaq 0x722(%rip), %rax       # 0x53cf
leaq 0xb4f(%rip), %rcx       # 0x5803
cmpb $0x0, 0x30(%rsp)
cmovneq %rax, %rcx
movq %rcx, 0x50(%rsp)
leaq 0xd09(%rip), %rax       # 0x59d2
movq %rax, 0x58(%rsp)
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x4d3e
cmpb $0x0, (%rax)
jne 0x4d3e
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0x10(%rax)
leaq 0xb5b1(%rip), %rcx      # 0x102a0
movq %rcx, 0x20(%rax)
movl $0x2000, %edx           # imm = 0x2000
movq %rdx, 0x18(%rax)
leaq 0x28(%rax), %rsi
movq %rsi, 0x28(%rax)
movq %rsi, 0x30(%rax)
movq %rcx, 0x40(%rax)
movq %rdx, 0x38(%rax)
leaq 0x48(%rax), %rsi
movq %rsi, 0x48(%rax)
movq %rsi, 0x50(%rax)
movq %rcx, 0x60(%rax)
movq %rdx, 0x58(%rax)
shrq $0x3, %r14
movq (%rbx), %rcx
cmpq %rcx, %r14
cmovbeq %rcx, %r14
movq %r14, 0x18(%rax)
movq %r14, 0x38(%rax)
movq %r14, 0x58(%rax)
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
callq *0x50(%rdi)
testl %eax, %eax
js 0x4d9d
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq *0x40(%r14)
movq 0x10(%r14), %rax
movq 0x30(%r14), %rcx
cmpb $0x0, (%rcx,%rax)
je 0x4e08
leaq 0x56ea(%rip), %rdi      # 0xa45c
leaq 0x5849(%rip), %rsi      # 0xa5c2
movl $0xe49, %edx            # imm = 0xE49
xorl %eax, %eax
callq 0x10d0
movq 0x38(%rsp), %rsi
addq 0x18(%rsp), %rsi
leaq 0x5850(%rip), %rdi      # 0xa5e6
xorl %eax, %eax
callq 0x10d0
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x4df7
leaq 0x8(%r14), %rdi
callq 0x3c36
leaq 0x28(%r14), %rdi
callq 0x3c36
addq $0x48, %r14
movq %r14, %rdi
callq 0x3c36
jmp 0x4e00
leaq 0x568f(%rip), %rdi      # 0xa45c
leaq 0x57ee(%rip), %rsi      # 0xa5c2
xorl %r14d, %r14d
movl $0xe0e, %edx            # imm = 0xE0E
xorl %eax, %eax
callq 0x10d0
movq 0x28(%rbx), %rsi
leaq 0x57e6(%rip), %rdi      # 0xa5d4
xorl %eax, %eax
callq 0x10d0
jmp 0x4e2f
movq (%rsp), %rdi
callq 0x3af7
movq $0x0, (%rsp)
cmpq $0x0, 0x28(%rbx)
je 0x4e2b
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x4e1e
callq 0x1030
movl 0x8(%rsp), %edi
testl %edi, %edi
js 0x4e2b
callq 0x1110
movq (%rsp), %r14
movq %r14, %rax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq