// File: /workspace/github_cpp_makefile_star2_O1/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, 0x70(%rsp)
leaq 0x12b13(%rip), %rax     # 0x16510
movq %rax, (%rsp)
leaq 0x128c8(%rip), %rsi     # 0x162d0
leaq 0x12b21(%rip), %rdx     # 0x16530
leaq 0x12b3a(%rip), %rcx     # 0x16550
leaq 0x12b53(%rip), %r8      # 0x16570
leaq 0x12acc(%rip), %r9      # 0x164f0
leaq 0x148(%rsp), %rdi
callq 0x8042
movq 0x12590(%rip), %rsi     # 0x15fc8
leaq 0x148(%rsp), %rdi
callq 0x86a0
leaq 0x148(%rsp), %rdi
leaq 0xc(%rsp), %rsi
leaq 0x70(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x8256
testb %al, %al
je 0x3bb3
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xc6ca(%rip), %rsi      # 0x10143
leaq 0xc6cf(%rip), %rdx      # 0x1014f
leaq 0x10(%rsp), %rdi
callq 0x3ffc
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xcf19(%rip), %rdx      # 0x109b3
leaq 0x50(%rsp), %rdi
movq %rdx, %rsi
callq 0x3ffc
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xcefc(%rip), %rdx      # 0x109b3
leaq 0x30(%rsp), %rdi
movq %rdx, %rsi
callq 0x3ffc
leaq 0xa8(%rsp), %r12
xorl %r15d, %r15d
leaq 0x148(%rsp), %rbx
leaq 0xc526(%rip), %r13      # 0x10004
leaq 0x98(%rsp), %r14
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x84da
testb %al, %al
je 0x3be5
movq %rbx, %rdi
movl %ebp, %esi
callq 0x84da
movsbl %al, %eax
addl $-0x64, %eax
rorl %eax
cmpl $0x6, %eax
ja 0x3bac
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x866e
leaq 0x30(%rsp), %rdi
jmp 0x3b87
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x866e
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x3370
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x3b6e
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32d0
movb $0x1, %r15b
jmp 0x3bac
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x866e
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x3370
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x3bac
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32d0
incl %ebp
jmp 0x3ae8
movq 0x1240e(%rip), %rsi     # 0x15fc8
leaq 0x148(%rsp), %rdi
callq 0x8778
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0x123f5(%rip), %rsi     # 0x15fc8
leaq 0x148(%rsp), %rdi
callq 0x87ea
jmp 0x3dc2
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x3f6c
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x408c
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x3c35
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x98(%rsp), %rdi
callq 0x54a8
testb %al, %al
je 0x3d00
movq 0x12377(%rip), %rdi     # 0x15fc8
leaq 0xc4d5(%rip), %rsi      # 0x1012d
movl $0x15, %edx
callq 0x3320
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x12355(%rip), %rdi     # 0x15fc8
callq 0x3320
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
cmpq $0x0, 0x58(%rsp)
je 0x3cbc
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x421e
cmpq $0x0, 0x38(%rsp)
je 0x3cd6
leaq 0x98(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x4228
leaq 0x98(%rsp), %rbx
testb $0x1, %r15b
je 0x3cf1
movq %rbx, %rdi
callq 0x42fe
cmpl $0x1, %eax
je 0x3d5f
movq %rbx, %rdi
movl $0x1, %esi
callq 0x4306
jmp 0x3cde
movq 0x122c1(%rip), %rdi     # 0x15fc8
leaq 0xc407(%rip), %rsi      # 0x10115
movl $0x17, %edx
callq 0x3320
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x1229f(%rip), %rdi     # 0x15fc8
callq 0x3320
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x31d0
jmp 0x3d61
xorl %ebx, %ebx
leaq 0x98(%rsp), %rdi
callq 0x4186
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3d8a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x3da6
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3dc2
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x148(%rsp), %rdi
callq 0x81b0
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
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x3e4f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x3e4f
jmp 0x3e49
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3e6b
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3e87
jmp 0x3e24
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3eb0
movq %rdx, %r14
movq %rax, %rbx
jmp 0x3ea3
jmp 0x3e49
jmp 0x3e49
jmp 0x3e49
jmp 0x3e34
movq %rdx, %r14
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x4186
jmp 0x3e4f
movq %rdx, %r14
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3e6b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x3e87
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3ea3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x148(%rsp), %rdi
callq 0x81b0
cmpl $0x1, %r14d
jne 0x3eec
movq %rbx, %rdi
callq 0x3120
movq 0x1212b(%rip), %rdi     # 0x15ff0
movq %rax, %rsi
callq 0x3efc
movq %rax, %rdi
callq 0x3140
callq 0x34d0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3dcf
movq %rax, %rbx
callq 0x34d0
movq %rbx, %rdi
callq 0xcdb0
movq %rax, %rdi
callq 0x3f60