// File: /workspace/github_cpp_makefile_star2_O2/mshabbirhasan[P]ups-indel/src/ups_compare_uvcf_files.cpp
// Function: main
int main(int argc, char const ** argv){
    if (argc != 4){
        std::cerr << "USAGE: ups_compare_uvcf_files FIRST_UVCF_FILE.UVCF SECOND_UVCF_FILE.UVCF OUTPUT_FILE_NAME\n";
        return 1;
    }

	string firstUVCF_line, secondUVCF_line;

    ifstream firstUVCFFile(argv[1]); //first uvcf file
    ifstream secondUVCFFile(argv[2]); //second uvcf file
    ofstream outputFile(argv[3]); //output file

    vector<string> first;
    vector<string> second;

    if (firstUVCFFile.is_open()){
        while (getline(firstUVCFFile, firstUVCF_line)){
			if(firstUVCF_line.at(0)!='#' && firstUVCF_line.at(0)!='\n'){
				vector<string> tokens = split(firstUVCF_line, '\t');
                string value = tokens.at(7); // UPS-Coordinate column

                first.push_back(value);
			}
        }
        firstUVCFFile.close();
    }
    else{
        std::cerr << "ERROR: Can't open the first input file: "<<argv[1]<<".\n";
        return 1;
    }

    if(secondUVCFFile.is_open()){
        while (getline(secondUVCFFile, secondUVCF_line)){
			if(secondUVCF_line.at(0)!='#' && secondUVCF_line.at(0)!='\n'){
				vector<string> tokens = split(secondUVCF_line, '\t');
                string value = tokens.at(7); // UPS-Coordinate column

                second.push_back(value);
			}
        }
        secondUVCFFile.close();
    }
    else{
        std::cerr << "ERROR: Can't open the second input file: "<<argv[2]<<".\n";
        return 1;
    }

    vector<string> intersection;
    vector<string> in_first_not_in_second;
    vector<string> in_second_not_in_first;

    sort(first.begin(), first.end());
    sort(second.begin(), second.end());

    set_intersection(first.begin(), first.end(), second.begin(), second.end(), back_inserter(intersection));
    set_difference(first.begin(), first.end(), second.begin(), second.end(), back_inserter(in_first_not_in_second));
    set_difference(second.begin(), second.end(), first.begin(), first.end(), back_inserter(in_second_not_in_first));


    if(outputFile.is_open()){
        outputFile<<"Number of Common Indels in "<<argv[1]<<" and "<<argv[2]<<" : "<<intersection.size()<<endl;
        outputFile<<"Number of Indels in "<<argv[1]<<" but not in "<<argv[2]<<" : "<<in_first_not_in_second.size()<<endl;
        outputFile<<"Number of Indels in "<<argv[2]<<" but not in "<<argv[1]<<" : "<<in_second_not_in_first.size()<<endl;

        outputFile.close();
    }
    else{
        std::cerr << "ERROR: Can't open the output file: "<<argv[3]<<".\n";
        return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x708, %rsp            # imm = 0x708
cmpl $0x4, %edi
jne 0x28a1
movq %rsi, %rbx
leaq -0x108(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0xe8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %edx, %edx
movb %dl, (%rax)
movb %dl, (%rcx)
movq 0x8(%rsi), %rsi
leaq -0x728(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2270
movq 0x10(%rbx), %rsi
leaq -0x520(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2270
movq 0x18(%rbx), %rsi
leaq -0x318(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x21a0
leaq 0x8(%rbx), %rax
movq %rax, -0x30(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
andq $0x0, -0x60(%rbp)
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
leaq -0x6b0(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x28bc
movq %rbx, -0xd8(%rbp)
leaq 0x10(%rbx), %rax
movq %rax, -0x38(%rbp)
leaq -0x728(%rbp), %r14
leaq -0x118(%rbp), %r15
leaq -0x90(%rbp), %r12
leaq -0xb0(%rbp), %r13
leaq -0x70(%rbp), %rbx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2040
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x28d4
movq %r15, %rdi
xorl %esi, %esi
callq 0x2290
cmpb $0x23, (%rax)
je 0x2825
movq %r15, %rdi
xorl %esi, %esi
callq 0x2290
cmpb $0xa, (%rax)
je 0x2825
movq %r12, %rdi
movq %r15, %rsi
pushq $0x9
popq %rdx
callq 0x24a3
movq %r12, %rdi
pushq $0x7
popq %rsi
callq 0x2e5c
movq %r13, %rdi
movq %rax, %rsi
callq 0x21d0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2d70
movq %r13, %rdi
callq 0x20c0
movq %r12, %rdi
callq 0x2e00
jmp 0x2825
movq 0x3748(%rip), %rdi      # 0x5ff0
leaq 0x1755(%rip), %rsi      # 0x4004
callq 0x2170
pushq $0x1
popq %rbx
jmp 0x2c99
movq 0x372d(%rip), %rdi      # 0x5ff0
leaq 0x1795(%rip), %rsi      # 0x405f
callq 0x2170
jmp 0x29ab
leaq -0x728(%rbp), %rdi
callq 0x2050
leaq -0x4a8(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x2990
leaq -0x520(%rbp), %r14
leaq -0xf8(%rbp), %r15
leaq -0x90(%rbp), %r12
leaq -0xb0(%rbp), %rbx
leaq -0x50(%rbp), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x2040
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x29d1
movq %r15, %rdi
xorl %esi, %esi
callq 0x2290
cmpb $0x23, (%rax)
je 0x2914
movq %r15, %rdi
xorl %esi, %esi
callq 0x2290
cmpb $0xa, (%rax)
je 0x2914
movq %r12, %rdi
movq %r15, %rsi
pushq $0x9
popq %rdx
callq 0x24a3
movq %r12, %rdi
pushq $0x7
popq %rsi
callq 0x2e5c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x21d0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2d70
movq %rbx, %rdi
callq 0x20c0
movq %r12, %rdi
callq 0x2e00
jmp 0x2914
movq 0x3659(%rip), %rdi      # 0x5ff0
leaq 0x16ed(%rip), %rsi      # 0x408b
callq 0x2170
movq -0x38(%rbp), %rcx
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x16c7(%rip), %rsi      # 0x4088
movq %rax, %rdi
callq 0x2170
pushq $0x1
popq %rbx
jmp 0x2c4b
leaq -0x520(%rbp), %rdi
callq 0x2050
andq $0x0, -0xa0(%rbp)
xorps %xmm0, %xmm0
andq $0x0, -0x80(%rbp)
movaps %xmm0, -0xb0(%rbp)
andq $0x0, -0xc0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xd0(%rbp)
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x317d
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x317d
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq -0xb0(%rbp), %r8
callq 0x3937
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq -0x90(%rbp), %r8
callq 0x39a9
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rcx
leaq -0xd0(%rbp), %r8
callq 0x39a9
leaq -0x2a8(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x2bef
leaq 0x1622(%rip), %rsi      # 0x40b5
leaq -0x318(%rbp), %rdi
callq 0x2170
movq -0x30(%rbp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x161c(%rip), %rsi      # 0x40d1
movq %rax, %rdi
callq 0x2170
movq -0x38(%rbp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1604(%rip), %rsi      # 0x40d7
movq %rax, %rdi
callq 0x2170
movq -0xa8(%rbp), %rsi
subq -0xb0(%rbp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20d0
leaq 0x15d7(%rip), %rsi      # 0x40db
leaq -0x318(%rbp), %rdi
callq 0x2170
movq -0x30(%rbp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x15ca(%rip), %rsi      # 0x40f0
movq %rax, %rdi
callq 0x2170
movq -0x38(%rbp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1593(%rip), %rsi      # 0x40d7
movq %rax, %rdi
callq 0x2170
movq -0x88(%rbp), %rsi
subq -0x90(%rbp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20d0
leaq 0x1566(%rip), %rsi      # 0x40db
leaq -0x318(%rbp), %rdi
callq 0x2170
movq -0x38(%rbp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1559(%rip), %rsi      # 0x40f0
movq %rax, %rdi
callq 0x2170
movq -0x30(%rbp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1522(%rip), %rsi      # 0x40d7
movq %rax, %rdi
callq 0x2170
movq -0xc8(%rbp), %rsi
subq -0xd0(%rbp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20d0
xorl %ebx, %ebx
leaq -0x318(%rbp), %rdi
callq 0x21e0
jmp 0x2c27
movq 0x33fa(%rip), %rdi      # 0x5ff0
leaq 0x1500(%rip), %rsi      # 0x40fd
callq 0x2170
movq -0xd8(%rbp), %rcx
movq 0x18(%rcx), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x146c(%rip), %rsi      # 0x4088
movq %rax, %rdi
callq 0x2170
pushq $0x1
popq %rbx
leaq -0xd0(%rbp), %rdi
callq 0x2e00
leaq -0x90(%rbp), %rdi
callq 0x2e00
leaq -0xb0(%rbp), %rdi
callq 0x2e00
leaq -0x50(%rbp), %rdi
callq 0x2e00
leaq -0x70(%rbp), %rdi
callq 0x2e00
leaq -0x318(%rbp), %rdi
callq 0x2200
leaq -0x520(%rbp), %rdi
callq 0x2070
leaq -0x728(%rbp), %rdi
callq 0x2070
leaq -0xf8(%rbp), %rdi
callq 0x20c0
leaq -0x118(%rbp), %rdi
callq 0x20c0
movl %ebx, %eax
addq $0x708, %rsp            # imm = 0x708
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2d38
movq %rax, %rbx
jmp 0x2d44
movq %rax, %rbx
jmp 0x2d50
jmp 0x2d17
jmp 0x2ccf
jmp 0x2d17
jmp 0x2d04
jmp 0x2d17
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20c0
jmp 0x2d07
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x2e00
leaq -0x90(%rbp), %rdi
callq 0x2e00
leaq -0xb0(%rbp), %rdi
jmp 0x2d0e
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x2e00
jmp 0x2d1a
jmp 0x2d17
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2e00
leaq -0x70(%rbp), %rdi
callq 0x2e00
leaq -0x318(%rbp), %rdi
callq 0x2200
leaq -0x520(%rbp), %rdi
callq 0x2070
leaq -0x728(%rbp), %rdi
callq 0x2070
leaq -0xf8(%rbp), %rdi
callq 0x20c0
leaq -0x118(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2260