// File: estwings57[P]CasHMC/sources/ConfigReader.cpp
// Function: CasHMC::ReadIniFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void ReadIniFile(string file_name)
{
	fstream file_stream(file_name.c_str(), ios::in);
    if(!file_stream.good()) {
		ERROR("CasHMC could not open "<<file_name<<" for reading");
		exit(0);
	}
	
	string line, field_name, field_value;
	int commentIdx, equalsIdx, spaceIdx;
	unsigned int lineNumber=0;
	
	while(!file_stream.eof())
	{
		lineNumber++;
		getline(file_stream, line);
		//skip zero-length lines
		if(line.size() == 0) {
			//DEBUG("Skipping blank line "<<lineNumber);
			continue;
		}
		//search for a comment
		commentIdx = line.find_first_of(";");
		if(commentIdx != string::npos) {
			if(commentIdx == 0) {
				//DEBUG("Skipping comment line "<<lineNumber);
				continue;
			}
			line = line.substr(0, commentIdx);
		}
		else {
			continue;
		}
		//a line has to have an equals sign
		equalsIdx = line.find_first_of("=");
		if(equalsIdx == string::npos) {
			//DEBUG("Skipping comment line "<<lineNumber);
			continue;
		}

		//extract field value
		field_value = line.substr(equalsIdx+1, line.size());
		spaceIdx = field_value.find_last_not_of(" ");
		field_value = field_value.substr(0, spaceIdx+1);
		spaceIdx = field_value.find_last_of(" ");
		field_value = field_value.substr(spaceIdx+1, field_value.size());
		 
		//extract field name
		line = line.substr(0, equalsIdx);
		spaceIdx = line.find_last_not_of(" ");
		line = line.substr(0, spaceIdx+1);
		spaceIdx = line.find_last_of(" ");
		field_name = line.substr(spaceIdx+1, line.size());

		//cout<<"["<<lineNumber<<"] "<<field_name<<" : "<<field_value<<endl;
		SetField(field_name, field_value);
	}
    file_stream.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x3c8(%rbp)
movq %rdi, -0x8(%rbp)
callq 0x4180
movq %rax, %rsi
leaq -0x218(%rbp), %rdi
movl $0x8, %edx
callq 0x44d0
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x45f0
movb %al, -0x3b9(%rbp)
jmp 0x2626f
movb -0x3b9(%rbp), %al
testb $0x1, %al
jne 0x26390
jmp 0x2627f
movq 0x3fd6a(%rip), %rdi     # 0x65ff0
leaq 0x2adad(%rip), %rsi     # 0x5103a
callq 0x4380
movq %rax, -0x3d0(%rbp)
jmp 0x2629b
movq -0x3d0(%rbp), %rdi
leaq 0x2ca43(%rip), %rsi     # 0x52cec
callq 0x4380
movq %rax, -0x3d8(%rbp)
jmp 0x262b7
movq -0x3d8(%rbp), %rdi
leaq 0x2b570(%rip), %rsi     # 0x51835
callq 0x4380
movq %rax, -0x3e0(%rbp)
jmp 0x262d3
movq -0x3e0(%rbp), %rdi
movl $0xa4, %esi
callq 0x4610
movq %rax, -0x3e8(%rbp)
jmp 0x262ed
movq -0x3e8(%rbp), %rdi
leaq 0x2ad5e(%rip), %rsi     # 0x51059
callq 0x4380
movq %rax, -0x3f0(%rbp)
jmp 0x26309
movq -0x3f0(%rbp), %rdi
leaq 0x2c9ee(%rip), %rsi     # 0x52d05
callq 0x4380
movq %rax, -0x3f8(%rbp)
jmp 0x26325
movq -0x3c8(%rbp), %rsi
movq -0x3f8(%rbp), %rdi
callq 0x4320
movq %rax, -0x400(%rbp)
jmp 0x26341
movq -0x400(%rbp), %rdi
leaq 0x2c9cd(%rip), %rsi     # 0x52d1c
callq 0x4380
movq %rax, -0x408(%rbp)
jmp 0x2635d
movq -0x408(%rbp), %rdi
movq 0x3fc45(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x26372
xorl %edi, %edi
callq 0x4460
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x2689b
leaq -0x248(%rbp), %rdi
callq 0x44f0
leaq -0x268(%rbp), %rdi
callq 0x44f0
leaq -0x288(%rbp), %rdi
callq 0x44f0
movl $0x0, -0x298(%rbp)
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x4680
movb %al, -0x409(%rbp)
jmp 0x263de
movb -0x409(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x263ef
jmp 0x26830
movl -0x298(%rbp), %eax
incl %eax
movl %eax, -0x298(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x40c0
jmp 0x26412
leaq -0x248(%rbp), %rdi
callq 0x4260
cmpq $0x0, %rax
jne 0x2643d
jmp 0x263be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x26877
leaq -0x248(%rbp), %rdi
leaq 0x2c8de(%rip), %rsi     # 0x52d29
xorl %eax, %eax
movl %eax, %edx
callq 0x41d0
movl %eax, -0x28c(%rbp)
movslq -0x28c(%rbp), %rax
cmpq $-0x1, %rax
je 0x264b6
cmpl $0x0, -0x28c(%rbp)
jne 0x26475
jmp 0x263be
movslq -0x28c(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x2b8(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x43b0
jmp 0x26495
leaq -0x248(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x4470
leaq -0x2b8(%rbp), %rdi
callq 0x46e8
jmp 0x264bb
jmp 0x263be
leaq -0x248(%rbp), %rdi
leaq 0x2e0f6(%rip), %rsi     # 0x545bf
xorl %eax, %eax
movl %eax, %edx
callq 0x41d0
movl %eax, -0x290(%rbp)
movslq -0x290(%rbp), %rax
cmpq $-0x1, %rax
jne 0x264ea
jmp 0x263be
movl -0x290(%rbp), %eax
incl %eax
cltq
movq %rax, -0x418(%rbp)
leaq -0x248(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x4260
movq -0x420(%rbp), %rsi
movq -0x418(%rbp), %rdx
movq %rax, %rcx
leaq -0x2d8(%rbp), %rdi
callq 0x43b0
jmp 0x2652d
leaq -0x288(%rbp), %rdi
movq %rdi, -0x428(%rbp)
leaq -0x2d8(%rbp), %rsi
movq %rsi, -0x430(%rbp)
callq 0x4470
movq -0x430(%rbp), %rdi
callq 0x46e8
movq -0x428(%rbp), %rdi
leaq 0x2c4ac(%rip), %rsi     # 0x52a14
movq $-0x1, %rdx
callq 0x4660
movq -0x428(%rbp), %rsi
movl %eax, -0x294(%rbp)
movl -0x294(%rbp), %eax
incl %eax
movslq %eax, %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x2f8(%rbp), %rdi
callq 0x43b0
jmp 0x2659e
leaq -0x288(%rbp), %rdi
movq %rdi, -0x440(%rbp)
leaq -0x2f8(%rbp), %rsi
movq %rsi, -0x448(%rbp)
callq 0x4470
movq -0x448(%rbp), %rdi
callq 0x46e8
movq -0x440(%rbp), %rdi
leaq 0x2c43b(%rip), %rsi     # 0x52a14
movq $-0x1, %rdx
callq 0x4340
movq -0x440(%rbp), %rdi
movl %eax, -0x294(%rbp)
movl -0x294(%rbp), %eax
incl %eax
cltq
movq %rax, -0x438(%rbp)
callq 0x4260
movq -0x440(%rbp), %rsi
movq -0x438(%rbp), %rdx
movq %rax, %rcx
leaq -0x318(%rbp), %rdi
callq 0x43b0
jmp 0x26627
leaq -0x288(%rbp), %rdi
leaq -0x318(%rbp), %rsi
movq %rsi, -0x450(%rbp)
callq 0x4470
movq -0x450(%rbp), %rdi
callq 0x46e8
movslq -0x290(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x338(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x43b0
jmp 0x2666d
leaq -0x248(%rbp), %rdi
movq %rdi, -0x458(%rbp)
leaq -0x338(%rbp), %rsi
movq %rsi, -0x460(%rbp)
callq 0x4470
movq -0x460(%rbp), %rdi
callq 0x46e8
movq -0x458(%rbp), %rdi
leaq 0x2c36c(%rip), %rsi     # 0x52a14
movq $-0x1, %rdx
callq 0x4660
movq -0x458(%rbp), %rsi
movl %eax, -0x294(%rbp)
movl -0x294(%rbp), %eax
incl %eax
movslq %eax, %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x358(%rbp), %rdi
callq 0x43b0
jmp 0x266de
leaq -0x248(%rbp), %rdi
movq %rdi, -0x470(%rbp)
leaq -0x358(%rbp), %rsi
movq %rsi, -0x478(%rbp)
callq 0x4470
movq -0x478(%rbp), %rdi
callq 0x46e8
movq -0x470(%rbp), %rdi
leaq 0x2c2fb(%rip), %rsi     # 0x52a14
movq $-0x1, %rdx
callq 0x4340
movq -0x470(%rbp), %rdi
movl %eax, -0x294(%rbp)
movl -0x294(%rbp), %eax
incl %eax
cltq
movq %rax, -0x468(%rbp)
callq 0x4260
movq -0x470(%rbp), %rsi
movq -0x468(%rbp), %rdx
movq %rax, %rcx
leaq -0x378(%rbp), %rdi
callq 0x43b0
jmp 0x26767
leaq -0x268(%rbp), %rdi
movq %rdi, -0x480(%rbp)
leaq -0x378(%rbp), %rsi
movq %rsi, -0x488(%rbp)
callq 0x4470
movq -0x488(%rbp), %rdi
callq 0x46e8
movq -0x480(%rbp), %rsi
leaq -0x398(%rbp), %rdi
callq 0x4190
jmp 0x267a9
leaq -0x3b8(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x4190
jmp 0x267be
leaq -0x398(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x268c0
jmp 0x267d3
leaq -0x3b8(%rbp), %rdi
callq 0x46e8
leaq -0x398(%rbp), %rdi
callq 0x46e8
jmp 0x263be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x26822
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x46e8
leaq -0x398(%rbp), %rdi
callq 0x46e8
jmp 0x26877
leaq -0x218(%rbp), %rdi
callq 0x4080
jmp 0x2683e
leaq -0x288(%rbp), %rdi
callq 0x46e8
leaq -0x268(%rbp), %rdi
callq 0x46e8
leaq -0x248(%rbp), %rdi
callq 0x46e8
leaq -0x218(%rbp), %rdi
callq 0x40d0
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
leaq -0x288(%rbp), %rdi
callq 0x46e8
leaq -0x268(%rbp), %rdi
callq 0x46e8
leaq -0x248(%rbp), %rdi
callq 0x46e8
leaq -0x218(%rbp), %rdi
callq 0x40d0
movq -0x220(%rbp), %rdi
callq 0x4630
nopw %cs:(%rax,%rax)