// File: /workspace/github_cpp_makefile_star2_O1/richardposner[P]BioNetFit2/src/code/Parser.cpp
// Function: Parser::Parser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char**)
Parser::Parser(string configFile, char** envp) {

	/*while (*envp) {
		string envEntry = *envp;
		size_t pos = envEntry.find('=');
		if (pos != string::npos) {
			string name = envEntry.substr(0, pos);
			string value = envEntry.substr(pos+1, string::npos);
			envSymbols[name] = value;
			logDebug(cout << "environment symbol: '" << name << "' = '" << value << "'" << endl);
		}
		++envp;
	}*/

	debugInfo = configFile;
	groupStack.push_front(this);

	FILE* in = fopen(configFile.c_str(), "r");
	if (!in) {
		cerr << "cannot open input file '" << configFile << "'" << endl;
		exit(2);
	}

	char buff[1024];
	while (fgets(buff, 1024, in)) {

		string line=buff;
		if ( (line.length() > 2) && (line[0] != '#') && (line.find(')') == string::npos) ) {
			string name;
			string value;
			split(line, name, value, '=');

			if (value == "(") {
				//logDebug(cout << "   config: new group '" << name << "'" << endl);
				Parser* newGroup = new Parser(name, debugInfo);
				groupStack.front()->groups[name] = newGroup;
				groupStack.push_front(newGroup);
			} else {
				for (list<Parser*>::reverse_iterator i = groupStack.rbegin(); i != groupStack.rend(); ++i) {
					(*i)->symbolExpand(value);
				}
				envSymbolExpand(value);
				//logDebug(cout << "   config: name = '" << name << "', value = '" << value << "'" << endl);
				groupStack.front()->add(name, value);
			}
		}
		if ( (line.length() > 0) && (line[0] != '#') && (line.find(')') != string::npos) ) {
			//logDebug(cout << "   end of group" << endl);
			groupStack.pop_front();
		}
	}

	fclose(in);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x528, %rsp            # imm = 0x528
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x8(%rdi), %rax
xorl %ecx, %ecx
movl %ecx, 0x8(%rdi)
movq %rcx, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movq %rcx, 0x28(%rdi)
leaq 0x30(%rdi), %rax
movq %rax, 0x70(%rsp)
leaq 0x38(%rdi), %rax
movl %ecx, 0x38(%rdi)
movq %rcx, 0x40(%rdi)
movq %rax, 0x48(%rdi)
movq %rax, 0x50(%rdi)
movq %rcx, 0x58(%rdi)
leaq 0x68(%rdi), %rax
movl %ecx, 0x68(%rdi)
movq %rcx, 0x70(%rdi)
movq %rax, 0x78(%rdi)
movq %rax, 0x80(%rdi)
movq %rcx, 0x88(%rdi)
leaq 0x90(%rdi), %r14
movq %r14, 0x98(%rdi)
movq %r14, 0x90(%rdi)
movq %rcx, 0xa0(%rdi)
leaq 0xa8(%rdi), %r15
leaq 0xb8(%rdi), %rax
movq %rax, 0x68(%rsp)
movq %rax, 0xa8(%rdi)
movq %rcx, 0xb0(%rdi)
movb $0x0, 0xb8(%rdi)
movq %r15, %rdi
movq %r15, 0x118(%rsp)
callq 0x22500
movq (%r14), %r15
movl $0x18, %edi
callq 0x22980
movq %rbx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x220d0
incq 0xa0(%rbx)
movq (%r13), %rdi
leaq 0xacb50(%rip), %rsi     # 0xff223
callq 0x22b10
testq %rax, %rax
je 0x52ae9
movq %rax, %r12
leaq 0x120(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x23000
testq %rax, %rax
je 0x52acf
leaq 0x120(%rsp), %r13
leaq 0x48(%rsp), %rbp
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq %r13, %rdi
callq 0x223a0
leaq (%rsp,%rax), %rdx
addq $0x120, %rdx            # imm = 0x120
movq %rbp, %rdi
movq %r13, %rsi
callq 0x32210
cmpq $0x3, 0x50(%rsp)
jb 0x52a50
movq 0x48(%rsp), %rax
cmpb $0x23, (%rax)
je 0x52a50
movq %rbp, %rdi
movl $0x29, %esi
xorl %edx, %edx
callq 0x22c80
cmpq $-0x1, %rax
jne 0x52a50
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x30(%rsp)
movb %cl, 0x38(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movb %cl, 0x18(%rsp)
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x32180
movq %rbx, %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movl $0x3d, %r8d
callq 0x52cdc
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x52801
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x8(%rsp), %rdi
leaq 0xa5bf7(%rip), %rsi     # 0xf8404
callq 0x22250
testl %eax, %eax
je 0x5290e
movq %r14, %r15
cmpq (%r14), %r14
je 0x5283d
movq 0x8(%r15), %rax
movq 0x10(%rax), %rsi
leaq 0x8(%rsp), %rdx
callq 0x530aa
movq 0x8(%r15), %r15
cmpq (%r14), %r15
jne 0x52822
movq 0x70(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x530aa
movq (%r14), %rax
movq 0x10(%rax), %r15
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x32180
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x32180
movq %r15, %rdi
leaq 0x98(%rsp), %rsi
callq 0x535ba
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
callq 0x22500
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x528e0
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x52a18
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x52a18
movl $0xc8, %edi
callq 0x22980
movq %rax, (%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x32180
leaq 0x108(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0xa8(%rbx), %rsi
movq 0xb0(%rbx), %rdx
addq %rsi, %rdx
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
callq 0x32180
movq (%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movq %r15, %rdx
callq 0x523fc
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x529b0
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x529d5
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x229c0
movq (%r14), %rax
movq 0x10(%rax), %rdi
addq $0x60, %rdi
leaq 0x28(%rsp), %rsi
callq 0x5353e
movq (%rsp), %rcx
movq %rcx, (%rax)
movq (%r14), %r15
movl $0x18, %edi
callq 0x22980
movq (%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x220d0
incq 0xa0(%rbx)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x52a34
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x52a50
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpq $0x0, 0x50(%rsp)
je 0x52a9a
movq 0x48(%rsp), %rax
cmpb $0x23, (%rax)
je 0x52a9a
movq %rbp, %rdi
movl $0x29, %esi
xorl %edx, %edx
callq 0x22c80
cmpq $-0x1, %rax
je 0x52a9a
movq 0x90(%rbx), %r15
decq 0xa0(%rbx)
movq %r15, %rdi
callq 0x230a0
movl $0x18, %esi
movq %r15, %rdi
callq 0x229c0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x52ab6
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x23000
testq %rax, %rax
jne 0x5270f
movq %r12, %rdi
callq 0x22970
addq $0x528, %rsp            # imm = 0x528
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1234e8(%rip), %rdi    # 0x175fd8
leaq 0xa57a5(%rip), %rsi     # 0xf829c
movl $0x18, %edx
callq 0x22ab0
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq 0x1234c8(%rip), %rdi    # 0x175fd8
callq 0x22ab0
movq %rax, %r15
leaq 0xa11e4(%rip), %rsi     # 0xf3d03
movl $0x1, %edx
movq %rax, %rdi
callq 0x22ab0
movq %r15, %rdi
callq 0x22430
movl $0x2, %edi
callq 0x22b90
movq %rax, %r15
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x52b6b
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x52b6b
movq %rax, %r15
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x52b95
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x52b95
movq %rax, %r15
movl $0xc8, %esi
movq (%rsp), %rdi
jmp 0x52c14
jmp 0x52c1d
jmp 0x52c1d
jmp 0x52c1d
movq %rax, %r15
jmp 0x52bf4
movq %rax, %r15
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x52c25
movq 0xe8(%rsp), %rsi
jmp 0x52c11
jmp 0x52c22
movq %rax, %r15
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x52bf4
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x52c25
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x52c25
jmp 0x52c22
movq %rax, %r15
jmp 0x52c79
movq %rax, %r15
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x52c41
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x52c5d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x52c79
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x118(%rsp), %rax
movq (%rax), %rdi
cmpq 0x68(%rsp), %rdi
je 0x52c9b
movq 0x68(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x229c0
movq (%r14), %rdi
cmpq %r14, %rdi
je 0x52cb8
movq (%rdi), %r12
movl $0x18, %esi
callq 0x229c0
movq %r12, %rdi
cmpq %r14, %r12
jne 0x52ca3
leaq 0x60(%rbx), %rdi
callq 0x53636
movq 0x70(%rsp), %rdi
callq 0x341fc
movq %rbx, %rdi
callq 0x341fc
movq %r15, %rdi
callq 0x23240
nop