// File: /workspace/github_cpp_makefile_star2_O1/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 0x5d57
xorl %ebx, %ebx
jmp 0x5ff9
movq %rsi, %r14
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x25a2f(%rip), %rsi     # 0x2b799
leaq 0x25a33(%rip), %rdx     # 0x2b7a4
leaq 0x30(%rsp), %rdi
callq 0xaa0e
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 0x5fd8
movq 0x31216(%rip), %rdi     # 0x36fd0
leaq 0x259e4(%rip), %rsi     # 0x2b7a5
movl $0x21, %edx
callq 0x3360
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x311f4(%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 0x9f34
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xae4a
leaq 0x20(%rsp), %rbp
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x5e58
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5f48
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 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5edf
movq %r14, %rdi
callq 0x3100
movl %eax, %edi
callq 0x3060
testl %eax, %eax
jne 0x5edf
movq %r14, %rdi
callq 0x3380
movq 0x70(%rsp), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x90(%rsp,%rcx)
jne 0x5e91
movsbl %al, %esi
movq %r15, %rdi
callq 0x3280
jmp 0x5e91
movq %r12, %rdi
movq %r15, %rsi
callq 0xa0b6
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5f1a
movq %r14, %rdi
callq 0x3100
movl %eax, %edi
callq 0x3060
testl %eax, %eax
je 0x5f1a
movq %r14, %rdi
callq 0x3380
jmp 0x5eea
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5f31
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
je 0x5e7e
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 0x5fbe
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 0x5f98
movl %r14d, %edi
movq %r15, %rsi
callq 0x4b11
leaq 0x50(%rsp), %rdi
callq 0x9f72
leaq 0x40(%rsp), %r15
leaq 0x70(%rsp), %rdi
callq 0x3090
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x5ff9
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 0x6032
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x6048
jmp 0x6055
jmp 0x6032
jmp 0x6032
movq %rax, %rbx
jmp 0x6069
movq %rax, %rbx
jmp 0x605f
jmp 0x603b
movq %rax, %rbx
jmp 0x6055
jmp 0x603b
jmp 0x603b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6055
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x50(%rsp), %rdi
callq 0x9f72
leaq 0x70(%rsp), %rdi
callq 0x3090
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6085
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3500