// File: /workspace/github_cpp_makefile_star2_O2/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 0x5112
xorl %ebx, %ebx
jmp 0x532d
movq %rsi, %r14
leaq 0x1d647(%rip), %rsi     # 0x22763
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x7fcc
leaq 0x70(%rsp), %rdi
callq 0x3310
movq 0x50(%rsp), %rsi
leaq 0x70(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x3190
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
sete %bl
jne 0x5319
movq 0x2ae68(%rip), %rdi     # 0x2ffd0
leaq 0x1d600(%rip), %rsi     # 0x2276f
callq 0x32c0
leaq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0x3270
movq %rax, %rdi
callq 0x3120
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq (%r14), %rsi
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x7fcc
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8e0c
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x3548
leaq 0x40(%rsp), %r13
leaq 0x70(%rsp), %r15
leaq 0x10(%rsp), %r12
movq 0x70(%rsp), %rcx
movq -0x18(%rcx), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5291
movq %r13, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movq -0x18(%rcx), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5249
movq %r15, %rdi
callq 0x30e0
movl %eax, %edi
callq 0x3060
testl %eax, %eax
jne 0x5249
movq %r15, %rdi
callq 0x3340
movq 0x70(%rsp), %rcx
movq -0x18(%rcx), %rdx
testb $0x5, 0x90(%rsp,%rdx)
jne 0x51fb
movsbl %al, %esi
movq %r14, %rdi
callq 0x3250
movq 0x70(%rsp), %rcx
jmp 0x51fb
movq %r12, %rdi
movq %r14, %rsi
callq 0x812e
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x5284
movq %r15, %rdi
callq 0x30e0
movl %eax, %edi
callq 0x3060
testl %eax, %eax
je 0x5284
movq %r15, %rdi
callq 0x3340
jmp 0x5254
movq %r14, %rdi
callq 0x3548
jmp 0x51d4
leaq 0x70(%rsp), %rdi
callq 0x3080
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r14
subq %r12, %r14
movq %r14, %rax
shlq $0x1b, %rax
movq %rax, %rcx
sarq $0x1d, %rcx
testq %rax, %rax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0x3030
movq %rax, %r15
shrq $0x5, %r14
xorl %r13d, %r13d
testl %r14d, %r14d
movl $0x0, %ebp
cmovgl %r14d, %ebp
shlq $0x3, %rbp
cmpq %r13, %rbp
je 0x5304
movl $0x100, %edi            # imm = 0x100
callq 0x3030
movq %rax, (%r15,%r13)
movq (%r12,%r13,4), %rsi
movq %rax, %rdi
callq 0x32a0
addq $0x8, %r13
jmp 0x52df
movl %r14d, %edi
movq %r15, %rsi
callq 0x44e8
leaq 0x10(%rsp), %rdi
callq 0x8008
leaq 0x70(%rsp), %rdi
callq 0x3090
leaq 0x50(%rsp), %rdi
callq 0x3548
movl %ebx, %eax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5353
jmp 0x535e
jmp 0x5353
jmp 0x5353
movq %rax, %rbx
jmp 0x537f
movq %rax, %rbx
jmp 0x5375
movq %rax, %rbx
jmp 0x536b
jmp 0x535e
jmp 0x535e
jmp 0x535e
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3548
leaq 0x10(%rsp), %rdi
callq 0x8008
leaq 0x70(%rsp), %rdi
callq 0x3090
leaq 0x50(%rsp), %rdi
callq 0x3548
movq %rbx, %rdi
callq 0x34d0