// File: /workspace/github_c_makefile_star2_O2/lengjingzju[P]json/json.c
// Function: json_search_object_item
json_object *json_search_object_item(json_items_t *items, json_string_t *jkey, uint32_t hash)
{
    int left = 0, right = 0, middle = 0, i = 0, count = 0;
    json_object *json = NULL;
    if (!hash)
        hash = json_string_hash_code(jkey);

    count = items->count;
    if (!count)
        return NULL;

    right = count - 1;
    while (left <= right) {
        middle = (left + right) >> 1;
        if (hash == items->items[middle].hash) {
            if (!items->conflicted)
                return items->items[middle].json;

            if (jkey->len) {
                for (i = middle; i < count; ++i) {
                    if (hash != items->items[i].hash)
                        break;
                    json = items->items[i].json;
                    if (jkey->len == json->jkey.len && memcmp(jkey->str, json->key_member, jkey->len) == 0)
                        return json;
                }
                for (i = middle - 1; i >= 0; --i) {
                    if (hash != items->items[i].hash)
                        break;
                    json = items->items[i].json;
                    if (jkey->len == json->jkey.len && memcmp(jkey->str, json->key_member, jkey->len) == 0)
                        return json;
                }
            } else {
                for (i = middle; i < count; ++i) {
                    if (hash != items->items[i].hash)
                        break;
                    json = items->items[i].json;
                    if (!json->jkey.len)
                        return json;
                }
                for (i = middle - 1; i >= 0; --i) {
                    if (hash != items->items[i].hash)
                        break;
                    json = items->items[i].json;
                    if (!json->jkey.len)
                        return json;
                }
            }
            return NULL;
        }

        if (hash > items->items[middle].hash)
            left = middle + 1;
        else
            right = middle - 1;
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
movq %rsi, %rbp
movq %rdi, %r12
testl %edx, %edx
jne 0x2cd9
movq %rbp, %rdi
callq 0x2130
movl %eax, %ebx
movslq 0x8(%r12), %rdi
xorl %r15d, %r15d
testq %rdi, %rdi
je 0x2e6f
leal -0x1(%rdi), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x2e6f
leal (%rcx,%rax), %r13d
shrl %r13d
movq 0x10(%r12), %r14
movq %r13, %rdx
shlq $0x4, %rdx
movl (%r14,%rdx), %esi
cmpl %esi, %ebx
je 0x2d24
ja 0x2d1c
decl %r13d
movl %r13d, %ecx
jmp 0x2cef
incl %r13d
movl %r13d, %eax
jmp 0x2cef
testb $0x1, (%r12)
jne 0x2d37
addq %rdx, %r14
movq 0x8(%r14), %r15
jmp 0x2e6f
movl (%rbp), %ecx
cmpq $0xff, %rcx
ja 0x2d81
movq %r13, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rcx
addq $0x8, %rcx
leaq -0x1(%r13), %rdx
incq %rdx
cmpq %rdi, %rdx
jge 0x2e45
cmpl -0x8(%rcx), %ebx
jne 0x2e45
movq (%rcx), %r15
addq $0x10, %rcx
cmpl $0x100, 0x8(%r15)       # imm = 0x100
jae 0x2d56
jmp 0x2e6f
movq %rbp, 0x10(%rsp)
shrl $0x8, %ecx
movq %r13, %rax
shlq $0x4, %rax
movq %rax, 0x18(%rsp)
leaq (%r14,%rax), %r12
addq $0x8, %r12
movq %r13, %rbp
movq %rcx, 0x8(%rsp)
movq %rdi, 0x20(%rsp)
cmpq %rdi, %rbp
jge 0x2df7
cmpl -0x8(%r12), %ebx
jne 0x2df7
movq (%r12), %r15
movl 0x8(%r15), %eax
shrl $0x8, %eax
cmpl %eax, %ecx
jne 0x2dee
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x10(%r15), %rsi
movq 0x8(%rsp), %rdx
callq 0x2200
movq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rdi
testl %eax, %eax
je 0x2e6f
incq %rbp
addq $0x10, %r12
jmp 0x2daa
movq 0x18(%rsp), %rax
addq %rax, %r14
addq $-0x8, %r14
testq %r13, %r13
jle 0x2e6c
cmpl -0x8(%r14), %ebx
jne 0x2e6c
movq (%r14), %r15
movl 0x8(%r15), %eax
shrl $0x8, %eax
cmpl %eax, %ecx
jne 0x2e3c
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x10(%r15), %rsi
movq 0x8(%rsp), %rdx
callq 0x2200
movq 0x8(%rsp), %rcx
testl %eax, %eax
je 0x2e6f
addq $-0x10, %r14
decq %r13
jmp 0x2e03
incq %r13
addq %r14, %rax
addq $-0x8, %rax
decq %r13
jle 0x2e6c
cmpl -0x8(%rax), %ebx
jne 0x2e6c
movq (%rax), %r15
addq $-0x10, %rax
cmpl $0x100, 0x8(%r15)       # imm = 0x100
jae 0x2e4f
jmp 0x2e6f
xorl %r15d, %r15d
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq