// File: BUSEC[P]RPKI_Downgrade_Detector/cli.cpp
// Function: readScanROAFile(std::vector<ROA*, std::allocator<ROA*>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
int readScanROAFile(vector<ROA*>* ROAs, string* filepath){

	ifstream f;
	f.open(*filepath);
	if ( f.is_open() ) {
		string line;

		while( getline(f, line) ){
			string path;
			string datetime;
			int as = 0;

			istringstream iss(line);
			int i = 0;
			do {
	
				if ( i == 0 ) iss>>path;
				if ( i == 1 ) iss>>datetime;
				if ( i == 2 ) iss>>as;

				if ( i > 2 ) {
					string prefix;
					iss>>prefix;

					// Ignore ipv6 prefixes (ipv6 prefixes contain ':' )
					// and
					// Ignore empty strings
					if ( prefix.find(":") == std::string::npos && prefix != "") {
						string formatStr = "%d.%d.%d.%d/%d-%d";
						int ip1, ip2, ip3, ip4, prefixlen, maxlen;

						sscanf(prefix.c_str(), formatStr.c_str(), &ip1, &ip2, &ip3, &ip4, &prefixlen, &maxlen);

						ROA* roa = new ROA(as, IPPrefix(IPAddr(ip1,ip2,ip3,ip4), prefixlen), maxlen, path );
						ROAs->push_back(roa);
					}
				}

				i++;
			} while(iss);
			assert(i > 3); // Something is wrong if we didn't read in atleast for tokens from this line (bad format)

		}
		f.close();
	} else return 0;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x530, %rsp            # imm = 0x530
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x220(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
callq 0x3300
movq -0x4c8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x8, %edx
callq 0x3210
jmp 0x502d
leaq -0x220(%rbp), %rdi
callq 0x33b0
movb %al, -0x4c9(%rbp)
jmp 0x5041
movb -0x4c9(%rbp), %al
testb $0x1, %al
jne 0x5050
jmp 0x5568
leaq -0x250(%rbp), %rdi
callq 0x3370
leaq -0x220(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x3070
movq %rax, -0x4d8(%rbp)
jmp 0x5078
movq -0x4d8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3330
movb %al, -0x4d9(%rbp)
jmp 0x5096
movb -0x4d9(%rbp), %al
testb $0x1, %al
jne 0x50a5
jmp 0x553e
leaq -0x270(%rbp), %rdi
callq 0x3370
leaq -0x290(%rbp), %rdi
callq 0x3370
movl $0x0, -0x294(%rbp)
leaq -0x418(%rbp), %rdi
leaq -0x250(%rbp), %rsi
movl $0x8, %edx
callq 0x33e0
jmp 0x50e1
movl $0x0, -0x41c(%rbp)
cmpl $0x0, -0x41c(%rbp)
jne 0x5167
leaq -0x418(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x3340
jmp 0x5109
jmp 0x5167
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x55a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x555a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5518
cmpl $0x1, -0x41c(%rbp)
jne 0x5187
leaq -0x418(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x3340
jmp 0x5185
jmp 0x5187
cmpl $0x2, -0x41c(%rbp)
jne 0x51a7
leaq -0x418(%rbp), %rdi
leaq -0x294(%rbp), %rsi
callq 0x3160
jmp 0x51a5
jmp 0x51a7
cmpl $0x2, -0x41c(%rbp)
jle 0x5486
leaq -0x440(%rbp), %rdi
movq %rdi, -0x4e8(%rbp)
callq 0x3370
movq -0x4e8(%rbp), %rsi
leaq -0x418(%rbp), %rdi
callq 0x3340
jmp 0x51dc
leaq -0x440(%rbp), %rdi
leaq 0xeedc(%rip), %rsi      # 0x140c6
xorl %eax, %eax
movl %eax, %edx
callq 0x3450
cmpq $-0x1, %rax
jne 0x5467
leaq 0xf117(%rip), %rsi      # 0x1431b
leaq -0x440(%rbp), %rdi
callq 0x7d80
movb %al, -0x4e9(%rbp)
jmp 0x5218
movb -0x4e9(%rbp), %al
testb $0x1, %al
jne 0x5227
jmp 0x5467
leaq -0x461(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
callq 0x3410
movq -0x4f8(%rbp), %rdx
leaq 0xee9c(%rip), %rsi      # 0x140e4
leaq -0x460(%rbp), %rdi
callq 0x7db0
jmp 0x5256
leaq -0x461(%rbp), %rdi
callq 0x32c0
leaq -0x440(%rbp), %rdi
callq 0x30e0
movq %rax, -0x508(%rbp)
leaq -0x460(%rbp), %rdi
callq 0x30e0
movq -0x508(%rbp), %rdi
movq %rax, %rsi
movq %rsp, %rax
leaq -0x47c(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x478(%rbp), %rcx
movq %rcx, (%rax)
xorl %eax, %eax
leaq -0x468(%rbp), %rdx
leaq -0x46c(%rbp), %rcx
leaq -0x470(%rbp), %r8
leaq -0x474(%rbp), %r9
callq 0x3240
movl $0x30, %edi
callq 0x3270
movq %rax, -0x500(%rbp)
jmp 0x52d9
movb $0x1, -0x4b9(%rbp)
movl -0x294(%rbp), %eax
movl %eax, -0x50c(%rbp)
movl -0x468(%rbp), %esi
movl -0x46c(%rbp), %edx
movl -0x470(%rbp), %ecx
movl -0x474(%rbp), %r8d
leaq -0x494(%rbp), %rdi
callq 0x7e60
jmp 0x5313
movl -0x478(%rbp), %edx
leaq -0x490(%rbp), %rdi
leaq -0x494(%rbp), %rsi
callq 0x7eb0
jmp 0x532e
movl -0x47c(%rbp), %eax
movl %eax, -0x510(%rbp)
leaq -0x4b8(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x30f0
jmp 0x534f
movl -0x510(%rbp), %ecx
movl -0x50c(%rbp), %esi
movq -0x500(%rbp), %rdi
leaq -0x490(%rbp), %rdx
leaq -0x4b8(%rbp), %r8
callq 0x7ef0
jmp 0x5377
movb $0x0, -0x4b9(%rbp)
leaq -0x4b8(%rbp), %rdi
callq 0x3170
movq -0x500(%rbp), %rax
movq %rax, -0x488(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x488(%rbp), %rsi
callq 0x6d30
jmp 0x53aa
leaq -0x460(%rbp), %rdi
callq 0x3170
jmp 0x5467
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5475
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x461(%rbp), %rdi
callq 0x32c0
jmp 0x5475
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5459
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x543b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x4b8(%rbp), %rdi
callq 0x3170
testb $0x1, -0x4b9(%rbp)
jne 0x5446
jmp 0x5457
movq -0x500(%rbp), %rdi
movl $0x30, %esi
callq 0x3280
jmp 0x5459
leaq -0x460(%rbp), %rdi
callq 0x3170
jmp 0x5475
leaq -0x440(%rbp), %rdi
callq 0x3170
jmp 0x5486
leaq -0x440(%rbp), %rdi
callq 0x3170
jmp 0x5518
movl -0x41c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x41c(%rbp)
movq -0x418(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x418(%rbp,%rax), %rdi
callq 0x3330
movb %al, -0x511(%rbp)
jmp 0x54b5
movb -0x511(%rbp), %al
testb $0x1, %al
jne 0x50eb
jmp 0x54c5
cmpl $0x3, -0x41c(%rbp)
jle 0x54d0
jmp 0x54ef
leaq 0xec1f(%rip), %rdi      # 0x140f6
leaq 0xec1e(%rip), %rsi      # 0x140fc
movl $0x39, %edx
leaq 0xec1a(%rip), %rcx      # 0x14104
callq 0x3180
leaq -0x418(%rbp), %rdi
callq 0x3110
leaq -0x290(%rbp), %rdi
callq 0x3170
leaq -0x270(%rbp), %rdi
callq 0x3170
jmp 0x505c
leaq -0x418(%rbp), %rdi
callq 0x3110
leaq -0x290(%rbp), %rdi
callq 0x3170
leaq -0x270(%rbp), %rdi
callq 0x3170
jmp 0x555a
leaq -0x220(%rbp), %rdi
callq 0x3080
jmp 0x554c
leaq -0x250(%rbp), %rdi
callq 0x3170
jmp 0x557b
leaq -0x250(%rbp), %rdi
callq 0x3170
jmp 0x55a4
movl $0x0, -0x4(%rbp)
movl $0x1, -0x4c0(%rbp)
jmp 0x558c
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4c0(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x3090
movl -0x4(%rbp), %eax
addq $0x530, %rsp            # imm = 0x530
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x3090
movq -0x228(%rbp), %rdi
callq 0x3400
nopl (%rax)