// File: /workspace/github_cpp_makefile_star2_O2/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, %r15d
movq %rcx, 0x20(%rsp)
movl %esi, %ebx
leaq 0x38(%rsp), %r12
leaq 0x310(%rsp), %r14
movq %r14, %rdi
callq 0x9d4a
movq %r12, -0x10(%r12)
movq %r14, %rdi
callq 0xacf0
andq $0x0, -0x8(%r12)
movq -0x10(%r12), %rax
xorl %ebp, %ebp
movb %bpl, (%rax)
leaq 0x98(%rsp), %r12
leaq 0x310(%rsp), %r14
movq %r14, %rdi
callq 0x9d4a
movq %r12, -0x10(%r12)
movq %r14, %rdi
callq 0xacf0
andq $0x0, -0x8(%r12)
movq -0x10(%r12), %rax
movb %bpl, (%rax)
cmpl $0x3, %ebx
ja 0xa2aa
movl %ebx, %eax
leaq 0x20395(%rip), %rcx     # 0x2a1f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2072c(%rip), %rsi     # 0x2a597
leaq 0x28(%rsp), %rdi
callq 0x57e0
leaq 0x20745(%rip), %rsi     # 0x2a5c1
jmp 0x9eca
leaq 0x207ba(%rip), %rsi     # 0x2a63f
leaq 0x28(%rsp), %rdi
callq 0x57e0
leaq 0x207d3(%rip), %rsi     # 0x2a669
jmp 0x9eca
leaq 0x207f4(%rip), %rsi     # 0x2a693
leaq 0x28(%rsp), %rdi
callq 0x57e0
leaq 0x2080d(%rip), %rsi     # 0x2a6bd
jmp 0x9eca
leaq 0x20732(%rip), %rsi     # 0x2a5eb
leaq 0x28(%rsp), %rdi
callq 0x57e0
leaq 0x2074b(%rip), %rsi     # 0x2a615
leaq 0x88(%rsp), %rdi
callq 0x57e0
pushq $0x8
popq %rdi
callq 0x5530
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0x54c0
leaq 0x310(%rsp), %rdi
callq 0x5460
movq 0x28(%rsp), %rsi
leaq 0x310(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x5280
leaq 0x388(%rsp), %rdi
callq 0x50c0
testb %al, %al
je 0xa282
leaq 0x78(%rsp), %r14
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0x9d4a
movq %r14, -0x10(%r14)
movq %rbx, %rdi
callq 0xacf0
andq $0x0, -0x8(%r14)
movq -0x10(%r14), %rax
xorl %ebp, %ebp
movb %bpl, (%rax)
leaq 0xf8(%rsp), %r14
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0x9d4a
movq %r14, -0x10(%r14)
movq %rbx, %rdi
callq 0xacf0
andq $0x0, -0x8(%r14)
movq -0x10(%r14), %rax
movb %bpl, (%rax)
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0x9d4a
leaq 0x20781(%rip), %rsi     # 0x2a71a
leaq 0x48(%rsp), %rdi
movq %rbx, %rdx
callq 0xac1e
leaq 0x108(%rsp), %rdi
callq 0xacf0
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0x9d4a
leaq 0x20757(%rip), %rsi     # 0x2a721
leaq 0xc8(%rsp), %rdi
movq %rbx, %rdx
callq 0xac1e
leaq 0x108(%rsp), %rdi
callq 0xacf0
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0x9d4a
leaq 0x20728(%rip), %rsi     # 0x2a726
leaq 0xa8(%rsp), %rdi
movq %rbx, %rdx
callq 0xac1e
leaq 0x108(%rsp), %rdi
callq 0xacf0
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
shlq $0x4, %r15
leaq 0x68(%rsp), %rbp
leaq 0x8(%rsp), %r14
leaq 0x48(%rsp), %rbx
movq 0x20(%rsp), %r13
cmpq %r12, %r15
je 0xa091
leaq 0x310(%rsp), %rdi
movq %rbp, %rsi
callq 0x5500
movq %rax, %rdi
movq %r14, %rsi
callq 0x5220
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x5050
testl %eax, %eax
jne 0xa249
movq 0x8(%rsp), %rax
movq %rax, (%r13,%r12)
callq 0x50f0
cltq
addq 0x18(%rsp), %rax
movq %rax, 0x8(%r13,%r12)
addq $0x10, %r12
jmp 0xa03d
leaq 0x310(%rsp), %rdi
callq 0x50a0
leaq 0x108(%rsp), %rdi
callq 0x5460
movq 0x88(%rsp), %rsi
leaq 0x108(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x5280
leaq 0x180(%rsp), %rdi
callq 0x50c0
testb %al, %al
je 0xa295
xorl %ebp, %ebp
movl 0x550(%rsp), %eax
movq %rax, %r12
testl %r12d, %r12d
cmovlel %ebp, %r12d
shlq $0x2, %r12
leaq 0x68(%rsp), %r15
leaq 0x8(%rsp), %rbx
leaq 0x48(%rsp), %r13
movq 0x10(%rsp), %r14
cmpq %rbp, %r12
je 0xa1be
leaq 0x108(%rsp), %rdi
movq %r15, %rsi
callq 0x5500
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5220
movq %r15, %rdi
movq %r13, %rsi
callq 0x5050
testl %eax, %eax
je 0xa173
movq %r15, %rdi
leaq 0xc8(%rsp), %rsi
callq 0x5050
testl %eax, %eax
je 0xa194
movq %r15, %rdi
leaq 0xa8(%rsp), %rsi
callq 0x5050
testl %eax, %eax
jne 0xa25e
movq 0x558(%rsp), %rax
movl $0x2, (%rax,%rbp)
jmp 0xa17f
movq 0x558(%rsp), %rax
andl $0x0, (%rax,%rbp)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbp,4)
movq %r14, 0x8(%rcx,%rbp,4)
jmp 0xa1b1
movq 0x558(%rsp), %rax
movl $0x1, (%rax,%rbp)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbp,4)
addq $0x4, %rbp
addq $0x10, %r14
jmp 0xa103
leaq 0x108(%rsp), %rdi
callq 0x50a0
leaq 0x108(%rsp), %rdi
callq 0x50e0
leaq 0xa8(%rsp), %rdi
callq 0x51b0
leaq 0xc8(%rsp), %rdi
callq 0x51b0
leaq 0x48(%rsp), %rdi
callq 0x51b0
leaq 0xe8(%rsp), %rdi
callq 0x51b0
leaq 0x68(%rsp), %rdi
callq 0x51b0
leaq 0x310(%rsp), %rdi
callq 0x50e0
leaq 0x88(%rsp), %rdi
callq 0x51b0
leaq 0x28(%rsp), %rdi
callq 0x51b0
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2fd70(%rip), %rax     # 0x39fc0
movq (%rax), %rcx
leaq 0x204d3(%rip), %rdi     # 0x2a72d
pushq $0x19
jmp 0xa271
movq 0x2fd5b(%rip), %rax     # 0x39fc0
movq (%rax), %rcx
leaq 0x204f1(%rip), %rdi     # 0x2a760
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x57f0
pushq $0x1
popq %rdi
callq 0x54d0
movq 0x2fd37(%rip), %rax     # 0x39fc0
movq (%rax), %rcx
leaq 0x2046d(%rip), %rdi     # 0x2a700
jmp 0xa25a
movq 0x2fd24(%rip), %rax     # 0x39fc0
movq (%rax), %rcx
leaq 0x204a1(%rip), %rdi     # 0x2a747
pushq $0x18
jmp 0xa271
movq 0x2fd0f(%rip), %rax     # 0x39fc0
movq (%rax), %rdi
leaq 0x2042c(%rip), %rsi     # 0x2a6e7
movl %ebx, %edx
xorl %eax, %eax
callq 0x5590
jmp 0xa27a
jmp 0xa30e
jmp 0xa30e
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xacf0
jmp 0xa330
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xacf0
jmp 0xa33d
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xacf0
jmp 0xa347
movq %rax, %rbx
jmp 0xa35e
jmp 0xa309
jmp 0xa313
movq %rax, %rbx
jmp 0xa36b
movq %rax, %rbx
jmp 0xa323
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x50e0
leaq 0xa8(%rsp), %rdi
callq 0x51b0
leaq 0xc8(%rsp), %rdi
callq 0x51b0
leaq 0x48(%rsp), %rdi
callq 0x51b0
leaq 0xe8(%rsp), %rdi
callq 0x51b0
leaq 0x68(%rsp), %rdi
callq 0x51b0
leaq 0x310(%rsp), %rdi
callq 0x50e0
leaq 0x88(%rsp), %rdi
callq 0x51b0
leaq 0x28(%rsp), %rdi
callq 0x51b0
movq %rbx, %rdi
callq 0x5740