// File: /workspace/github_cpp_makefile_star2_O3/chahk0129[P]hash_bench/./bench/benchmark.hpp
// Function: benchmark_t<unsigned long>::ycsb_load(int, int, Pair<unsigned long>*, int, Pair<unsigned long>*, int, int*)
inline void benchmark_t<Key_t>::ycsb_load(int workload_type, int index_type, Pair<Key_t>* init_kv, int init_num, Pair<Key_t>* run_kv, int run_num, int* ops){
    std::string init_file;
    std::string txn_file;

    if(workload_type == WORKLOAD_A){
	init_file = "/hk/workloads2/loada_zipfian_int_100M.dat";
	txn_file = "/hk/workloads2/txnsa_zipfian_int_100M.dat";
    }
    else if(workload_type == WORKLOAD_B){
	init_file = "/hk/workloads2/loadb_zipfian_int_100M.dat";
	txn_file = "/hk/workloads2/txnsb_zipfian_int_100M.dat";
    }
    else if(workload_type == WORKLOAD_C){
	init_file = "/hk/workloads2/loadc_zipfian_int_100M.dat";
	txn_file = "/hk/workloads2/txnsc_zipfian_int_100M.dat";
    }
    else if(workload_type == WORKLOAD_D){
	init_file = "/hk/workloads2/loadd_zipfian_int_100M.dat";
	txn_file = "/hk/workloads2/txnsd_zipfian_int_100M.dat";
    }
    else{
	fprintf(stderr, "unkonw workload type %d\n", workload_type);
	exit(1);
    }


    uint64_t value = 0;
    void* base_ptr = malloc(8);
    uint64_t base = (uint64_t)base_ptr;
    free(base_ptr);

    std::ifstream infile_load;
    infile_load.open(init_file.c_str());
    if(!infile_load.is_open()){
	fprintf(stderr, "init file failed to open\n");
	exit(1);
    }

    std::string op;
    std::string key_;
    Key_t key;

    std::string insert("INSERT");
    std::string read("READ");
    std::string update("UPDATE");

    for(int i=0; i<init_num; i++){
	if constexpr(sizeof(Key_t) > 8)
	    infile_load >> op >> key_;
	else
	    infile_load >> op >> key;
	if(op.compare(insert) != 0){
	    fprintf(stderr, "Reading load file failed\n");
	    exit(1);
	}
	if constexpr(sizeof(Key_t) > 8){
	    strcpy(init_kv[i].key, key_.c_str());
	    //memcpy(init_kv[i].key, key_.c_str(), sizeof(Key_t));
	    //init_kv[i].key[sizeof(Key_t)-1] = 0;
	}
	else
	    init_kv[i].key = key;
	init_kv[i].value = base + rand();
	if constexpr(sizeof(Key_t) > 8)
	    key_ = "";

    }

    infile_load.close();

    Pair<Key_t>* init_kv_data = &init_kv[0];


    std::ifstream infile_txn;
    infile_txn.open(txn_file.c_str());
    if(!infile_txn.is_open()){
	fprintf(stderr, "txn file failed to open\n");
	exit(1);
    }
    
    for(int i=0; i<run_num; i++){
	if constexpr(sizeof(Key_t) > 8)
	    infile_txn >> op >> key_;
	else
	    infile_txn >> op >> key;
	if(op.compare(insert) == 0){
	    ops[i] = OP_INSERT;
	    if constexpr(sizeof(Key_t) > 8){
		strcpy(run_kv[i].key, key_.c_str());
		//memcpy(run_kv[i].key, key_.c_str(), sizeof(Key_t));
		//run_kv[i].key[sizeof(Key_t)-1] = 0;
	    }
	    else
		run_kv[i].key = key;
	    run_kv[i].value = (uint64_t)&run_kv[i];
	}
	else if(op.compare(read) == 0){
	    ops[i] = OP_READ;
	    if constexpr(sizeof(Key_t) > 8){
		strcpy(run_kv[i].key, key_.c_str());
		//memcpy(run_kv[i].key, key_.c_str(), sizeof(Key_t));
		run_kv[i].key[sizeof(Key_t)-1] = 0;
	    }
	    else
		run_kv[i].key = key;
	}
	else if(op.compare(update) == 0){
	    ops[i] = OP_UPDATE;
	    if constexpr(sizeof(Key_t) > 8){
		strcpy(run_kv[i].key, key_.c_str());
		//memcpy(run_kv[i].key, key_.c_str(), sizeof(Key_t));
		//run_kv[i].key[sizeof(Key_t)-1] = 0;
	    }
	    else
		run_kv[i].key = key;
	    run_kv[i].value = (uint64_t)&run_kv[i];
	}
	else{
	    fprintf(stderr, "unknown operation type\n");
	    exit(1);
	}
	if constexpr(sizeof(Key_t) > 8)
	    key_ = "";
    }

    infile_txn.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x518, %rsp            # imm = 0x518
movq %r9, 0x10(%rsp)
movl %r8d, %ebp
movq %rcx, 0xe0(%rsp)
movl %esi, %r15d
leaq 0x68(%rsp), %r14
leaq 0x310(%rsp), %r12
movq %r12, %rdi
callq 0xb754
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xd146
xorl %ebx, %ebx
movq %rbx, -0x8(%r14)
movq -0x10(%r14), %rax
movb %bl, (%rax)
leaq 0xc8(%rsp), %r14
leaq 0x310(%rsp), %r12
movq %r12, %rdi
callq 0xb754
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xd146
movq %rbx, -0x8(%r14)
movq -0x10(%r14), %rax
movb %bl, (%rax)
cmpl $0x3, %r15d
ja 0xbe19
movl %r15d, %eax
leaq 0x219e3(%rip), %rcx     # 0x2d260
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x21d19(%rip), %rcx     # 0x2d5af
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x21d2f(%rip), %rcx     # 0x2d5d9
jmp 0xb91c
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x21d9b(%rip), %rcx     # 0x2d657
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x21db1(%rip), %rcx     # 0x2d681
jmp 0xb91c
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x21dc9(%rip), %rcx     # 0x2d6ab
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x21ddf(%rip), %rcx     # 0x2d6d5
jmp 0xb91c
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x21cfb(%rip), %rcx     # 0x2d603
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x21d11(%rip), %rcx     # 0x2d62d
leaq 0xb8(%rsp), %rdi
movq 0x8(%rdi), %rdx
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
movl $0x8, %edi
callq 0x5530
movq %rax, 0xd8(%rsp)
movq %rax, %rdi
callq 0x54c0
leaq 0x310(%rsp), %rdi
callq 0x5460
movq 0x58(%rsp), %rsi
leaq 0x310(%rsp), %rdi
movl $0x8, %edx
callq 0x5260
leaq 0x388(%rsp), %rdi
callq 0x50b0
testb %al, %al
je 0xbe0f
leaq 0x28(%rsp), %r14
leaq 0x108(%rsp), %r12
movq %r12, %rdi
callq 0xb754
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xd146
xorl %ebx, %ebx
movq %rbx, -0x8(%r14)
movq -0x10(%r14), %rax
movb %bl, (%rax)
leaq 0xf8(%rsp), %r14
leaq 0x108(%rsp), %r12
movq %r12, %rdi
callq 0xb754
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xd146
movq %rbx, -0x8(%r14)
movq -0x10(%r14), %rax
movb %bl, (%rax)
leaq 0x108(%rsp), %rdi
callq 0xb754
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21d32(%rip), %rsi     # 0x2d732
leaq 0x21d31(%rip), %rdx     # 0x2d738
leaq 0x38(%rsp), %rdi
callq 0xd0b0
leaq 0x108(%rsp), %rdi
callq 0xd146
leaq 0x108(%rsp), %rdi
callq 0xb754
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21cfb(%rip), %rsi     # 0x2d739
leaq 0x21cf8(%rip), %rdx     # 0x2d73d
leaq 0x98(%rsp), %rdi
callq 0xd0b0
leaq 0x108(%rsp), %rdi
callq 0xd146
leaq 0x108(%rsp), %rdi
callq 0xb754
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21cbf(%rip), %rsi     # 0x2d73e
leaq 0x21cbe(%rip), %rdx     # 0x2d744
leaq 0x78(%rsp), %rdi
callq 0xd0b0
leaq 0x108(%rsp), %rdi
callq 0xd146
testl %ebp, %ebp
jle 0xbb48
movl %ebp, %ebx
shlq $0x4, %rbx
xorl %r15d, %r15d
leaq 0x18(%rsp), %r13
leaq 0x8(%rsp), %rbp
leaq 0x310(%rsp), %rdi
movq %r13, %rsi
callq 0x5500
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5200
movq 0x20(%rsp), %r14
movq 0x40(%rsp), %r12
cmpq %r14, %r12
movq %r14, %rdx
cmovbq %r12, %rdx
testq %rdx, %rdx
je 0xbb0d
movq 0x38(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
cmpq %r12, %r14
jne 0xbe05
testl %eax, %eax
je 0xbb16
jmp 0xbe05
cmpq %r12, %r14
jne 0xbe05
movq 0x8(%rsp), %rax
movq 0xe0(%rsp), %r14
movq %rax, (%r14,%r15)
callq 0x50e0
cltq
addq 0xd8(%rsp), %rax
movq %rax, 0x8(%r14,%r15)
addq $0x10, %r15
cmpq %r15, %rbx
jne 0xbab8
leaq 0x310(%rsp), %rdi
callq 0x5090
leaq 0x108(%rsp), %rdi
callq 0x5460
movq 0xb8(%rsp), %rsi
leaq 0x108(%rsp), %rdi
movl $0x8, %edx
callq 0x5260
leaq 0x180(%rsp), %rdi
callq 0x50b0
testb %al, %al
je 0xbe14
movl 0x550(%rsp), %eax
testl %eax, %eax
jle 0xbce7
movl %eax, %ebp
shlq $0x2, %rbp
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
movq 0x10(%rsp), %rbx
leaq 0x108(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5500
movq %rax, %rdi
movq %r12, %rsi
callq 0x5200
movq 0x20(%rsp), %r14
movq 0x40(%rsp), %r15
cmpq %r14, %r15
movq %r14, %rdx
cmovbq %r15, %rdx
testq %rdx, %rdx
je 0xbc16
movq 0x38(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
cmpq %r15, %r14
jne 0xbc1b
testl %eax, %eax
jne 0xbc1b
movq 0x558(%rsp), %rax
movl $0x0, (%rax,%r13)
jmp 0xbcc3
cmpq %r15, %r14
je 0xbc01
movq 0xa0(%rsp), %r15
cmpq %r14, %r15
movq %r14, %rdx
cmovbq %r15, %rdx
testq %rdx, %rdx
je 0xbc6d
movq 0x98(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
cmpq %r15, %r14
jne 0xbc72
testl %eax, %eax
jne 0xbc72
movq 0x558(%rsp), %rax
movl $0x1, (%rax,%r13)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,4)
jmp 0xbcd6
cmpq %r15, %r14
je 0xbc4d
movq 0x80(%rsp), %r15
cmpq %r14, %r15
movq %r14, %rdx
cmovbq %r15, %rdx
testq %rdx, %rdx
je 0xbcaa
movq 0x78(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
cmpq %r15, %r14
jne 0xbe0a
testl %eax, %eax
je 0xbcb3
jmp 0xbe0a
cmpq %r15, %r14
jne 0xbe0a
movq 0x558(%rsp), %rax
movl $0x2, (%rax,%r13)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,4)
movq %rbx, 0x8(%rcx,%r13,4)
addq $0x4, %r13
addq $0x10, %rbx
cmpq %r13, %rbp
jne 0xbbb3
leaq 0x108(%rsp), %rdi
callq 0x5090
leaq 0x108(%rsp), %rdi
callq 0x50d0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0xbd23
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xbd48
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xbd64
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xbd89
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0xbda5
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5410
leaq 0x310(%rsp), %rdi
callq 0x50d0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xbdd7
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xbdf3
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5410
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5865
callq 0x58af
callq 0x5840
callq 0x588a
movl %r15d, %edi
callq 0x58d4
jmp 0xbe87
jmp 0xbe87
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xd146
jmp 0xbeac
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xd146
jmp 0xbed1
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xd146
jmp 0xbeed
movq %rax, %rbx
jmp 0xbf2e
jmp 0xbe6d
jmp 0xbe75
movq %rax, %rbx
jmp 0xbf3b
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x50d0
jmp 0xbe8a
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0xbeac
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xbed1
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xbeed
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xbf12
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0xbf2e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5410
leaq 0x310(%rsp), %rdi
callq 0x50d0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xbf60
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xbf7c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5410
movq %rbx, %rdi
callq 0x5740