// File: /workspace/github_cpp_makefile_star2_O1/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 0xa998
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xc54e
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 0xa998
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xc54e
movq %rbx, -0x8(%r14)
movq -0x10(%r14), %rax
movb %bl, (%rax)
cmpl $0x3, %r15d
ja 0xb069
movl %r15d, %eax
leaq 0x21543(%rip), %rcx     # 0x2c004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x218af(%rip), %rcx     # 0x2c389
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x218c5(%rip), %rcx     # 0x2c3b3
jmp 0xab60
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x21931(%rip), %rcx     # 0x2c431
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x21947(%rip), %rcx     # 0x2c45b
jmp 0xab60
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x2195f(%rip), %rcx     # 0x2c485
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x21975(%rip), %rcx     # 0x2c4af
jmp 0xab60
leaq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x21891(%rip), %rcx     # 0x2c3dd
movl $0x29, %r8d
xorl %esi, %esi
callq 0x5630
leaq 0x218a7(%rip), %rcx     # 0x2c407
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 0xb05f
leaq 0x28(%rsp), %r14
leaq 0x108(%rsp), %r12
movq %r12, %rdi
callq 0xa998
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xc54e
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 0xa998
movq %r14, -0x10(%r14)
movq %r12, %rdi
callq 0xc54e
movq %rbx, -0x8(%r14)
movq -0x10(%r14), %rax
movb %bl, (%rax)
leaq 0x108(%rsp), %rdi
callq 0xa998
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x218c8(%rip), %rsi     # 0x2c50c
leaq 0x218c7(%rip), %rdx     # 0x2c512
leaq 0x38(%rsp), %rdi
callq 0xc4be
leaq 0x108(%rsp), %rdi
callq 0xc54e
leaq 0x108(%rsp), %rdi
callq 0xa998
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21891(%rip), %rsi     # 0x2c513
leaq 0x2188e(%rip), %rdx     # 0x2c517
leaq 0x98(%rsp), %rdi
callq 0xc4be
leaq 0x108(%rsp), %rdi
callq 0xc54e
leaq 0x108(%rsp), %rdi
callq 0xa998
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21855(%rip), %rsi     # 0x2c518
leaq 0x21854(%rip), %rdx     # 0x2c51e
leaq 0x78(%rsp), %rdi
callq 0xc4be
leaq 0x108(%rsp), %rdi
callq 0xc54e
testl %ebp, %ebp
jle 0xad8b
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 0xad46
movq 0x38(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
testl %eax, %eax
sete %al
jmp 0xad48
movb $0x1, %al
testb %al, %al
je 0xb055
cmpq %r12, %r14
jne 0xb055
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 0xacfc
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 0xb064
movl 0x550(%rsp), %eax
testl %eax, %eax
jle 0xaf37
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 0xae42
movq 0x38(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
testl %eax, %eax
sete %al
jmp 0xae44
movb $0x1, %al
cmpq %r15, %r14
setne %cl
xorb $0x1, %al
orb %cl, %al
jne 0xae65
movq 0x558(%rsp), %rax
movl $0x0, (%rax,%r13)
jmp 0xaf13
movq 0xa0(%rsp), %r15
cmpq %r14, %r15
movq %r14, %rdx
cmovbq %r15, %rdx
testq %rdx, %rdx
je 0xae95
movq 0x98(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
testl %eax, %eax
sete %al
jmp 0xae97
movb $0x1, %al
cmpq %r15, %r14
setne %cl
xorb $0x1, %al
orb %cl, %al
jne 0xaec3
movq 0x558(%rsp), %rax
movl $0x1, (%rax,%r13)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,4)
jmp 0xaf26
movq 0x80(%rsp), %r15
cmpq %r14, %r15
movq %r14, %rdx
cmovbq %r15, %rdx
testq %rdx, %rdx
je 0xaef0
movq 0x78(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x5430
testl %eax, %eax
sete %al
jmp 0xaef2
movb $0x1, %al
testb %al, %al
je 0xb05a
cmpq %r15, %r14
jne 0xb05a
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 0xadf6
leaq 0x108(%rsp), %rdi
callq 0x5090
leaq 0x108(%rsp), %rdi
callq 0x50d0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0xaf73
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xaf98
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xafb4
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xafd9
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0xaff5
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 0xb027
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xb043
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 0xb0d7
jmp 0xb0d7
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xc54e
jmp 0xb0fc
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xc54e
jmp 0xb121
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xc54e
jmp 0xb13d
movq %rax, %rbx
jmp 0xb17e
jmp 0xb0bd
jmp 0xb0c5
movq %rax, %rbx
jmp 0xb18b
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x50d0
jmp 0xb0da
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0xb0fc
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xb121
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xb13d
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xb162
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0xb17e
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 0xb1b0
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5410
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xb1cc
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5410
movq %rbx, %rdi
callq 0x5740