// File: /workspace/github_cpp_makefile_star2_O1/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 0x9b65e
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %rbx
leaq 0x71dfa(%rip), %rsi     # 0x10cb50
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, 0x71df8(%rip)     # 0x10cb78
je 0x9ad95
leaq 0x71de7(%rip), %rsi     # 0x10cb70
leaq 0x30(%rsp), %rdi
callq 0x8270
jmp 0x9adde
leaq 0x71db4(%rip), %rsi     # 0x10cb50
leaq 0xd8(%rsp), %rdi
callq 0x50803
leaq 0x30(%rsp), %rdi
leaq 0xd8(%rsp), %r14
movq %r14, %rsi
callq 0x8540
movq (%r14), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x9adde
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 0x2e45c
leaq 0x49a30(%rip), %rsi     # 0xe4835
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 0x2e45c
leaq 0x49a0b(%rip), %rsi     # 0xe4847
leaq 0xb0(%rsp), %rdi
callq 0x88c0
movq 0x70198(%rip), %rdi     # 0x10afe8
leaq 0x49a08(%rip), %rsi     # 0xe485f
movl $0x13, %edx
callq 0x84e0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x70176(%rip), %rdi     # 0x10afe8
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 0x70140(%rip), %rdi     # 0x10afe8
leaq 0x306fb(%rip), %rsi     # 0xcb5aa
movl $0x5, %edx
callq 0x84e0
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0x70118(%rip), %rdi     # 0x10afe8
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 0x9afb6
cmpl $0x40, %r13d
jne 0x9b4f9
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 0x9b8c2
leaq 0x70(%rsp), %rdi
movl $0x22, %esi
callq 0x9b8c2
movq 0x10(%rsp), %rdi
cmpq %rdi, 0x18(%rsp)
je 0x9b051
xorl %r14d, %r14d
xorl %r12d, %r12d
addq %r14, %rdi
movl $0x4, %esi
callq 0x54d18
movq 0x70(%rsp), %rdi
addq %r14, %rdi
movl $0x4, %esi
callq 0x54d18
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 0x9b007
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 0x9b239
cmpb $0x40, %r13b
je 0x9b110
leal -0x3(%r12), %eax
andl $0x1, %eax
je 0x9b110
movq 0x90(%rsp), %rax
cmpb $0x4e, (%rax)
je 0x9b231
movq %rbp, %rsi
movq 0x98(%rsp), %r14
leaq 0xd8(%rsp), %rdi
callq 0x9bb7e
movq 0x90(%rsp), %rcx
movzbl (%rcx), %ecx
leaq 0xe0(%rsp), %rdx
cmpq %rdx, %rax
je 0x9b129
cmpl $0x46, %ecx
jg 0x9b166
cmpl $0x41, %ecx
je 0x9b1ba
cmpl $0x43, %ecx
jne 0x9b436
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl 0x4(%rax)
jmp 0x9b231
cmpb $0x40, %r13b
jne 0x9b231
testb $0x3, %r12b
jne 0x9b231
jmp 0x9b0a3
cmpl $0x46, %ecx
jg 0x9b189
cmpl $0x41, %ecx
je 0x9b1dd
cmpl $0x43, %ecx
jne 0x9b499
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 0x9b21c
cmpl $0x47, %ecx
je 0x9b1cb
cmpl $0x54, %ecx
jne 0x9b436
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl 0xc(%rax)
jmp 0x9b231
cmpl $0x47, %ecx
je 0x9b1fb
cmpl $0x54, %ecx
jne 0x9b499
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 0x9b21c
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl (%rax)
jmp 0x9b231
movq 0x10(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
incl 0x8(%rax)
jmp 0x9b231
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 0x9b21c
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 0x9b8fe
movb $0x1, (%rax)
incl %r12d
jmp 0x9b05f
xorl %r13d, %r13d
leaq 0x36a3b(%rip), %rbx     # 0xd1c7e
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
subq %rcx, %rax
cmpq $0x1b0, %rax            # imm = 0x1B0
je 0x9b372
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rax
movl $0x12, %ebp
movl $0x1b0, %r14d           # imm = 0x1B0
decq %rax
movq (%rcx,%r14), %rcx
movl (%rcx,%r13,4), %esi
cmpq %rax, %rbp
jne 0x9b301
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 0x9b343
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), %rcx
movq 0x18(%rsp), %rax
subq %rcx, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rax
addq $0x18, %r14
cmpq %rax, %rbp
jne 0x9b279
incq %r13
cmpq $0x4, %r13
jne 0x9b243
leaq 0x70(%rsp), %rdi
callq 0x4b0a4
leaq 0x10(%rsp), %rdi
callq 0x4b0a4
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9b3b8
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0xd8(%rsp), %rdi
callq 0x9b97a
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x40(%rsp), %rbx
je 0x9b3ef
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x9b40b
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x9b422
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 0x6fba6(%rip), %rdi     # 0x10afe8
leaq 0x49445(%rip), %rsi     # 0xe488e
movl $0x1e, %edx
callq 0x84e0
movq 0x90(%rsp), %rax
movb (%rax), %al
leaq 0xf(%rsp), %rsi
movb %al, (%rsi)
movq 0x6fb7d(%rip), %rdi     # 0x10afe8
movl $0x1, %edx
callq 0x84e0
movq %rax, %rbx
leaq 0x4942e(%rip), %rsi     # 0xe48ad
movl $0xb, %edx
movq %rax, %rdi
callq 0x84e0
movq %rbx, %rdi
callq 0x8200
jmp 0x9b522
leaq 0x40(%rsp), %rbp
movq 0x6fb43(%rip), %rdi     # 0x10afe8
leaq 0x493e2(%rip), %rsi     # 0xe488e
movl $0x1e, %edx
callq 0x84e0
movq 0x90(%rsp), %rax
movb (%rax), %al
leaq 0xf(%rsp), %rsi
movb %al, (%rsi)
movq 0x6fb1a(%rip), %rdi     # 0x10afe8
movl $0x1, %edx
callq 0x84e0
movq %rax, %rbx
leaq 0x493cb(%rip), %rsi     # 0xe48ad
movl $0xb, %edx
movq %rax, %rdi
callq 0x84e0
movq %rbx, %rdi
callq 0x8200
jmp 0x9b522
leaq 0x40(%rsp), %rbp
movq 0x6fae3(%rip), %rdi     # 0x10afe8
leaq 0x49367(%rip), %rsi     # 0xe4873
movl $0x1a, %edx
callq 0x84e0
movq 0x6facb(%rip), %rdi     # 0x10afe8
callq 0x8200
movl $0x1, %edi
callq 0x8530
movq %rax, %r12
jmp 0x9b5cc
jmp 0x9b57a
jmp 0x9b57a
movq %rax, %r12
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
jmp 0x9b552
jmp 0x9b5a7
movq %rax, %r12
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdi
callq 0x8480
jmp 0x9b5fe
jmp 0x9b5a7
jmp 0x9b5a7
movq %rax, %r12
jmp 0x9b623
movq %rax, %r12
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
jmp 0x9b62d
movq %rax, %r12
jmp 0x9b63f
movq %rax, %r12
movl $0x208, %esi            # imm = 0x208
movq %rbx, %rdi
jmp 0x9b651
jmp 0x9b5b0
movq %rax, %r12
leaq 0x40(%rsp), %rbp
jmp 0x9b5cc
movq %rax, %r12
jmp 0x9b5b8
jmp 0x9b5b0
jmp 0x9b5b0
movq %rax, %r12
jmp 0x9b5fe
jmp 0x9b5b0
jmp 0x9b5b0
movq %rax, %r12
leaq 0x40(%rsp), %rbp
leaq 0x70(%rsp), %rdi
callq 0x4b0a4
leaq 0x10(%rsp), %rdi
callq 0x4b0a4
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9b5f1
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0xd8(%rsp), %rdi
callq 0x9b97a
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x9b623
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x60(%rsp), %rax
movq 0x50(%rsp), %rdi
cmpq %rax, %rdi
je 0x9b63f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9b656
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r12, %rdi
callq 0x8840