// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
leaq 0x80(%rsp), %r12
movq %r12, %rdi
callq 0x5460
leaq 0x80(%r13), %rsi
movq %r12, %rdi
movl $0x8, %edx
callq 0x5380
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xa0(%rsp,%rax)
je 0x7e08
movq 0x3121d(%rip), %rdi     # 0x38fd0
leaq 0x21280(%rip), %rsi     # 0x2903a
movl $0xe, %edx
callq 0x5470
movq 0x80(%r13), %rsi
movq 0x88(%r13), %rdx
movq 0x311f7(%rip), %rdi     # 0x38fd0
callq 0x5470
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x52a0
leaq 0xe8(%r13), %rax
movq %rax, 0x10(%rsp)
leaq 0x140(%r13), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0xc(%rsp)
xorl %ebp, %ebp
movq %r13, 0x40(%rsp)
movq %r12, %rdi
callq 0x51a0
cmpl $-0x1, %eax
je 0x800d
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 %r12, %rdi
movl $0xa, %esi
callq 0x53f0
movsbl %al, %edx
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
callq 0x56f0
movq 0x18(%rsp), %r13
callq 0x5060
movq %rax, %r15
movl (%rax), %ebx
movl $0x0, (%rax)
movq %r13, %rdi
leaq 0x48(%rsp), %rsi
movl $0xa, %edx
callq 0x5560
cmpq %r13, 0x48(%rsp)
je 0x8231
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x823d
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x823d
testl %ecx, %ecx
movq 0x40(%rsp), %r13
jne 0x7ed7
movl %ebx, (%r15)
movl %ebp, %ecx
cmpl $0x6, %ebp
ja 0x7f4f
leaq 0x212ef(%rip), %rdx     # 0x291d4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %ebx, %ebx
movl $0x0, %r14d
cmpl %eax, 0xc4(%r13)
je 0x7fcb
jmp 0x7fe3
cmpl %eax, 0x110(%r13)
setne %al
movl 0xc(%rsp), %ecx
orb %al, %cl
movl %ecx, 0xc(%rsp)
jmp 0x7fcb
cmpl %eax, 0xcc(%r13)
je 0x7fcb
movl $0x2, %ebx
jmp 0x7fe0
cmpl %eax, 0xd0(%r13)
je 0x7fcb
movl $0x3, %ebx
jmp 0x7fe0
jle 0x7fcb
movl 0xdc(%r13), %edx
addl $0x7, %edx
cmpl %edx, %ebp
jge 0x7fcb
movq 0xe8(%r13), %rdx
movl %eax, -0x1c(%rdx,%rcx,4)
addl %eax, 0xe0(%r13)
jmp 0x7fcb
cmpl %eax, 0xc8(%r13)
je 0x7fcb
movl $0x1, %ebx
jmp 0x7fe0
testl %eax, %eax
jle 0x7fd4
movl %eax, 0xdc(%r13)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x0, 0x48(%rsp)
movq 0x10(%rsp), %rdi
movq %rax, %rsi
leaq 0x48(%rsp), %rdx
callq 0xd1f0
movslq 0xdc(%r13), %rsi
movq 0x38(%rsp), %rdi
callq 0xd224
jmp 0x7fcb
testl %eax, %eax
je 0x7fdb
movl %eax, 0x100(%r13)
incl %ebp
movb $0x1, %r14b
movl %ebp, %ebx
jmp 0x7fe3
movl $0x5, %ebx
jmp 0x7fe0
movl $0x6, %ebx
xorl %r14d, %r14d
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x7ff7
callq 0x53d0
movl %ebx, %ebp
testb %r14b, %r14b
jne 0x7e2f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x820f
leaq 0x80(%rsp), %rdi
callq 0x50e0
movq 0x10(%rsp), %r14
movl 0xdc(%r13), %eax
addl $0x7, %eax
xorl %r15d, %r15d
cmpl %eax, %ebp
setl %al
movl 0xc(%rsp), %ecx
orb %al, %cl
testb $0x1, %cl
je 0x804b
movb %al, %r15b
negl %r15d
orl $0x1, %r15d
jmp 0x820f
leaq 0xa0(%r13), %rsi
leaq 0x80(%rsp), %rdi
movl $0x8, %edx
callq 0x5380
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xa0(%rsp,%rax)
je 0x80d6
movq 0x30f4f(%rip), %rdi     # 0x38fd0
leaq 0x20fb2(%rip), %rsi     # 0x2903a
movl $0xe, %edx
callq 0x5470
movq 0xa0(%r13), %rsi
movq 0xa8(%r13), %rdx
movq 0x30f29(%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(%r13)
jle 0x820c
leaq 0x58(%rsp), %r15
xorl %r13d, %r13d
leaq 0x68(%rsp), %r12
leaq 0x18(%rsp), %rbp
xorl %ebx, %ebx
movq (%r14), %rax
movslq (%rax,%rbx,4), %rsi
incq %rsi
movq %r12, %rdi
movq %rbp, %rdx
callq 0xd2a0
movq (%r14), %rax
cmpl $0x0, (%rax,%rbx,4)
js 0x81ca
movq $-0x1, %r14
xorl %r12d, %r12d
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movb %r13b, 0x28(%rsp)
movq %r15, 0x48(%rsp)
movq %r13, 0x50(%rsp)
movb %r13b, 0x58(%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 %rbp, %rsi
callq 0x56f0
movq 0x68(%rsp), %rdi
addq %r12, %rdi
movq %rbp, %rsi
callq 0x5230
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x819a
callq 0x53d0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x81ae
callq 0x53d0
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%rbx,4), %rax
incq %r14
addq $0x20, %r12
cmpq %rax, %r14
jl 0x8124
leaq (%rbx,%rbx,2), %rdi
shlq $0x3, %rdi
movq 0x38(%rsp), %rax
addq (%rax), %rdi
leaq 0x68(%rsp), %r12
movq %r12, %rsi
callq 0xd32c
movq %r12, %rdi
callq 0x698e
incq %rbx
movq 0x40(%rsp), %rax
movslq 0xdc(%rax), %rax
cmpq %rax, %rbx
movq 0x10(%rsp), %r14
jl 0x80f8
xorl %r15d, %r15d
leaq 0x80(%rsp), %rdi
callq 0x5100
movl %r15d, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21288(%rip), %rdi     # 0x294c0
callq 0x5260
leaq 0x2127c(%rip), %rdi     # 0x294c0
callq 0x55a0
jmp 0x826b
jmp 0x826b
jmp 0x8258
jmp 0x8258
movq %rax, %r14
jmp 0x82aa
jmp 0x8258
movq %rax, %r14
jmp 0x82b4
movq %rax, %r14
cmpl $0x0, (%r15)
jne 0x826e
movl %ebx, (%r15)
jmp 0x826e
movq %rax, %r14
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x82b4
callq 0x53d0
jmp 0x82b4
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x8296
callq 0x53d0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x82aa
callq 0x53d0
leaq 0x68(%rsp), %rdi
callq 0x698e
leaq 0x80(%rsp), %rdi
callq 0x5100
movq %r14, %rdi
callq 0x56b0
nop