// File: /workspace/github_cpp_makefile_star2_O1/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 0x494f
movq 0x8(%r14), %rsi
leaq 0x98(%rsp), %r15
leaq 0x38(%rsp), %rdx
movq %r15, %rdi
callq 0x5c7c
leaq 0x4873(%rip), %rsi      # 0x914b
movq %r15, %rdi
callq 0x20a0
movl %eax, %ebp
movq (%r15), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x4902
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2240
testl %ebp, %ebp
je 0x4954
movq 0x86cb(%rip), %rbx      # 0xcfd8
leaq 0x483c(%rip), %rsi      # 0x9150
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 0x4b14
cmpl $0x4, %ebx
jne 0x4906
movq 0x8(%r14), %rsi
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x5c7c
movq 0x10(%r14), %rsi
leaq 0x78(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x5c7c
movq 0x18(%r14), %rsi
leaq 0x58(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x5c7c
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 0x42df
movl $0x1, %ebp
testl %eax, %eax
je 0x4a90
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0x42df
testl %eax, %eax
je 0x4a90
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 0x3b0a
movq 0x85c1(%rip), %rbx      # 0xcfd8
leaq 0x475e(%rip), %rsi      # 0x917c
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 0x858f(%rip), %rdi      # 0xcfd8
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x856b(%rip), %rax      # 0xcfc8
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 0x4aa6
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4abd
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4ad8
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4af9
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4b14
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 0x4b30
movq %rax, %rbx
jmp 0x4b8d
movq %rax, %rbx
jmp 0x4bae
movq %rax, %rbx
jmp 0x4b45
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x22e0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4b5b
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4b72
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2240
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4b8d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4bae
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4bc9
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
movq %rbx, %rdi
callq 0x2360