// File: yangwanyuan[P]HLKVDS/tools/Benchmark.cc
// Function: fun_get(void*)
void* fun_get(void *arg) {
    thread_arg *t_args = (thread_arg*) arg;
    KVDS *db = t_args->db;
    int key_start = t_args->key_start;
    int key_end = t_args->key_end;
    vector<string> &key_list = *t_args->key_list;
    uint64_t *latency = t_args->latency;

    string *value = t_args->data;
    int key_len = KEY_SIZE;
    Status s;

    for (int i = key_start; i < key_end + 1; i++) {
        string key = key_list[i];
        string get_data;
        KVTime tv_start;
        s = db->Get(key.c_str() ,key_len, get_data);
        KVTime tv_end;
        latency[i - key_start] = (uint64_t)(tv_end - tv_start);

        if (!s.ok()) {
            cout << "Get key = " << key << "from DB failed!" << endl;
        }
        if (strcmp(get_data.c_str(), value->c_str()) != 0) {
            cout << "Get key=" << key << "Inconsistent! " << endl;
            cout << "Value size = " << get_data.length() << endl;
            cout << "value = " << get_data << endl;
        }
    }
    return NULL;
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x140(%rsp)
movq 0x148(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x13c(%rsp)
movq 0x148(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0x138(%rsp)
movq 0x148(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x130(%rsp)
movq 0x148(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x128(%rsp)
movq 0x148(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x120(%rsp)
movl $0xa, 0x11c(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xce70
movl 0x13c(%rsp), %eax
movl %eax, 0xfc(%rsp)
movl 0xfc(%rsp), %eax
movl 0x138(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0xa532
movq 0x130(%rsp), %rdi
movslq 0xfc(%rsp), %rsi
callq 0xce90
movq %rax, %rsi
leaq 0xd8(%rsp), %rdi
callq 0x81b0
jmp 0xa1e8
leaq 0xa8(%rsp), %rdi
callq 0x86e0
leaq 0x98(%rsp), %rdi
callq 0x555c0
jmp 0xa204
movq 0x140(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x8190
movq 0x70(%rsp), %rsi
movq %rax, %rdx
movl 0x11c(%rsp), %ecx
leaq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %r8
callq 0x32190
jmp 0xa244
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x100(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xceb0
leaq 0x78(%rsp), %rdi
callq 0x555c0
jmp 0xa26d
leaq 0x78(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x55770
movq %rax, 0x68(%rsp)
jmp 0xa286
movq 0x68(%rsp), %rdx
movq 0x128(%rsp), %rax
movl 0xfc(%rsp), %ecx
movl 0x13c(%rsp), %esi
subl %esi, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x100(%rsp), %rdi
callq 0xcef0
movb %al, 0x67(%rsp)
jmp 0xa2bd
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0xa399
jmp 0xa2cb
movq 0x6dcfe(%rip), %rdi     # 0x77fd0
leaq 0x4d00e(%rip), %rsi     # 0x572e7
callq 0x8520
movq %rax, 0x58(%rsp)
jmp 0xa2e5
movq 0x58(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x84a0
movq %rax, 0x50(%rsp)
jmp 0xa2fe
movq 0x50(%rsp), %rdi
leaq 0x4cfe8(%rip), %rsi     # 0x572f2
callq 0x8520
movq %rax, 0x48(%rsp)
jmp 0xa316
movq 0x48(%rsp), %rdi
movq 0x6dc7e(%rip), %rsi     # 0x77fa0
callq 0x8560
jmp 0xa329
jmp 0xa399
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xa549
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xa516
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xa509
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x557b0
jmp 0xa509
leaq 0xa8(%rsp), %rdi
callq 0x8190
movq %rax, 0x40(%rsp)
movq 0x120(%rsp), %rdi
callq 0x8190
movq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x86f0
cmpl $0x0, %eax
je 0xa4c2
movq 0x6dbfb(%rip), %rdi     # 0x77fd0
leaq 0x4cf26(%rip), %rsi     # 0x57302
callq 0x8520
movq %rax, 0x38(%rsp)
jmp 0xa3e8
movq 0x38(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x84a0
movq %rax, 0x30(%rsp)
jmp 0xa401
movq 0x30(%rsp), %rdi
leaq 0x4cefe(%rip), %rsi     # 0x5730b
callq 0x8520
movq %rax, 0x28(%rsp)
jmp 0xa419
movq 0x28(%rsp), %rdi
movq 0x6db7b(%rip), %rsi     # 0x77fa0
callq 0x8560
jmp 0xa42c
movq 0x6db9d(%rip), %rdi     # 0x77fd0
leaq 0x4cee0(%rip), %rsi     # 0x5731a
callq 0x8520
movq %rax, 0x20(%rsp)
jmp 0xa446
leaq 0xa8(%rsp), %rdi
callq 0x8770
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x80f0
movq %rax, 0x18(%rsp)
jmp 0xa467
movq 0x18(%rsp), %rdi
movq 0x6db2d(%rip), %rsi     # 0x77fa0
callq 0x8560
jmp 0xa47a
movq 0x6db4f(%rip), %rdi     # 0x77fd0
leaq 0x4cea0(%rip), %rsi     # 0x57328
callq 0x8520
movq %rax, 0x10(%rsp)
jmp 0xa494
movq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x84a0
movq %rax, 0x8(%rsp)
jmp 0xa4ad
movq 0x8(%rsp), %rdi
movq 0x6dae7(%rip), %rsi     # 0x77fa0
callq 0x8560
jmp 0xa4c0
jmp 0xa4c2
leaq 0x78(%rsp), %rdi
callq 0x557b0
leaq 0x98(%rsp), %rdi
callq 0x557b0
leaq 0xa8(%rsp), %rdi
callq 0x8998
leaq 0xd8(%rsp), %rdi
callq 0x8998
movl 0xfc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xfc(%rsp)
jmp 0xa1a8
leaq 0x98(%rsp), %rdi
callq 0x557b0
leaq 0xa8(%rsp), %rdi
callq 0x8998
leaq 0xd8(%rsp), %rdi
callq 0x8998
jmp 0xa549
leaq 0x100(%rsp), %rdi
callq 0xceb0
xorl %eax, %eax
addq $0x158, %rsp            # imm = 0x158
retq
leaq 0x100(%rsp), %rdi
callq 0xceb0
movq 0xd0(%rsp), %rdi
callq 0x8880
nopw %cs:(%rax,%rax)