// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/main.cpp
// Function: processArgsFromFile(int, char**)
bool processArgsFromFile(int argc, char **argv)
{
	if (argc < 2)
		return false;
	
	string argListFile("argList.txt");
	
	ifstream ifs;
	ifs.open(argListFile.c_str());
	if (!ifs)
		return false;
	
	cout << "Building argument list from file " << argListFile << endl;
	
	vector<string> args;
	args.push_back(string(argv[0]));
	while (ifs)
	{
		string s;
		while (ifs && !isspace(ifs.peek()))
		{
			char c = ifs.get();
			if (ifs)
				s += c;
		}
		
		//cout << "    Arg read: \"" << s << "\"" << endl;
		
		args.push_back(s);
		
		//Skip spaces/endlines/tabs/etc. to the next argument
		while (ifs && isspace(ifs.peek()))
			ifs.get();
	}
	ifs.close();
	
	//cout << "Num args in file: " << args.size() << endl;
	//for (int i = 0; i < args.size(); i++)
	//	cout << "    Arg: \"" << args[i] << "\"" << endl;
	
	int argc2 = args.size();
	char **argv2 = new char*[argc2];
	for (int i = 0; i < argc2; i++)
	{
		argv2[i] = new char[256];
		strcpy(argv2[i], args[i].c_str());
		//cout << "    Arg " << i << " length: " << strlen(argv2[i]) << endl;
	}
	
	//cout << "Argument list built" << endl;
	//for (int i = 0; i < argc2; i++)
	//	cout << "    Arg: \"" << argv2[i] << "\"" << endl;
	
	processArgs(argc2, argv2);
	
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
cmpl $0x2, %edi
jge 0x5c9e
xorl %ebx, %ebx
jmp 0x5f40
movq %rsi, %r14
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24ac6(%rip), %rsi     # 0x2a777
leaq 0x24aca(%rip), %rdx     # 0x2a782
leaq 0x30(%rsp), %rdi
callq 0xa9c2
leaq 0x70(%rsp), %rdi
callq 0x3350
movq 0x30(%rsp), %rsi
leaq 0x70(%rsp), %rdi
movl $0x8, %edx
callq 0x31b0
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
sete %bl
jne 0x5f1f
movq 0x312cf(%rip), %rdi     # 0x36fd0
leaq 0x24a7b(%rip), %rsi     # 0x2a783
movl $0x21, %edx
callq 0x3360
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x312ad(%rip), %rdi     # 0x36fd0
callq 0x3360
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq (%r14), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x9ee4
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xadd2
leaq 0x20(%rsp), %rbp
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x5d9f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rcx
testb $0x5, 0x90(%rsp,%rcx)
jne 0x5e8f
leaq 0x70(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0x50(%rsp), %r12
movq %rbp, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5e26
movq %r14, %rdi
callq 0x3100
movl %eax, %edi
callq 0x3060
testl %eax, %eax
jne 0x5e26
movq %r14, %rdi
callq 0x3380
movq 0x70(%rsp), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x90(%rsp,%rcx)
jne 0x5e26
movsbl %al, %esi
movq %r15, %rdi
callq 0x3280
movq 0x70(%rsp), %rax
jmp 0x5dd8
movq %r12, %rdi
movq %r15, %rsi
callq 0xa068
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5e61
movq %r14, %rdi
callq 0x3100
movl %eax, %edi
callq 0x3060
testl %eax, %eax
je 0x5e61
movq %r14, %rdi
callq 0x3380
jmp 0x5e31
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5e78
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rcx
testb $0x5, 0x90(%rsp,%rcx)
je 0x5dc5
leaq 0x70(%rsp), %rdi
callq 0x3080
movq 0x50(%rsp), %r12
movq 0x58(%rsp), %r14
subq %r12, %r14
movq %r14, %rax
shlq $0x1b, %rax
movq %rax, %rcx
sarq $0x1d, %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x3030
movq %rax, %r15
shrq $0x5, %r14
testl %r14d, %r14d
jle 0x5f05
movl %r14d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %r13d, %r13d
movl $0x100, %edi            # imm = 0x100
callq 0x3030
movq %rax, (%r15,%r13,8)
movq (%r12), %rsi
movq %rax, %rdi
callq 0x32c0
incq %r13
addq $0x20, %r12
cmpq %r13, %rbp
jne 0x5edf
movl %r14d, %edi
movq %r15, %rsi
callq 0x4b11
leaq 0x50(%rsp), %rdi
callq 0x9f22
leaq 0x40(%rsp), %r15
leaq 0x70(%rsp), %rdi
callq 0x3090
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x5f40
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3310
movl %ebx, %eax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5f79
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x5f8f
jmp 0x5f9c
jmp 0x5f79
jmp 0x5f79
movq %rax, %rbx
jmp 0x5fb0
movq %rax, %rbx
jmp 0x5fa6
jmp 0x5f82
movq %rax, %rbx
jmp 0x5f9c
jmp 0x5f82
jmp 0x5f82
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5f9c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x50(%rsp), %rdi
callq 0x9f22
leaq 0x70(%rsp), %rdi
callq 0x3090
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5fcc
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3500