// File: /workspace/github_cpp_makefile_star2_O2/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 %rdi, %r15
leaq 0x8(%rdi), %rax
andl $0x0, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
andq $0x0, 0x28(%rdi)
leaq 0x38(%rdi), %rax
andl $0x0, 0x38(%rdi)
andq $0x0, 0x40(%rdi)
movq %rax, 0x48(%rdi)
movq %rax, 0x50(%rdi)
andq $0x0, 0x58(%rdi)
leaq 0x68(%rdi), %rax
andl $0x0, 0x68(%rdi)
andq $0x0, 0x70(%rdi)
movq %rax, 0x78(%rdi)
movq %rax, 0x80(%rdi)
andq $0x0, 0x88(%rdi)
leaq 0x90(%rdi), %r14
movq %r14, 0x98(%rdi)
movq %r14, 0x90(%rdi)
andq $0x0, 0xa0(%rdi)
movq %rsi, %rbx
addq $0xa8, %rdi
leaq 0xb8(%r15), %rax
movq %rax, 0xa8(%r15)
andq $0x0, 0xb0(%r15)
movb $0x0, 0xb8(%r15)
movq %rdi, 0x10(%rsp)
movq %r15, 0x8(%rsp)
callq 0x28570
leaq 0x120(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0x4fe32
movq (%rbx), %rdi
leaq 0x8ac4d(%rip), %rsi     # 0xda13c
callq 0x28ba0
testq %rax, %rax
je 0x4f76e
movq %rax, %r12
leaq 0x120(%rsp), %r13
leaq 0x60(%rsp), %rbp
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x29070
testq %rax, %rax
je 0x4f754
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x18(%rsp), %rdx
callq 0x33402
movq 0x68(%rsp), %rax
cmpq $0x3, %rax
jb 0x4f71d
movq 0x60(%rsp), %rax
cmpb $0x23, (%rax)
je 0x4f718
movq %rbp, %rdi
pushq $0x29
popq %rsi
xorl %edx, %edx
callq 0x28d20
cmpq $-0x1, %rax
jne 0x4f718
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
xorl %ecx, %ecx
movb %cl, 0x28(%rsp)
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movb %cl, 0x48(%rsp)
leaq 0x100(%rsp), %rdi
movq %rbp, %rsi
callq 0x28dd0
movq 0x8(%rsp), %rdi
leaq 0x100(%rsp), %r15
movq %r15, %rsi
leaq 0x18(%rsp), %rdx
leaq 0x38(%rsp), %rbx
movq %rbx, %rcx
pushq $0x3d
popq %r8
callq 0x4f884
movq %r15, %rdi
callq 0x295a0
movq %rbx, %rdi
leaq 0x86d28(%rip), %rsi     # 0xd6304
callq 0x3357b
movq %r14, %r15
testb %al, %al
je 0x4f67f
movl $0xc8, %edi
callq 0x28a10
movq %rax, %r15
leaq 0xe0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x28dd0
leaq 0x80(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x28dd0
movq %r15, %rdi
movq %r15, %rbx
leaq 0xe0(%rsp), %r15
movq %r15, %rsi
leaq 0x80(%rsp), %rdx
callq 0x4f2c8
leaq 0x80(%rsp), %rdi
callq 0x295a0
movq %r15, %rdi
callq 0x295a0
movq %rbx, 0x58(%rsp)
movq (%r14), %rax
movq 0x10(%rax), %rdi
addq $0x60, %rdi
leaq 0x18(%rsp), %rsi
callq 0x4fe3e
movq %rbx, (%rax)
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
callq 0x4fea4
jmp 0x4f704
cmpq (%r14), %r15
je 0x4f69c
movq 0x8(%r15), %rax
movq 0x10(%rax), %rdi
leaq 0x38(%rsp), %rsi
callq 0x4f966
movq 0x8(%r15), %r15
jmp 0x4f67f
movq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x4f972
movq (%r14), %rax
movq 0x10(%rax), %r15
leaq 0xc0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x28dd0
leaq 0xa0(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x28dd0
movq %r15, %rdi
leaq 0xc0(%rsp), %rbx
movq %rbx, %rsi
leaq 0xa0(%rsp), %r15
movq %r15, %rdx
callq 0x4f97e
movq %r15, %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x295a0
leaq 0x38(%rsp), %rdi
callq 0x295a0
leaq 0x18(%rsp), %rdi
callq 0x295a0
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x4f747
movq 0x60(%rsp), %rax
cmpb $0x23, (%rax)
je 0x4f747
movq %rbp, %rdi
pushq $0x29
popq %rsi
xorl %edx, %edx
callq 0x28d20
cmpq $-0x1, %rax
je 0x4f747
movq %r14, %rdi
callq 0x4feb0
movq %rbp, %rdi
callq 0x295a0
jmp 0x4f50d
movq %r12, %rdi
callq 0x28a00
addq $0x528, %rsp            # imm = 0x528
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x116873(%rip), %rdi    # 0x165fe8
leaq 0x86a20(%rip), %rsi     # 0xd619c
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x28910
leaq 0x824f9(%rip), %rsi     # 0xd1c8c
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
pushq $0x2
popq %rdi
callq 0x28c20
jmp 0x4f81f
jmp 0x4f81f
jmp 0x4f81f
movq %rbx, %r15
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x295a0
jmp 0x4f7c9
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x295a0
jmp 0x4f7db
movq %rax, %rbx
movl $0xc8, %esi
movq %r15, %rdi
callq 0x28a50
jmp 0x4f827
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x295a0
jmp 0x4f7ff
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x4f814
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x295a0
jmp 0x4f827
jmp 0x4f824
jmp 0x4f824
movq %rax, %rbx
jmp 0x4f845
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x295a0
leaq 0x18(%rsp), %rdi
callq 0x295a0
leaq 0x60(%rsp), %rdi
callq 0x295a0
movq 0x8(%rsp), %r13
leaq 0x60(%r13), %r15
leaq 0x30(%r13), %r12
movq 0x10(%rsp), %rdi
callq 0x295a0
movq %r14, %rdi
callq 0x4ff1e
movq %r15, %rdi
callq 0x4ff48
movq %r12, %rdi
callq 0x35bd2
movq %r13, %rdi
callq 0x35bd2
movq %rbx, %rdi
callq 0x292f0