// File: /workspace/github_c_makefile_star2_O3/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 %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq $0x0, 0x8(%rsp)
leaq 0x10(%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 0xb24e(%rip), %rax      # 0x10228
cmovneq %r15, %rax
movq %rax, 0x38(%r14)
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x505b
xorl %esi, %esi
xorl %eax, %eax
callq 0x11a0
movl %eax, 0x10(%rsp)
testl %eax, %eax
js 0x509f
movq 0x10(%rbx), %r14
testq %r14, %r14
jne 0x502e
movl %eax, %ebp
movl %eax, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x10e0
movq %rax, %r14
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10e0
leaq 0x1ef(%rip), %rax       # 0x5224
movq %rax, 0x50(%rsp)
leaq -0x35cc(%rip), %rax     # 0x1a75
movq %rax, 0x58(%rsp)
leaq 0x23e(%rip), %rax       # 0x528b
movq %rax, 0x60(%rsp)
movq 0x20(%rbx), %r15
jmp 0x50f7
movq 0x30(%rbx), %rdi
movq %rdi, 0x40(%rsp)
movq 0x10(%rbx), %r14
testq %r14, %r14
jne 0x5075
callq 0x10b0
movq %rax, %r14
movq %r14, 0x18(%rsp)
testq %r15, %r15
je 0x50d3
movb 0x18(%rbx), %al
movb %al, 0x38(%rsp)
leaq 0x6d3(%rip), %rcx       # 0x5760
movq %rcx, 0x50(%rsp)
testb %al, %al
je 0x50df
leaq 0x6e1(%rip), %rax       # 0x577e
jmp 0x50e6
leaq 0x53b6(%rip), %rdi      # 0xa45c
leaq 0x5515(%rip), %rsi      # 0xa5c2
xorl %r14d, %r14d
movl $0xe0e, %edx            # imm = 0xE0E
xorl %eax, %eax
callq 0x10c0
movq 0x28(%rbx), %rsi
leaq 0x550d(%rip), %rdi      # 0xa5d4
xorl %eax, %eax
callq 0x10c0
jmp 0x5213
leaq 0x686(%rip), %rax       # 0x5760
movq %rax, 0x50(%rsp)
leaq 0xa46(%rip), %rax       # 0x5b2c
movq %rax, 0x58(%rsp)
leaq 0xc03(%rip), %rax       # 0x5cf5
movq %rax, 0x60(%rsp)
testq %r15, %r15
je 0x5153
cmpb $0x0, (%r15)
jne 0x5153
leaq 0x8(%r15), %rcx
movq %rcx, 0x8(%r15)
movq %rcx, 0x10(%r15)
leaq 0xb17b(%rip), %rcx      # 0x10290
movq %rcx, 0x20(%r15)
leaq 0x28(%r15), %rdx
movq %rdx, 0x28(%r15)
movq %rdx, 0x30(%r15)
movq %rcx, 0x40(%r15)
leaq 0x48(%r15), %rdx
movq %rdx, 0x48(%r15)
movq %rdx, 0x50(%r15)
movq %rcx, 0x60(%r15)
shrq $0x3, %r14
movq (%rbx), %rcx
cmpq %rcx, %r14
cmovbeq %rcx, %r14
movq %r14, 0x18(%r15)
movq %r14, 0x38(%r15)
movq %r14, 0x58(%r15)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq *%rax
testl %eax, %eax
js 0x51af
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq *0x40(%r14)
movq 0x10(%r14), %rax
movq 0x30(%r14), %rcx
cmpb $0x0, (%rcx,%rax)
je 0x51eb
leaq 0x52d8(%rip), %rdi      # 0xa45c
leaq 0x5437(%rip), %rsi      # 0xa5c2
movl $0xe49, %edx            # imm = 0xE49
xorl %eax, %eax
callq 0x10c0
movq 0x40(%rsp), %rsi
addq 0x20(%rsp), %rsi
leaq 0x543e(%rip), %rdi      # 0xa5e6
xorl %eax, %eax
callq 0x10c0
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x51d8
leaq 0x8(%r14), %rdi
callq 0x3faa
leaq 0x28(%r14), %rdi
callq 0x3faa
addq $0x48, %r14
movq %r14, %rdi
callq 0x3faa
jmp 0x51e2
movq 0x8(%rsp), %rdi
callq 0x3e4d
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x28(%rbx)
je 0x520e
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x5201
callq 0x1030
movl 0x10(%rsp), %edi
testl %edi, %edi
js 0x520e
callq 0x1100
movq 0x8(%rsp), %r14
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq