// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rdi, %rbx
andq $0x0, (%rsp)
leaq 0x8(%rsp), %r14
movl $0x88, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x10f0
movq $0x2000, 0x20(%r14)     # imm = 0x2000
movq 0x20(%rbx), %r15
testq %r15, %r15
leaq 0xa9e6(%rip), %rax      # 0xe228
cmovneq %r15, %rax
movq %rax, 0x38(%r14)
orl $-0x1, (%r14)
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x38be
xorl %esi, %esi
xorl %eax, %eax
callq 0x11a0
movl %eax, 0x8(%rsp)
testl %eax, %eax
js 0x3902
movq 0x10(%rbx), %r14
testq %r14, %r14
jne 0x3891
movl %eax, %ebp
pushq $0x2
popq %rdx
movl %eax, %edi
xorl %esi, %esi
callq 0x10e0
movq %rax, %r14
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10e0
leaq 0x1a1(%rip), %rax       # 0x3a39
movq %rax, 0x48(%rsp)
leaq 0x1ef(%rip), %rax       # 0x3a93
movq %rax, 0x50(%rsp)
leaq 0x39a(%rip), %r12       # 0x3c4a
movq %r12, 0x58(%rsp)
movq 0x20(%rbx), %r15
jmp 0x395a
movq 0x30(%rbx), %rdi
movq %rdi, 0x38(%rsp)
movq 0x10(%rbx), %r14
testq %r14, %r14
jne 0x38d8
callq 0x10b0
movq %rax, %r14
movq %r14, 0x10(%rsp)
testq %r15, %r15
je 0x3936
movb 0x18(%rbx), %al
movb %al, 0x30(%rsp)
leaq 0x80f(%rip), %rcx       # 0x40ff
movq %rcx, 0x48(%rsp)
testb %al, %al
je 0x3942
leaq 0x81d(%rip), %rax       # 0x411d
jmp 0x3949
leaq 0x4b53(%rip), %rdi      # 0x845c
leaq 0x4cb2(%rip), %rsi      # 0x85c2
xorl %r14d, %r14d
movl $0xe0e, %edx            # imm = 0xE0E
xorl %eax, %eax
callq 0x10c0
movq 0x28(%rbx), %rsi
leaq 0x4caa(%rip), %rdi      # 0x85d4
xorl %eax, %eax
callq 0x10c0
jmp 0x3a26
leaq 0x7c2(%rip), %rax       # 0x40ff
movq %rax, 0x48(%rsp)
leaq 0xb6d(%rip), %rax       # 0x44b6
movq %rax, 0x50(%rsp)
leaq 0xd6a(%rip), %r12       # 0x46bf
movq %r12, 0x58(%rsp)
testq %r15, %r15
je 0x398b
cmpb $0x0, (%r15)
jne 0x398b
movq %r15, %rdi
callq 0x201c
shrq $0x3, %r14
movq (%rbx), %rax
cmpq %rax, %r14
cmovbeq %rax, %r14
movq 0x20(%rbx), %rax
movq %r14, 0x18(%rax)
movq %r14, 0x38(%rax)
movq %r14, 0x58(%rax)
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
callq *%r12
testl %eax, %eax
js 0x39e6
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq *0x40(%r14)
movq 0x10(%r14), %rax
movq 0x30(%r14), %rcx
cmpb $0x0, (%rcx,%rax)
je 0x3a04
leaq 0x4aa1(%rip), %rdi      # 0x845c
leaq 0x4c00(%rip), %rsi      # 0x85c2
movl $0xe49, %edx            # imm = 0xE49
xorl %eax, %eax
callq 0x10c0
movq 0x38(%rsp), %rsi
addq 0x18(%rsp), %rsi
leaq 0x4c07(%rip), %rdi      # 0x85e6
xorl %eax, %eax
callq 0x10c0
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x39f6
callq 0x2065
jmp 0x39ff
movq (%rsp), %rdi
callq 0x1f55
andq $0x0, (%rsp)
cmpq $0x0, 0x28(%rbx)
je 0x3a22
movq 0x38(%rsp), %rdi
callq 0x1030
movl 0x8(%rsp), %edi
testl %edi, %edi
js 0x3a22
callq 0x1100
movq (%rsp), %r14
movq %r14, %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq