// File: allasandeep[P]LocationBoundaryFinder/prog1.cc
// Function: main
int main(int argc, char* argv[])
{
	//File Stream object
	ifstream is;
	PGconn *db; 
	db = conn();
	if(argc > 1)
	{
		for(int i = 1; i < argc; i++)
		{
			//Calling open_files function by passing input file stream objects as arguments.
			openFiles(is,argv[i]); 
			string str(argv[i]);
			string toFind = ".RTC";
			//Finding whether the file contains the bnd extension
			size_t found = str.find(toFind);
			//If the file contains bnd extension go to processBoundFiles or go to processNameFiles
			if(found != string::npos)
				processNameFiles(is,db);//Calling processBoundFiles function by passing input file stream objects as arguments.
			//Calling closeFiles function by passing input file stream objects as arguments.
			closeFiles(is);
		}

		for(int i = 1; i < argc; i++)
		{
			//Calling open_files function by passing input file stream objects as arguments.
			openFiles(is,argv[i]); 
			string str(argv[i]);
			string toFind = ".bnd";
			//Finding whether the file contains the bnd extension
			size_t found = str.find(toFind);
			//If the file contains bnd extension go to processBoundFiles or go to processNameFiles
			if(found != string::npos)
				processBoundFiles(is,db);//Calling processBoundFiles function by passing input file stream objects as arguments.
			//Calling closeFiles function by passing input file stream objects as arguments.
			closeFiles(is);
		}
	}
	else
	{
		cerr<<"**Note: Please input data files as commad line arguments to insert data into database!"<<endl;
		return 0;
	}

	cout<<"Data Successfully inserted into the database!"<<endl;
	PQfinish(db);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x20f0
callq 0x2560
movq %rax, -0x2f8(%rbp)
jmp 0x2623
movq -0x2f8(%rbp), %rax
movq %rax, -0x220(%rbp)
cmpl $0x1, -0x8(%rbp)
jle 0x29b6
movl $0x1, -0x230(%rbp)
movl -0x230(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2805
movq -0x10(%rbp), %rax
movslq -0x230(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x218(%rbp), %rdi
callq 0x2a80
jmp 0x2671
movq -0x10(%rbp), %rax
movslq -0x230(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x308(%rbp)
leaq -0x251(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x22e0
movq -0x308(%rbp), %rsi
movq -0x300(%rbp), %rdx
leaq -0x250(%rbp), %rdi
callq 0x3c00
jmp 0x26b6
leaq -0x251(%rbp), %rdi
callq 0x23a0
leaq -0x279(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x22e0
movq -0x310(%rbp), %rdx
leaq 0x29eb(%rip), %rsi      # 0x50ce
leaq -0x278(%rbp), %rdi
callq 0x3c00
jmp 0x26f1
leaq -0x279(%rbp), %rdi
callq 0x23a0
leaq -0x250(%rbp), %rdi
leaq -0x278(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x21e0
movq %rax, -0x288(%rbp)
cmpq $-0x1, -0x288(%rbp)
je 0x27ba
movq -0x220(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x2b00
jmp 0x273e
jmp 0x27ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x2a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x251(%rbp), %rdi
callq 0x23a0
jmp 0x2a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x279(%rbp), %rdi
callq 0x23a0
jmp 0x27f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x2240
jmp 0x27f4
leaq -0x218(%rbp), %rdi
callq 0x3630
jmp 0x27c8
leaq -0x278(%rbp), %rdi
callq 0x2240
leaq -0x250(%rbp), %rdi
callq 0x2240
movl -0x230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x230(%rbp)
jmp 0x2645
leaq -0x250(%rbp), %rdi
callq 0x2240
jmp 0x2a62
movl $0x1, -0x28c(%rbp)
movl -0x28c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x29b4
movq -0x10(%rbp), %rax
movslq -0x28c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x218(%rbp), %rdi
callq 0x2a80
jmp 0x283b
movq -0x10(%rbp), %rax
movslq -0x28c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x320(%rbp)
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x22e0
movq -0x320(%rbp), %rsi
movq -0x318(%rbp), %rdx
leaq -0x2b0(%rbp), %rdi
callq 0x3c00
jmp 0x2880
leaq -0x2b1(%rbp), %rdi
callq 0x23a0
leaq -0x2d9(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0x22e0
movq -0x328(%rbp), %rdx
leaq 0x2826(%rip), %rsi      # 0x50d3
leaq -0x2d8(%rbp), %rdi
callq 0x3c00
jmp 0x28bb
leaq -0x2d9(%rbp), %rdi
callq 0x23a0
leaq -0x2b0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x21e0
movq %rax, -0x2e8(%rbp)
cmpq $-0x1, -0x2e8(%rbp)
je 0x2969
movq -0x220(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x3650
jmp 0x2904
jmp 0x2969
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x2b1(%rbp), %rdi
callq 0x23a0
jmp 0x2a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x2d9(%rbp), %rdi
callq 0x23a0
jmp 0x29a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x2240
jmp 0x29a3
leaq -0x218(%rbp), %rdi
callq 0x3630
jmp 0x2977
leaq -0x2d8(%rbp), %rdi
callq 0x2240
leaq -0x2b0(%rbp), %rdi
callq 0x2240
movl -0x28c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28c(%rbp)
jmp 0x280f
leaq -0x2b0(%rbp), %rdi
callq 0x2240
jmp 0x2a62
jmp 0x29fa
movq 0x4633(%rip), %rdi      # 0x6ff0
leaq 0x2714(%rip), %rsi      # 0x50d8
callq 0x2190
movq %rax, -0x330(%rbp)
jmp 0x29d2
movq -0x330(%rbp), %rdi
movq 0x4600(%rip), %rsi      # 0x6fe0
callq 0x2320
jmp 0x29e7
movl $0x0, -0x4(%rbp)
movl $0x1, -0x2ec(%rbp)
jmp 0x2a4a
movq 0x45c7(%rip), %rdi      # 0x6fc8
leaq 0x2727(%rip), %rsi      # 0x512f
callq 0x2190
movq %rax, -0x338(%rbp)
jmp 0x2a16
movq -0x338(%rbp), %rdi
movq 0x45bc(%rip), %rsi      # 0x6fe0
callq 0x2320
jmp 0x2a2b
movq -0x220(%rbp), %rdi
callq 0x2260
jmp 0x2a39
movl $0x0, -0x4(%rbp)
movl $0x1, -0x2ec(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x2040
movl -0x4(%rbp), %eax
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x2040
movq -0x228(%rbp), %rdi
callq 0x21f0
nopw (%rax,%rax)