// File: /workspace/github_cpp_makefile_star2_O1/BU-DiSC[P]BF-Shared-Hashing/db.cpp
// Function: db::ReadSettings()
int db::ReadSettings()
{
	ifstream infile;
	infile.open( settings_file );
	 
	if( infile.fail() ){
		cout << "Error opening " << settings_file << endl;
	}

	bool bf_rebuild = false;

	int num = 0;
	while( infile.peek() != EOF ){
		//int line = 0;
		string line;
		getline( infile, line);
		int value = stoi(line);
		//cout << num << " " << value << endl;
		if ( num==0 ) {
			if (value != P)
				return -1;
		} else if ( num==1 ){
			if (value != B)
				return -1;
		} else if ( num==2 ){
				if (value != E)
					return -1;
		} else if ( num==3 ){
			if (value != K)
				return -1;
		} else if ( num==4 ){
			if (value != num_filter_units){
				bf_rebuild = true;
			}
		
		} else if ( num==5 ){
			if ( value > 0 ){
				num_levels = value;
				num_sstPerLevel.resize( num_levels, 0);
				fence_pointers.resize( num_levels );
			}
			else {
				return -1;
			}
		} else if ( num==6 ){
			if( value == 0){
				return -1;
			}
			last_sst_keys = value;
		} else if ( num>=7 && num<7+num_levels ){
			num_sstPerLevel[num-7] = value;
			num_sst += value;
		}
		num++;
	}
	infile.close();

	if ( num < 7+num_levels )
		return -1;

	if (bf_rebuild==true){
		return 1;
	}

	//cout << fence_file << endl;
	infile.open( fence_file );
	if( infile.fail() ){
		cout << "Error opening " << fence_file << endl;
	}
	for ( int i=0 ; i<num_levels ; i++ ){
		vector <string> fence_pointer_one_level ( num_sstPerLevel[i]+1 );
		for ( int j=0 ; j<=num_sstPerLevel[i] ; j++ ){
			string first, last;
			getline( infile, first );
			fence_pointer_one_level[j] = first;
		}
		fence_pointers[i] = fence_pointer_one_level;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdi, %rbx
leaq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x5460
movq %rbx, 0x8(%rsp)
leaq 0x80(%rbx), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x5380
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xa0(%rsp,%rax)
je 0x7e50
movq 0x311da(%rip), %rdi     # 0x38fd0
leaq 0x2123d(%rip), %rsi     # 0x2903a
movl $0xe, %edx
callq 0x5470
movq 0x8(%rsp), %rax
movq 0x80(%rax), %rsi
movq 0x88(%rax), %rdx
movq 0x311af(%rip), %rdi     # 0x38fd0
callq 0x5470
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x53f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x52a0
movq 0x8(%rsp), %rax
leaq 0xe8(%rax), %rcx
movq %rcx, 0x60(%rsp)
addq $0x140, %rax            # imm = 0x140
movq %rax, 0x58(%rsp)
movl $0x0, 0x14(%rsp)
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x51a0
cmpl $-0x1, %eax
je 0x807d
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53f0
movsbl %al, %edx
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x56f0
movq 0x18(%rsp), %r12
callq 0x5060
movq %rax, %r15
movl (%rax), %r13d
movl $0x0, (%rax)
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
movl $0xa, %edx
callq 0x5560
cmpq %r12, 0x38(%rsp)
je 0x82b0
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x82bc
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x82bc
testl %ecx, %ecx
jne 0x7f1a
movl %r13d, (%r15)
movl %ebp, %ecx
cmpl $0x6, %ebp
ja 0x7fac
leaq 0x212a8(%rip), %rdx     # 0x291d4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %ebx, %ebx
movl $0x0, %r15d
movq 0x8(%rsp), %rcx
cmpl %eax, 0xc4(%rcx)
je 0x803b
jmp 0x8053
movq 0x8(%rsp), %rcx
cmpl %eax, 0x110(%rcx)
movl 0x14(%rsp), %eax
movzbl %al, %eax
movl $0x1, %ecx
cmovnel %ecx, %eax
movl %eax, 0x14(%rsp)
jmp 0x803b
movq 0x8(%rsp), %rcx
cmpl %eax, 0xcc(%rcx)
je 0x803b
movl $0x2, %ebx
jmp 0x8050
movq 0x8(%rsp), %rcx
cmpl %eax, 0xd0(%rcx)
je 0x803b
movl $0x3, %ebx
jmp 0x8050
jle 0x803b
movq 0x8(%rsp), %rsi
movl 0xdc(%rsi), %edx
addl $0x7, %edx
cmpl %edx, %ebp
jge 0x803b
movq 0xe8(%rsi), %rdx
movl %eax, -0x1c(%rdx,%rcx,4)
addl %eax, 0xe0(%rsi)
jmp 0x803b
movq 0x8(%rsp), %rcx
cmpl %eax, 0xc8(%rcx)
je 0x803b
movl $0x1, %ebx
jmp 0x8050
testl %eax, %eax
jle 0x8044
movq 0x8(%rsp), %rbx
movl %eax, 0xdc(%rbx)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x0, 0x38(%rsp)
movq 0x60(%rsp), %rdi
movq %rax, %rsi
leaq 0x38(%rsp), %rdx
callq 0xd368
movslq 0xdc(%rbx), %rsi
movq 0x58(%rsp), %rdi
callq 0xd39c
jmp 0x803b
testl %eax, %eax
je 0x804b
movq 0x8(%rsp), %rcx
movl %eax, 0x100(%rcx)
incl %ebp
movb $0x1, %r15b
movl %ebp, %ebx
jmp 0x8053
movl $0x5, %ebx
jmp 0x8050
movl $0x6, %ebx
xorl %r15d, %r15d
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x8067
callq 0x53d0
movl %ebx, %ebp
testb %r15b, %r15b
jne 0x7e76
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x828e
leaq 0x80(%rsp), %rdi
callq 0x50e0
movq 0x8(%rsp), %rax
movl 0xdc(%rax), %eax
addl $0x7, %eax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl %eax, %ebp
jl 0x828e
movl $0x1, %r14d
testb $0x1, 0x14(%rsp)
jne 0x828e
movq 0x8(%rsp), %rbx
leaq 0xa0(%rbx), %rsi
leaq 0x80(%rsp), %rdi
movl $0x8, %edx
callq 0x5380
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xa0(%rsp,%rax)
je 0x8147
movq 0x30ede(%rip), %rdi     # 0x38fd0
leaq 0x20f41(%rip), %rsi     # 0x2903a
movl $0xe, %edx
callq 0x5470
movq 0xa0(%rbx), %rsi
movq 0xa8(%rbx), %rdx
movq 0x30eb8(%rip), %rdi     # 0x38fd0
callq 0x5470
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x53f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x52a0
cmpl $0x0, 0xdc(%rbx)
jle 0x828b
leaq 0x48(%rsp), %rbp
xorl %r15d, %r15d
leaq 0x68(%rsp), %r14
leaq 0x18(%rsp), %r12
xorl %r13d, %r13d
movq 0xe8(%rbx), %rax
movslq (%rax,%r13,4), %rsi
incq %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0xd418
movq 0xe8(%rbx), %rax
cmpl $0x0, (%rax,%r13,4)
js 0x8248
movq $-0x1, %rbx
xorl %r14d, %r14d
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movb %r15b, 0x28(%rsp)
movq %rbp, 0x38(%rsp)
movq %r15, 0x40(%rsp)
movb %r15b, 0x48(%rsp)
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x80(%rsp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x53f0
movsbl %al, %edx
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x56f0
movq 0x68(%rsp), %rdi
addq %r14, %rdi
movq %r12, %rsi
callq 0x5230
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0x8214
callq 0x53d0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x8228
callq 0x53d0
movq 0x8(%rsp), %rax
movq 0xe8(%rax), %rax
movslq (%rax,%r13,4), %rax
incq %rbx
addq $0x20, %r14
cmpq %rax, %rbx
jl 0x819e
leaq (,%r13,2), %rdi
addq %r13, %rdi
shlq $0x3, %rdi
movq 0x8(%rsp), %rbx
addq 0x140(%rbx), %rdi
leaq 0x68(%rsp), %r14
movq %r14, %rsi
callq 0xd4a2
movq %r14, %rdi
callq 0x6982
incq %r13
movslq 0xdc(%rbx), %rax
cmpq %rax, %r13
jl 0x8169
xorl %r14d, %r14d
leaq 0x80(%rsp), %rdi
callq 0x5100
movl %r14d, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21209(%rip), %rdi     # 0x294c0
callq 0x5260
leaq 0x211fd(%rip), %rdi     # 0x294c0
callq 0x55a0
jmp 0x82d7
jmp 0x82ea
jmp 0x82ea
movq %rax, %rbx
jmp 0x8329
jmp 0x82d7
jmp 0x82d7
movq %rax, %rbx
jmp 0x8333
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x82ed
movl %r13d, (%r15)
jmp 0x82ed
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x8333
callq 0x53d0
jmp 0x8333
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0x8315
callq 0x53d0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x8329
callq 0x53d0
leaq 0x68(%rsp), %rdi
callq 0x6982
leaq 0x80(%rsp), %rdi
callq 0x5100
movq %rbx, %rdi
callq 0x56b0