// File: BU-DiSC[P]BF-Shared-Hashing/db.cpp
// Function: db::split_keys_sst(int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::vector<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::allocator<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&)
void db::split_keys_sst(int sst_capacity, vector<string> keys_one_level, vector<vector<string> > & sst, vector<string> & fence_pointer )
{
	sst.clear();
	fence_pointer.clear();
	if(keys_one_level.size() == 0) return;
	sort(keys_one_level.begin(), keys_one_level.end());
	int start_index = 0;
	int num_keys_one_level = keys_one_level.size();
	while(true){
		int end_index = start_index + sst_capacity;
		fence_pointer.push_back(keys_one_level[start_index]);
		if(end_index >= num_keys_one_level){
			sst.push_back(vector<string> (keys_one_level.cbegin() + start_index, keys_one_level.cend()));
			break;
		}else{
			sst.push_back(vector<string> (keys_one_level.cbegin() + start_index, keys_one_level.cbegin() + end_index));
		}
		start_index = end_index;
	}	
	fence_pointer.push_back(keys_one_level.back());	
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdx, 0x30(%rsp)
movq %rdi, 0x100(%rsp)
movl %esi, 0xfc(%rsp)
movq %rdx, 0xf0(%rsp)
movq %rcx, 0xe8(%rsp)
movq %r8, 0xe0(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x12530
movq 0xe0(%rsp), %rdi
callq 0x12bb0
movq 0x30(%rsp), %rdi
callq 0x8020
cmpq $0x0, %rax
jne 0xef92
jmp 0xf24f
movq 0x30(%rsp), %rdi
callq 0xa460
movq 0x30(%rsp), %rdi
movq %rax, 0xd8(%rsp)
callq 0xa2d0
movq %rax, 0xd0(%rsp)
movq 0xd8(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0x12bd0
movq 0x30(%rsp), %rdi
movl $0x0, 0xcc(%rsp)
callq 0x8020
movl %eax, 0xc8(%rsp)
movq 0x30(%rsp), %rdi
movl 0xcc(%rsp), %eax
addl 0xfc(%rsp), %eax
movl %eax, 0xc4(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x28(%rsp)
movslq 0xcc(%rsp), %rsi
callq 0x8040
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x8140
movl 0xc4(%rsp), %eax
cmpl 0xc8(%rsp), %eax
jl 0xf136
movq 0x30(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq %rax, 0x18(%rsp)
callq 0x12c10
movq %rax, 0x98(%rsp)
movslq 0xcc(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x12c40
movq 0x30(%rsp), %rdi
movq %rax, 0xa0(%rsp)
callq 0x12c80
movq %rax, 0x90(%rsp)
leaq 0x8f(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x81f0
movq 0x20(%rsp), %rcx
movq 0xa0(%rsp), %rsi
movq 0x90(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
callq 0x12cb0
jmp 0xf0c0
movq 0x18(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x12410
jmp 0xf0d4
leaq 0xa8(%rsp), %rdi
callq 0x7e60
leaq 0x8f(%rsp), %rdi
callq 0x8f60
jmp 0xf22d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0xf124
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x7e60
leaq 0x8f(%rsp), %rdi
callq 0x8f60
jmp 0xf257
movq 0x30(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq %rax, 0x8(%rsp)
callq 0x12c10
movq %rax, 0x50(%rsp)
movslq 0xcc(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x12c40
movq 0x30(%rsp), %rdi
movq %rax, 0x58(%rsp)
callq 0x12c10
movq %rax, 0x40(%rsp)
movslq 0xc4(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x12c40
movq %rax, 0x48(%rsp)
leaq 0x3f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x81f0
movq 0x10(%rsp), %rcx
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x12cb0
jmp 0xf1b9
movq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x12410
jmp 0xf1ca
leaq 0x60(%rsp), %rdi
callq 0x7e60
leaq 0x3f(%rsp), %rdi
callq 0x8f60
jmp 0xf21a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0xf20e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x7e60
leaq 0x3f(%rsp), %rdi
callq 0x8f60
jmp 0xf257
movl 0xc4(%rsp), %eax
movl %eax, 0xcc(%rsp)
jmp 0xefe7
movq 0x30(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq %rax, (%rsp)
callq 0x12d40
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x8140
addq $0x108, %rsp            # imm = 0x108
retq
movq 0x80(%rsp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)