// File: /workspace/github_cpp_makefile_star2_O3/millanek[P]evo/process_vcf_shortRNA.cpp
// Function: shortRNAMain(int, char**)
int shortRNAMain(int argc, char** argv) {
    parseShortRNAOptions(argc, argv);
    
    std::ifstream* smallRNAFile = new std::ifstream(opt::smallRNAFile);
    
    string refFastaFileRoot;
    if (opt::out.empty()) {
        refFastaFileRoot = stripExtension(opt::smallRNAFile);
    } else {
        refFastaFileRoot = opt::out;
    }
    
    string outDistribution = refFastaFileRoot + "smallRNAdist.forR";
    string outDistributionUnique = refFastaFileRoot + "smallRNAdistUnique.forR";
  
    std::cerr << "Output will be in: " << outDistribution << std::endl;
    std::cerr << "and: " << outDistributionUnique << std::endl;
    std::ofstream* outDistributionFile = new std::ofstream(outDistribution);
    std::ofstream* outDistributionUniqueFile = new std::ofstream(outDistributionUnique);
    
    std::map<string, bool> seen;
    
    string line;
    getline(*smallRNAFile, line);
    bool fastq = false;
    if (line[0] == '@') { fastq = true; } else if (line[0] == '>') { fastq = false; } else { std::cerr << "File format not recognised" << std::endl; exit(1); }
    int linesRead = 1;
    
    std::vector<std::vector<int> > counts; std::vector<std::vector<int> > uniqueCounts; counts.resize(34); uniqueCounts.resize(34);
    for (std::vector<std::vector<int> >::size_type i = 0; i != counts.size(); i++) {
        counts[i].resize(4); uniqueCounts[i].resize(4);
    }
    
    while (getline(*smallRNAFile, line)) {
        linesRead++;
        if ((!fastq && (linesRead % 2 == 0))
            || (fastq && ((linesRead+2) % 4 == 0))) {
            if (line[0] == 'N') { continue; }
            else {
                // std::cerr << "Seq: " << line << std::endl;
                string::size_type l = line.length();
                if (seen.find(line) == seen.end()) {
                    switch (line[0]) {
                        case 'A': counts[l][0]++; uniqueCounts[l][0]++;
                            // std::cerr << "l: " << l << " fb: " << line[0] << "c: " << counts[l][0] << std::endl;
                            break;
                        case 'C': counts[l][1]++; uniqueCounts[l][1]++; break;
                        case 'G': counts[l][2]++; uniqueCounts[l][2]++; break;
                        case 'T': counts[l][3]++; uniqueCounts[l][3]++; break;
                        default: std::cerr << "Unknown base in the sequence: " << line[0] << " Exiting..." << std::endl; exit(1);
                    }
                    seen[line] = true;
                } else {
                    switch (line[0]) {
                        case 'A': counts[l][0]++;
                            // std::cerr << "l: " << l << " fb: " << line[0] << "c: " << counts[l][0] << std::endl;
                            break;
                        case 'C': counts[l][1]++; break;
                        case 'G': counts[l][2]++; break;
                        case 'T': counts[l][3]++; break;
                        default: std::cerr << "Unknown base in the sequence: " << line[0] << " Exiting..." << std::endl; exit(1);
                    }
                }
            }
        }
    }
    
    //std::cerr << "Counts_size: " << counts.size() << " " << counts[18][1] << std::endl;
    
    for (std::vector<int>::size_type j = 0; j != 4; j++) {
        for (std::vector<std::vector<int> >::size_type i = 18; i != counts.size(); i++) {
            //std::cerr << " i: " << i << " " << counts[i][j] << std::endl;
            if (i == (counts.size()-1)) {
                *outDistributionFile << counts[i][j] << std::endl;
                *outDistributionUniqueFile << uniqueCounts[i][j] << std::endl;
            }
            else {
                *outDistributionFile << counts[i][j] << "\t";
                *outDistributionUniqueFile << uniqueCounts[i][j] << "\t";
            }
        }
    }
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
callq 0x9aba5
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %rbx
leaq 0x698ca(%rip), %rsi     # 0x103b60
movq %rax, %rdi
movl $0x8, %edx
callq 0x8740
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
cmpq $0x0, 0x698c8(%rip)     # 0x103b88
je 0x9a2d5
leaq 0x698b7(%rip), %rsi     # 0x103b80
leaq 0x30(%rsp), %rdi
callq 0x8270
jmp 0x9a31e
leaq 0x69884(%rip), %rsi     # 0x103b60
leaq 0xd8(%rsp), %rdi
callq 0x4d82f
leaq 0x30(%rsp), %rdi
leaq 0xd8(%rsp), %r14
movq %r14, %rsi
callq 0x8540
movq (%r14), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x9a31e
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x2ba06
leaq 0x42ae0(%rip), %rsi     # 0xdce25
leaq 0x50(%rsp), %rdi
callq 0x88c0
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0x2ba06
leaq 0x42abb(%rip), %rsi     # 0xdce37
leaq 0xb0(%rsp), %rdi
callq 0x88c0
movq 0x67c58(%rip), %rdi     # 0x101fe8
leaq 0x42ab8(%rip), %rsi     # 0xdce4f
movl $0x13, %edx
callq 0x84e0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x67c36(%rip), %rdi     # 0x101fe8
callq 0x84e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movq 0x67c00(%rip), %rdi     # 0x101fe8
leaq 0x2ff7b(%rip), %rsi     # 0xca36a
movl $0x5, %edx
callq 0x84e0
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0x67bd8(%rip), %rdi     # 0x101fe8
callq 0x84e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq %rax, %r15
leaq 0x50(%rsp), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x88d0
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq %rax, %r14
leaq 0xb0(%rsp), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x88d0
leaq 0xe0(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xa0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
leaq 0x90(%rsp), %rsi
movq %rbx, %rdi
callq 0x8870
movq 0x90(%rsp), %rax
movzbl (%rax), %r13d
cmpl $0x3e, %r13d
je 0x9a4f6
cmpl $0x40, %r13d
jne 0x9aa40
movq %r14, 0xd0(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
movq %rax, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movl $0x22, %esi
callq 0x9ae02
leaq 0x70(%rsp), %rdi
movl $0x22, %esi
callq 0x9ae02
movq 0x10(%rsp), %rdi
cmpq %rdi, 0x18(%rsp)
je 0x9a591
xorl %r14d, %r14d
xorl %r12d, %r12d
addq %r14, %rdi
movl $0x4, %esi
callq 0x51d1c
movq 0x70(%rsp), %rdi
addq %r14, %rdi
movl $0x4, %esi
callq 0x51d1c
incq %r12
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
addq $0x18, %r14
cmpq %rax, %r12
jne 0x9a547
movl $0x4, %r12d
leaq 0x90(%rsp), %rbp
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x9a779
cmpb $0x40, %r13b
je 0x9a650
leal -0x3(%r12), %eax
andl $0x1, %eax
je 0x9a650
movq 0x90(%rsp), %rax
cmpb $0x4e, (%rax)
je 0x9a771
movq %rbp, %rsi
movq 0x98(%rsp), %r14
leaq 0xd8(%rsp), %rdi
callq 0x9b0b6
movq 0x90(%rsp), %rcx
movzbl (%rcx), %ecx
leaq 0xe0(%rsp), %rdx
cmpq %rdx, %rax
je 0x9a669
cmpl $0x46, %ecx
jg 0x9a6a6
cmpl $0x41, %ecx
je 0x9a6fa
cmpl $0x43, %ecx
jne 0x9a97d
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl 0x4(%rax)
jmp 0x9a771
cmpb $0x40, %r13b
jne 0x9a771
testb $0x3, %r12b
jne 0x9a771
jmp 0x9a5e3
cmpl $0x46, %ecx
jg 0x9a6c9
cmpl $0x41, %ecx
je 0x9a71d
cmpl $0x43, %ecx
jne 0x9a9e0
movq 0x10(%rsp), %rax
shlq $0x3, %r14
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx), %rax
incl 0x4(%rax)
movq 0x70(%rsp), %rax
movq (%rax,%rcx), %rax
addq $0x4, %rax
jmp 0x9a75c
cmpl $0x47, %ecx
je 0x9a70b
cmpl $0x54, %ecx
jne 0x9a97d
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl 0xc(%rax)
jmp 0x9a771
cmpl $0x47, %ecx
je 0x9a73b
cmpl $0x54, %ecx
jne 0x9a9e0
movq 0x10(%rsp), %rax
shlq $0x3, %r14
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx), %rax
incl 0xc(%rax)
movq 0x70(%rsp), %rax
movq (%rax,%rcx), %rax
addq $0xc, %rax
jmp 0x9a75c
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl (%rax)
jmp 0x9a771
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl 0x8(%rax)
jmp 0x9a771
movq 0x10(%rsp), %rax
shlq $0x3, %r14
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx), %rax
incl (%rax)
movq 0x70(%rsp), %rax
movq (%rax,%rcx), %rax
jmp 0x9a75c
movq 0x10(%rsp), %rax
shlq $0x3, %r14
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx), %rax
incl 0x8(%rax)
movq 0x70(%rsp), %rax
movq (%rax,%rcx), %rax
addq $0x8, %rax
incl (%rax)
leaq 0xd8(%rsp), %rdi
movq %rbp, %rsi
callq 0x9ae3e
movb $0x1, (%rax)
incl %r12d
jmp 0x9a59f
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
xorl %r13d, %r13d
leaq 0x3323d(%rip), %rbx     # 0xcd9ca
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x1b0, %rdx            # imm = 0x1B0
je 0x9a8b9
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
movl $0x12, %ebp
movl $0x1b0, %r14d           # imm = 0x1B0
decq %rdx
movq (%rax,%r14), %rax
movl (%rax,%r13,4), %esi
cmpq %rdx, %rbp
jne 0x9a845
movq %r15, %rdi
callq 0x8810
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r12, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movq 0x70(%rsp), %rax
movq (%rax,%r14), %rax
movl (%rax,%r13,4), %esi
movq 0xd0(%rsp), %rdi
callq 0x8810
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r12, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
jmp 0x9a887
movq %r15, %rdi
callq 0x8810
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x84e0
movq 0x70(%rsp), %rax
movq (%rax,%r14), %rax
movl (%rax,%r13,4), %esi
movq 0xd0(%rsp), %rdi
callq 0x8810
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x84e0
incq %rbp
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
addq $0x18, %r14
cmpq %rdx, %rbp
jne 0x9a7bd
incq %r13
cmpq $0x4, %r13
jne 0x9a78d
leaq 0x70(%rsp), %rdi
callq 0x480b0
leaq 0x10(%rsp), %rdi
callq 0x480b0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9a8ff
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0xd8(%rsp), %rdi
callq 0x9aeba
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x40(%rsp), %rbx
je 0x9a936
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x9a952
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x9a969
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%rsp), %rbp
movq 0x6765f(%rip), %rdi     # 0x101fe8
leaq 0x424ee(%rip), %rsi     # 0xdce7e
movl $0x1e, %edx
callq 0x84e0
movq 0x90(%rsp), %rax
movb (%rax), %al
leaq 0xf(%rsp), %rsi
movb %al, (%rsi)
movq 0x67636(%rip), %rdi     # 0x101fe8
movl $0x1, %edx
callq 0x84e0
movq %rax, %rbx
leaq 0x424d7(%rip), %rsi     # 0xdce9d
movl $0xb, %edx
movq %rax, %rdi
callq 0x84e0
movq %rbx, %rdi
callq 0x8200
jmp 0x9aa69
leaq 0x40(%rsp), %rbp
movq 0x675fc(%rip), %rdi     # 0x101fe8
leaq 0x4248b(%rip), %rsi     # 0xdce7e
movl $0x1e, %edx
callq 0x84e0
movq 0x90(%rsp), %rax
movb (%rax), %al
leaq 0xf(%rsp), %rsi
movb %al, (%rsi)
movq 0x675d3(%rip), %rdi     # 0x101fe8
movl $0x1, %edx
callq 0x84e0
movq %rax, %rbx
leaq 0x42474(%rip), %rsi     # 0xdce9d
movl $0xb, %edx
movq %rax, %rdi
callq 0x84e0
movq %rbx, %rdi
callq 0x8200
jmp 0x9aa69
leaq 0x40(%rsp), %rbp
movq 0x6759c(%rip), %rdi     # 0x101fe8
leaq 0x42410(%rip), %rsi     # 0xdce63
movl $0x1a, %edx
callq 0x84e0
movq 0x67584(%rip), %rdi     # 0x101fe8
callq 0x8200
movl $0x1, %edi
callq 0x8530
movq %rax, %r12
jmp 0x9ab13
jmp 0x9aac1
jmp 0x9aac1
movq %rax, %r12
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
jmp 0x9aa99
jmp 0x9aaee
movq %rax, %r12
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdi
callq 0x8480
jmp 0x9ab45
jmp 0x9aaee
jmp 0x9aaee
movq %rax, %r12
jmp 0x9ab6a
movq %rax, %r12
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
jmp 0x9ab74
movq %rax, %r12
jmp 0x9ab86
movq %rax, %r12
movl $0x208, %esi            # imm = 0x208
movq %rbx, %rdi
jmp 0x9ab98
jmp 0x9aaf7
movq %rax, %r12
leaq 0x40(%rsp), %rbp
jmp 0x9ab13
movq %rax, %r12
jmp 0x9aaff
jmp 0x9aaf7
jmp 0x9aaf7
movq %rax, %r12
jmp 0x9ab45
jmp 0x9aaf7
jmp 0x9aaf7
movq %rax, %r12
leaq 0x40(%rsp), %rbp
leaq 0x70(%rsp), %rdi
callq 0x480b0
leaq 0x10(%rsp), %rdi
callq 0x480b0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9ab38
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0xd8(%rsp), %rdi
callq 0x9aeba
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x9ab6a
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x60(%rsp), %rax
movq 0x50(%rsp), %rdi
cmpq %rax, %rdi
je 0x9ab86
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9ab9d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r12, %rdi
callq 0x8840