// File: /workspace/github_cpp_makefile_star2_O3/BUSEC[P]RPKI_Downgrade_Detector/cli.cpp
// Function: main
int main(int argc, char* argv[]){

	bool U2I = false;

	if (argc == 5 ){ 
		if( string(argv[1]) == "-U2I" ){
			U2I = true;
		} else{
			cout<<"detector <old file> <new file> <outputfile>"<<endl; return 0; 
		}	
	} else if (argc != 4){ cout<<"detector <old file> <new file> <outputfile>"<<endl; return 0; }

	string oldFilepath = string(argv[1]);
	string newFilepath = string(argv[2]);
	string outputFilepath = string(argv[3]);

	vector<ROA*> oldROAs;
	vector<ROA*> newROAs;

	int success = readScanROAFile(&oldROAs, &oldFilepath);
	if (!success) { return 1; cout<<"Failed to load old roas :"<<oldFilepath<<endl;}

	success = readScanROAFile(&newROAs, &newFilepath);
	if (!success) { return 1; cout<<"Failed to load new roas :"<<newFilepath<<endl;}
	
	ofstream outputFile(outputFilepath.c_str());

	OutputDowngrades(&oldROAs, &newROAs, &outputFile, U2I);

	cout<<"finished sucessfully"<<endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, %r14
movl %edi, %ebx
cmpl $0x5, %edi
jne 0x4705
movq 0x8(%r14), %rsi
leaq 0x98(%rsp), %r15
leaq 0x38(%rsp), %rdx
movq %r15, %rdi
callq 0x59fc
leaq 0x3abd(%rip), %rsi      # 0x814b
movq %r15, %rdi
callq 0x20a0
movl %eax, %ebp
movq (%r15), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x46b8
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2240
testl %ebp, %ebp
je 0x470a
movq 0x7915(%rip), %rbx      # 0xbfd8
leaq 0x3a86(%rip), %rsi      # 0x8150
movl $0x2b, %edx
movq %rbx, %rdi
callq 0x2280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
xorl %ebp, %ebp
jmp 0x48ca
cmpl $0x4, %ebx
jne 0x46bc
movq 0x8(%r14), %rsi
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x59fc
movq 0x10(%r14), %rsi
leaq 0x78(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x59fc
movq 0x18(%r14), %rsi
leaq 0x58(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x59fc
xorl %eax, %eax
leaq 0x20(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rsp)
movaps %xmm0, (%rsp)
leaq 0x38(%rsp), %rsi
callq 0x40b9
movl $0x1, %ebp
testl %eax, %eax
je 0x4846
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0x40b9
testl %eax, %eax
je 0x4846
movq 0x58(%rsp), %rsi
leaq 0x98(%rsp), %rdi
movl $0x10, %edx
callq 0x2260
xorl %ecx, %ecx
cmpl $0x5, %ebx
sete %cl
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
leaq 0x98(%rsp), %rdx
callq 0x3912
movq 0x780b(%rip), %rbx      # 0xbfd8
leaq 0x39a8(%rip), %rsi      # 0x817c
movl $0x14, %edx
movq %rbx, %rdi
callq 0x2280
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0x77d9(%rip), %rdi      # 0xbfd8
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x77b5(%rip), %rax      # 0xbfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xa0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x98(%rsp,%rcx)
callq 0x21e0
leaq 0x190(%rsp), %rdi
callq 0x20b0
xorl %ebp, %ebp
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x485c
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4873
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x488e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48af
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48ca
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
movl %ebp, %eax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x48e6
movq %rax, %rbx
jmp 0x4943
movq %rax, %rbx
jmp 0x4964
movq %rax, %rbx
jmp 0x48fb
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x22e0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4911
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4928
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4943
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4964
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x497f
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
movq %rbx, %rdi
callq 0x2360