// File: /workspace/github_cpp_makefile_star2_O2/pelrun[P]aft/aft.cpp
// Function: main
int main(int argc, char *argv[])
{
	try
	{
		COptionParser optParser(appliOption, appliName, appliUsageShort, appliUsageLong, authorName, authorMail);
		
		optParser.PrintHeader(std::cout);

		if (!optParser.ParseCommandLine(&argc, &argv, 0, false))
		{
			optParser.PrintError(std::cout);
			optParser.PrintUsage(std::cout);
			return -1;
		}

		bool noLoop = false;
		std::string COMport = defaultComPort();
		std::string filename = "";
		std::string dir = "";

		
		int i=0;
		while (optParser.GetOptionI(i) != 0)
		{
			switch(optParser.GetOptionI(i))
			{
			case 'p':
				{
					COMport = optParser.GetStringOptionI(i);
					break;
				}
			case 'f':
				{
					filename = optParser.GetStringOptionI(i);
					noLoop = true;
					break;
				}
			case 'd':
				{
					dir = optParser.GetStringOptionI(i);
					break;
				}
			case 'n':
				{
					noLoop = true;
					break;
				}
			default:
				{
					break;
				}
			}

			i++;
		}

		CAksFileTransfert transfert(COMport);

		if (!transfert.IsOpen())
		{
			std::cout << "Unable to open comport " << COMport << std::endl;
			return -1;
		} else {
			std::cout << "AFT now listening on " << COMport << std::endl;
		}

		if (filename.size() != 0)
		{
			transfert.SetForceFilename(filename);
		}
		if (dir.size() != 0)
		{
			transfert.SetFilepath(dir);
		}

		while (!noLoop || (noLoop && (transfert.GetNbTransfertDone() != 1)))
		{
			transfert.Run();
		}
	}
	catch(tools::CException &e)
	{
		std::cerr << e << std::endl;
		return -1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movl %edi, 0xc(%rsp)
movq %rsi, 0x10(%rsp)
leaq 0x10c23(%rip), %rax     # 0x14510
movq %rax, (%rsp)
leaq 0x109d8(%rip), %rsi     # 0x142d0
leaq 0x10c31(%rip), %rdx     # 0x14530
leaq 0x10c4a(%rip), %rcx     # 0x14550
leaq 0x10c63(%rip), %r8      # 0x14570
leaq 0x10bdc(%rip), %r9      # 0x144f0
leaq 0x148(%rsp), %rdi
callq 0x7140
movq 0x106a0(%rip), %rsi     # 0x13fc8
leaq 0x148(%rsp), %rdi
callq 0x75d4
leaq 0x148(%rsp), %rdi
leaq 0xc(%rsp), %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x7250
testb %al, %al
je 0x3a5f
leaq 0xa7e3(%rip), %rsi      # 0xe143
leaq 0x18(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x3c9e
leaq 0xb017(%rip), %rsi      # 0xe990
leaq 0x58(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x3c9e
leaq 0xaffe(%rip), %rsi      # 0xe990
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x3c9e
xorl %r15d, %r15d
leaq 0x148(%rsp), %rbx
leaq 0xa64e(%rip), %r12      # 0xe004
leaq 0x98(%rsp), %r14
leaq 0x18(%rsp), %r13
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x745a
testb %al, %al
je 0x3a8f
movq %rbx, %rdi
movl %ebp, %esi
callq 0x745a
movsbl %al, %eax
addl $-0x64, %eax
rorl %eax
cmpl $0x6, %eax
ja 0x3a58
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x75a2
leaq 0x38(%rsp), %rdi
jmp 0x3a48
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x75a2
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x3340
movq %r14, %rdi
callq 0x3578
movb $0x1, %r15b
jmp 0x3a58
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x75a2
movq %r13, %rdi
movq %r14, %rsi
callq 0x3340
movq %r14, %rdi
callq 0x3578
incl %ebp
jmp 0x39c5
movq 0x10562(%rip), %rsi     # 0x13fc8
leaq 0x148(%rsp), %rdi
callq 0x7644
movq 0x1054e(%rip), %rsi     # 0x13fc8
leaq 0x148(%rsp), %rdi
callq 0x7662
pushq $-0x1
popq %rbx
jmp 0x3baf
leaq 0x78(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x33d0
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x3db4
leaq 0x78(%rsp), %rdi
callq 0x3578
leaq 0x98(%rsp), %rdi
callq 0x4d8a
testb %al, %al
je 0x3b55
movq 0x104f2(%rip), %rdi     # 0x13fc8
leaq 0xa650(%rip), %rsi      # 0xe12d
callq 0x3270
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
cmpq $0x0, 0x60(%rsp)
je 0x3b11
leaq 0x98(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x3ee8
cmpq $0x0, 0x40(%rsp)
je 0x3b2b
leaq 0x98(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x3ef2
leaq 0x98(%rsp), %rbx
pushq $0x1
popq %rbp
testb $0x1, %r15b
je 0x3b49
movq %rbx, %rdi
callq 0x3fa8
cmpl $0x1, %eax
je 0x3b82
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3fb0
jmp 0x3b36
movq 0x1046c(%rip), %rdi     # 0x13fc8
leaq 0xa5b2(%rip), %rsi      # 0xe115
callq 0x3270
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
pushq $-0x1
popq %rbx
jmp 0x3b84
xorl %ebx, %ebx
leaq 0x98(%rsp), %rdi
callq 0x3e70
leaq 0x38(%rsp), %rdi
callq 0x3578
leaq 0x58(%rsp), %rdi
callq 0x3578
leaq 0x18(%rsp), %rdi
callq 0x3578
leaq 0x148(%rsp), %rdi
callq 0x71fc
movl %ebx, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r14
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x3578
jmp 0x3c29
jmp 0x3c23
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3c33
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3c3d
jmp 0x3c00
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3c54
jmp 0x3c0e
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3c47
jmp 0x3c23
jmp 0x3c23
jmp 0x3c23
movq %rdx, %r14
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3e70
jmp 0x3c29
movq %rdx, %r14
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3578
leaq 0x58(%rsp), %rdi
callq 0x3578
leaq 0x18(%rsp), %rdi
callq 0x3578
leaq 0x148(%rsp), %rdi
callq 0x71fc
cmpl $0x1, %r14d
jne 0x3c8e
movq %rbx, %rdi
callq 0x3110
movq 0x10387(%rip), %rdi     # 0x13ff0
movq %rax, %rsi
callq 0x3cd9
movq %rax, %rdi
callq 0x3130
callq 0x34b0
pushq $-0x1
popq %rbx
jmp 0x3bbc
movq %rax, %rbx
callq 0x34b0
movq %rbx, %rdi
callq 0xb830
movq %rax, %rdi
callq 0x3d11