// File: /workspace/github_cpp_makefile_star2_O1/BU-DiSC[P]BF-Shared-Hashing/db.cpp
// Function: db::flushfile(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::flushfile( string filename, vector<string>* table){
	ofstream outfile(filename, ios::out);
	char buffer[DB_PAGE_SIZE];

	int size = table->size();
	memcpy(buffer, &size, sizeof(unsigned int));
	outfile.write(buffer, sizeof(unsigned int));
	memset(buffer, 0, sizeof(unsigned int));

	int key_size = (table->at(0)).size();
	memcpy(buffer, &key_size, sizeof(unsigned int));
	outfile.write(buffer, sizeof(unsigned int));
	memset(buffer, 0, sizeof(unsigned int));

	memset(buffer, 0, DB_PAGE_SIZE-2*sizeof(unsigned int));
	outfile.write(buffer, DB_PAGE_SIZE-2*sizeof(unsigned int));

	for(int i = 0 ;i < size; i++){
		char* str = (char*) malloc(key_size);
		strcpy (str, table->at(i).c_str());
		memcpy(buffer, str, key_size);
		outfile.write(buffer, key_size);
		memset(buffer, 0, key_size);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1218, %rsp           # imm = 0x1218
movq %rdx, %rbx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl $0x10, %edx
callq 0x5730
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x5, %rax
leaq 0x210(%rsp), %rsi
movq %rax, 0x8(%rsp)
movl %eax, (%rsi)
movl $0x4, %edx
movq %r14, %rdi
callq 0x5510
movl $0x0, 0x210(%rsp)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0xaaf3
movq 0x8(%rax), %r15
leaq 0x210(%rsp), %rsi
movl %r15d, (%rsi)
leaq 0x10(%rsp), %rdi
movl $0x4, %edx
callq 0x5510
leaq 0x210(%rsp), %r14
movl $0xff8, %edx            # imm = 0xFF8
movq %r14, %rdi
xorl %esi, %esi
callq 0x5240
leaq 0x10(%rsp), %rdi
movl $0xff8, %edx            # imm = 0xFF8
movq %r14, %rsi
callq 0x5510
cmpl $0x0, 0x8(%rsp)
jle 0xaa9e
movslq %r15d, %r14
movq 0x8(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
leaq 0x210(%rsp), %r12
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x5530
movq %rax, %rbp
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0xaae2
movq (%rax,%r13), %rsi
movq %rbp, %rdi
callq 0x53c0
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x5330
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x5510
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x5240
incq %r15
addq $0x20, %r13
cmpq %r15, 0x8(%rsp)
jne 0xaa37
movq 0x2e50b(%rip), %rax     # 0x38fb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x18(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x10(%rsp,%rcx)
callq 0x5350
leaq 0x108(%rsp), %rdi
callq 0x5160
addq $0x1218, %rsp           # imm = 0x1218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e58a(%rip), %rdi     # 0x29073
movq %r15, %rsi
xorl %eax, %eax
callq 0x55d0
leaq 0x1e579(%rip), %rdi     # 0x29073
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x55d0
jmp 0xab0b
jmp 0xab0b
jmp 0xab0b
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x55c0
movq %rbx, %rdi
callq 0x56b0