// File: 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
subq $0x9b0, %rsp            # imm = 0x9B0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x4, -0x8(%rbp)
je 0x2b4e
movq 0x74ba(%rip), %rdi      # 0x9ff0
leaq 0x44c7(%rip), %rsi      # 0x7004
callq 0x21a0
movl $0x1, -0x4(%rbp)
jmp 0x36dc
leaq -0x30(%rbp), %rdi
callq 0x2220
leaq -0x50(%rbp), %rdi
callq 0x2220
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x258(%rbp), %rdi
movl $0x8, %edx
callq 0x22d0
jmp 0x2b7b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0x470(%rbp), %rdi
movl $0x8, %edx
callq 0x22d0
jmp 0x2b96
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x670(%rbp), %rdi
movl $0x10, %edx
callq 0x21e0
jmp 0x2bb1
leaq -0x688(%rbp), %rdi
callq 0x3880
leaq -0x6a0(%rbp), %rdi
callq 0x3880
leaq -0x258(%rbp), %rdi
callq 0x22a0
movb %al, -0x811(%rbp)
jmp 0x2bdd
movb -0x811(%rbp), %al
testb $0x1, %al
jne 0x2bec
jmp 0x2db2
jmp 0x2bee
leaq -0x258(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2040
movq %rax, -0x820(%rbp)
jmp 0x2c07
movq -0x820(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2200
movb %al, -0x821(%rbp)
jmp 0x2c25
movb -0x821(%rbp), %al
testb $0x1, %al
jne 0x2c34
jmp 0x2da2
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x22f0
movq %rax, -0x830(%rbp)
jmp 0x2c4a
movq -0x830(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
je 0x2d9d
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x22f0
movq %rax, -0x838(%rbp)
jmp 0x2c73
movq -0x838(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x2d9d
leaq -0x6b8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x9, %edx
callq 0x2580
jmp 0x2c9d
leaq -0x6b8(%rbp), %rdi
movl $0x7, %esi
callq 0x39c0
movq %rax, -0x840(%rbp)
jmp 0x2cb7
movq -0x840(%rbp), %rsi
leaq -0x6d8(%rbp), %rdi
callq 0x20b0
jmp 0x2ccc
leaq -0x688(%rbp), %rdi
leaq -0x6d8(%rbp), %rsi
callq 0x3720
jmp 0x2ce1
leaq -0x6d8(%rbp), %rdi
callq 0x20f0
leaq -0x6b8(%rbp), %rdi
callq 0x38a0
jmp 0x2d9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x36c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x36bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x36b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x368c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x2d8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x6d8(%rbp), %rdi
callq 0x20f0
leaq -0x6b8(%rbp), %rdi
callq 0x38a0
jmp 0x368c
jmp 0x2bee
leaq -0x258(%rbp), %rdi
callq 0x2050
jmp 0x2db0
jmp 0x2e16
movq 0x7237(%rip), %rdi      # 0x9ff0
leaq 0x429f(%rip), %rsi      # 0x705f
callq 0x21a0
movq %rax, -0x848(%rbp)
jmp 0x2dce
movq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x21a0
movq %rax, -0x850(%rbp)
jmp 0x2deb
movq -0x850(%rbp), %rdi
leaq 0x428f(%rip), %rsi      # 0x7088
callq 0x21a0
jmp 0x2e00
movl $0x1, -0x4(%rbp)
movl $0x1, -0x6dc(%rbp)
jmp 0x363c
leaq -0x470(%rbp), %rdi
callq 0x22a0
movb %al, -0x851(%rbp)
jmp 0x2e2a
movb -0x851(%rbp), %al
testb $0x1, %al
jne 0x2e39
jmp 0x2fa0
jmp 0x2e3b
leaq -0x470(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2040
movq %rax, -0x860(%rbp)
jmp 0x2e54
movq -0x860(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2200
movb %al, -0x861(%rbp)
jmp 0x2e72
movb -0x861(%rbp), %al
testb $0x1, %al
jne 0x2e81
jmp 0x2f90
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x22f0
movq %rax, -0x870(%rbp)
jmp 0x2e97
movq -0x870(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
je 0x2f8b
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x22f0
movq %rax, -0x878(%rbp)
jmp 0x2ec0
movq -0x878(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x2f8b
leaq -0x6f8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl $0x9, %edx
callq 0x2580
jmp 0x2eea
leaq -0x6f8(%rbp), %rdi
movl $0x7, %esi
callq 0x39c0
movq %rax, -0x880(%rbp)
jmp 0x2f04
movq -0x880(%rbp), %rsi
leaq -0x718(%rbp), %rdi
callq 0x20b0
jmp 0x2f19
leaq -0x6a0(%rbp), %rdi
leaq -0x718(%rbp), %rsi
callq 0x3720
jmp 0x2f2e
leaq -0x718(%rbp), %rdi
callq 0x20f0
leaq -0x6f8(%rbp), %rdi
callq 0x38a0
jmp 0x2f8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x2f7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x718(%rbp), %rdi
callq 0x20f0
leaq -0x6f8(%rbp), %rdi
callq 0x38a0
jmp 0x368c
jmp 0x2e3b
leaq -0x470(%rbp), %rdi
callq 0x2050
jmp 0x2f9e
jmp 0x3004
movq 0x7049(%rip), %rdi      # 0x9ff0
leaq 0x40dd(%rip), %rsi      # 0x708b
callq 0x21a0
movq %rax, -0x888(%rbp)
jmp 0x2fbc
movq -0x888(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21a0
movq %rax, -0x890(%rbp)
jmp 0x2fd9
movq -0x890(%rbp), %rdi
leaq 0x40a1(%rip), %rsi      # 0x7088
callq 0x21a0
jmp 0x2fee
movl $0x1, -0x4(%rbp)
movl $0x1, -0x6dc(%rbp)
jmp 0x363c
leaq -0x730(%rbp), %rdi
callq 0x3880
leaq -0x748(%rbp), %rdi
callq 0x3880
leaq -0x760(%rbp), %rdi
callq 0x3880
leaq -0x688(%rbp), %rdi
movq %rdi, -0x898(%rbp)
callq 0x3a40
movq -0x898(%rbp), %rdi
movq %rax, -0x768(%rbp)
callq 0x3a70
movq %rax, -0x770(%rbp)
movq -0x768(%rbp), %rdi
movq -0x770(%rbp), %rsi
callq 0x3a00
jmp 0x306a
leaq -0x6a0(%rbp), %rdi
movq %rdi, -0x8a0(%rbp)
callq 0x3a40
movq -0x8a0(%rbp), %rdi
movq %rax, -0x778(%rbp)
callq 0x3a70
movq %rax, -0x780(%rbp)
movq -0x778(%rbp), %rdi
movq -0x780(%rbp), %rsi
callq 0x3a00
jmp 0x30ac
leaq -0x688(%rbp), %rdi
movq %rdi, -0x8b8(%rbp)
callq 0x3a40
movq -0x8b8(%rbp), %rdi
movq %rax, -0x788(%rbp)
callq 0x3a70
movq %rax, -0x790(%rbp)
leaq -0x6a0(%rbp), %rdi
movq %rdi, -0x8b0(%rbp)
callq 0x3a40
movq -0x8b0(%rbp), %rdi
movq %rax, -0x798(%rbp)
callq 0x3a70
movq %rax, -0x7a0(%rbp)
leaq -0x730(%rbp), %rdi
callq 0x3b10
movq %rax, -0x8a8(%rbp)
jmp 0x311b
movq -0x8a8(%rbp), %rax
movq %rax, -0x7a8(%rbp)
movq -0x788(%rbp), %rdi
movq -0x790(%rbp), %rsi
movq -0x798(%rbp), %rdx
movq -0x7a0(%rbp), %rcx
movq -0x7a8(%rbp), %r8
callq 0x3aa0
movq %rax, -0x8c0(%rbp)
jmp 0x315a
movq -0x8c0(%rbp), %rax
movq %rax, -0x7b0(%rbp)
leaq -0x688(%rbp), %rdi
movq %rdi, -0x8d8(%rbp)
callq 0x3a40
movq -0x8d8(%rbp), %rdi
movq %rax, -0x7b8(%rbp)
callq 0x3a70
movq %rax, -0x7c0(%rbp)
leaq -0x6a0(%rbp), %rdi
movq %rdi, -0x8d0(%rbp)
callq 0x3a40
movq -0x8d0(%rbp), %rdi
movq %rax, -0x7c8(%rbp)
callq 0x3a70
movq %rax, -0x7d0(%rbp)
leaq -0x748(%rbp), %rdi
callq 0x3b10
movq %rax, -0x8c8(%rbp)
jmp 0x31d7
movq -0x8c8(%rbp), %rax
movq %rax, -0x7d8(%rbp)
movq -0x7b8(%rbp), %rdi
movq -0x7c0(%rbp), %rsi
movq -0x7c8(%rbp), %rdx
movq -0x7d0(%rbp), %rcx
movq -0x7d8(%rbp), %r8
callq 0x3b40
movq %rax, -0x8e0(%rbp)
jmp 0x3216
movq -0x8e0(%rbp), %rax
movq %rax, -0x7e0(%rbp)
leaq -0x6a0(%rbp), %rdi
movq %rdi, -0x8f8(%rbp)
callq 0x3a40
movq -0x8f8(%rbp), %rdi
movq %rax, -0x7e8(%rbp)
callq 0x3a70
movq %rax, -0x7f0(%rbp)
leaq -0x688(%rbp), %rdi
movq %rdi, -0x8f0(%rbp)
callq 0x3a40
movq -0x8f0(%rbp), %rdi
movq %rax, -0x7f8(%rbp)
callq 0x3a70
movq %rax, -0x800(%rbp)
leaq -0x760(%rbp), %rdi
callq 0x3b10
movq %rax, -0x8e8(%rbp)
jmp 0x3293
movq -0x8e8(%rbp), %rax
movq %rax, -0x808(%rbp)
movq -0x7e8(%rbp), %rdi
movq -0x7f0(%rbp), %rsi
movq -0x7f8(%rbp), %rdx
movq -0x800(%rbp), %rcx
movq -0x808(%rbp), %r8
callq 0x3b40
movq %rax, -0x900(%rbp)
jmp 0x32d2
movq -0x900(%rbp), %rax
movq %rax, -0x810(%rbp)
leaq -0x670(%rbp), %rdi
callq 0x2140
movb %al, -0x901(%rbp)
jmp 0x32f4
movb -0x901(%rbp), %al
testb $0x1, %al
jne 0x3303
jmp 0x35a6
leaq 0x3dab(%rip), %rsi      # 0x70b5
leaq -0x670(%rbp), %rdi
callq 0x21a0
movq %rax, -0x910(%rbp)
jmp 0x331f
movq -0x910(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x21a0
movq %rax, -0x918(%rbp)
jmp 0x333c
movq -0x918(%rbp), %rdi
leaq 0x3d87(%rip), %rsi      # 0x70d1
callq 0x21a0
movq %rax, -0x920(%rbp)
jmp 0x3358
movq -0x920(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21a0
movq %rax, -0x928(%rbp)
jmp 0x3375
movq -0x928(%rbp), %rdi
leaq 0x3d54(%rip), %rsi      # 0x70d7
callq 0x21a0
movq %rax, -0x930(%rbp)
jmp 0x3391
leaq -0x730(%rbp), %rdi
callq 0x3bb0
movq -0x930(%rbp), %rdi
movq %rax, %rsi
callq 0x2060
movq %rax, -0x938(%rbp)
jmp 0x33b5
movq -0x938(%rbp), %rdi
movq 0x6c05(%rip), %rsi      # 0x9fc8
callq 0x21d0
jmp 0x33ca
leaq 0x3d0a(%rip), %rsi      # 0x70db
leaq -0x670(%rbp), %rdi
callq 0x21a0
movq %rax, -0x940(%rbp)
jmp 0x33e6
movq -0x940(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x21a0
movq %rax, -0x948(%rbp)
jmp 0x3403
movq -0x948(%rbp), %rdi
leaq 0x3cdf(%rip), %rsi      # 0x70f0
callq 0x21a0
movq %rax, -0x950(%rbp)
jmp 0x341f
movq -0x950(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21a0
movq %rax, -0x958(%rbp)
jmp 0x343c
movq -0x958(%rbp), %rdi
leaq 0x3c8d(%rip), %rsi      # 0x70d7
callq 0x21a0
movq %rax, -0x960(%rbp)
jmp 0x3458
leaq -0x748(%rbp), %rdi
callq 0x3bb0
movq -0x960(%rbp), %rdi
movq %rax, %rsi
callq 0x2060
movq %rax, -0x968(%rbp)
jmp 0x347c
movq -0x968(%rbp), %rdi
movq 0x6b3e(%rip), %rsi      # 0x9fc8
callq 0x21d0
jmp 0x3491
leaq 0x3c43(%rip), %rsi      # 0x70db
leaq -0x670(%rbp), %rdi
callq 0x21a0
movq %rax, -0x970(%rbp)
jmp 0x34ad
movq -0x970(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21a0
movq %rax, -0x978(%rbp)
jmp 0x34ca
movq -0x978(%rbp), %rdi
leaq 0x3c18(%rip), %rsi      # 0x70f0
callq 0x21a0
movq %rax, -0x980(%rbp)
jmp 0x34e6
movq -0x980(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x21a0
movq %rax, -0x988(%rbp)
jmp 0x3503
movq -0x988(%rbp), %rdi
leaq 0x3bc6(%rip), %rsi      # 0x70d7
callq 0x21a0
movq %rax, -0x990(%rbp)
jmp 0x351f
leaq -0x760(%rbp), %rdi
callq 0x3bb0
movq -0x990(%rbp), %rdi
movq %rax, %rsi
callq 0x2060
movq %rax, -0x998(%rbp)
jmp 0x3543
movq -0x998(%rbp), %rdi
movq 0x6a77(%rip), %rsi      # 0x9fc8
callq 0x21d0
jmp 0x3558
leaq -0x670(%rbp), %rdi
callq 0x2230
jmp 0x3566
jmp 0x3607
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x760(%rbp), %rdi
callq 0x38a0
leaq -0x748(%rbp), %rdi
callq 0x38a0
leaq -0x730(%rbp), %rdi
callq 0x38a0
jmp 0x368c
movq 0x6a43(%rip), %rdi      # 0x9ff0
leaq 0x3b49(%rip), %rsi      # 0x70fd
callq 0x21a0
movq %rax, -0x9a0(%rbp)
jmp 0x35c2
movq -0x9a0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x21a0
movq %rax, -0x9a8(%rbp)
jmp 0x35df
movq -0x9a8(%rbp), %rdi
leaq 0x3a9b(%rip), %rsi      # 0x7088
callq 0x21a0
jmp 0x35f4
movl $0x1, -0x4(%rbp)
movl $0x1, -0x6dc(%rbp)
jmp 0x3618
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6dc(%rbp)
leaq -0x760(%rbp), %rdi
callq 0x38a0
leaq -0x748(%rbp), %rdi
callq 0x38a0
leaq -0x730(%rbp), %rdi
callq 0x38a0
leaq -0x6a0(%rbp), %rdi
callq 0x38a0
leaq -0x688(%rbp), %rdi
callq 0x38a0
leaq -0x670(%rbp), %rdi
callq 0x2250
leaq -0x470(%rbp), %rdi
callq 0x2070
leaq -0x258(%rbp), %rdi
callq 0x2070
leaq -0x50(%rbp), %rdi
callq 0x20f0
leaq -0x30(%rbp), %rdi
callq 0x20f0
jmp 0x36dc
leaq -0x6a0(%rbp), %rdi
callq 0x38a0
leaq -0x688(%rbp), %rdi
callq 0x38a0
leaq -0x670(%rbp), %rdi
callq 0x2250
leaq -0x470(%rbp), %rdi
callq 0x2070
leaq -0x258(%rbp), %rdi
callq 0x2070
leaq -0x50(%rbp), %rdi
callq 0x20f0
leaq -0x30(%rbp), %rdi
callq 0x20f0
jmp 0x36e8
movl -0x4(%rbp), %eax
addq $0x9b0, %rsp            # imm = 0x9B0
popq %rbp
retq
movq -0x260(%rbp), %rdi
callq 0x22c0
nopw %cs:(%rax,%rax)
nop