// File: millanek[P]evo/process_vcf_cbs.cpp
// Function: findUndeterminedRegions()
void findUndeterminedRegions() {
    // Open a connection to read from the genome file
    std::ifstream* genomeFile = new std::ifstream(opt::genomeFile.c_str());
    string genomeFileRoot = stripExtension(opt::genomeFile);
    string undeterminedRegionsFileName = genomeFileRoot + ".ns";
    std::ofstream* undeterminedRegionsFile = new std::ofstream(undeterminedRegionsFileName.c_str());
    
    string nextScaffoldName;
    getline(*genomeFile, nextScaffoldName);
    string currentScaffoldReference;
    int thisUndeterminedRegionStart;
    int thisUndeterminedRegionEnd;
    while (nextScaffoldName != "") {
        //std::cerr << "Processing " << nextScaffoldName << "..." << std::endl;
        string thisScaffold = nextScaffoldName;
        currentScaffoldReference = readScaffold(genomeFile, nextScaffoldName);
        *undeterminedRegionsFile << thisScaffold << "\t" << currentScaffoldReference.length() << std::endl;
        bool bInUndetermined = false;
        for (string::size_type i = 0; i != currentScaffoldReference.size(); i++) {
            if (currentScaffoldReference[i] == 'N') {
                if (!bInUndetermined)
                    thisUndeterminedRegionStart = (int)i;
                if (i == currentScaffoldReference.size()-1) {
                    if (bInUndetermined)
                        *undeterminedRegionsFile << thisUndeterminedRegionStart << "\t" << i << std::endl;
                    else
                        *undeterminedRegionsFile << i << "\t" << i << std::endl;
                }
                bInUndetermined = true;
            } else {
                if (bInUndetermined) {
                    thisUndeterminedRegionEnd = (int)i-1;
                    *undeterminedRegionsFile << thisUndeterminedRegionStart << "\t" << thisUndeterminedRegionEnd << std::endl;
                    bInUndetermined = false;
                }
            }
        }
    }
    
    string line;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0x120(%rbp)
movq %rax, -0x128(%rbp)
leaq 0x132d06(%rip), %rdi    # 0x19a540
callq 0xa220
movq -0x120(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0x67855
movq -0x128(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq 0x132cd9(%rip), %rsi    # 0x19a540
leaq -0x38(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x7be70
movq -0x130(%rbp), %rsi
leaq 0xd1bab(%rip), %rdx     # 0x139430
leaq -0x58(%rbp), %rdi
callq 0x3da80
jmp 0x67890
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x138(%rbp)
jmp 0x678a3
leaq -0x58(%rbp), %rdi
callq 0xa220
movq -0x138(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0xa650
jmp 0x678c2
movq -0x138(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0xa820
movq -0x140(%rbp), %rsi
movq -0x8(%rbp), %rdi
callq 0xa0d0
jmp 0x678ef
leaq -0xa0(%rbp), %rdi
callq 0xa820
leaq 0xce5dd(%rip), %rsi     # 0x135edf
leaq -0x80(%rbp), %rdi
callq 0x50eb0
movb %al, -0x141(%rbp)
jmp 0x67913
movb -0x141(%rbp), %al
testb $0x1, %al
jne 0x67922
jmp 0x67cd5
leaq -0xc8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xa250
jmp 0x67934
leaq -0xe8(%rbp), %rdi
leaq -0x8(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x6a7e0
jmp 0x6794a
leaq -0xa0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
movq %rsi, -0x158(%rbp)
callq 0xa710
movq -0x158(%rbp), %rdi
callq 0xac88
movq -0x60(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xa520
movq %rax, -0x150(%rbp)
jmp 0x67989
movq -0x150(%rbp), %rdi
leaq 0xce547(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x160(%rbp)
jmp 0x679a5
leaq -0xa0(%rbp), %rdi
callq 0xa930
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0xa140
movq %rax, -0x168(%rbp)
jmp 0x679c9
movq -0x168(%rbp), %rdi
movq 0x1315b1(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x679de
movb $0x0, -0xe9(%rbp)
movq $0x0, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xa3e0
movq %rax, %rcx
movq -0x170(%rbp), %rax
cmpq %rcx, %rax
je 0x67cc4
movq -0xf8(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0xac60
movq %rax, -0x178(%rbp)
jmp 0x67a39
movq -0x178(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4e, %eax
jne 0x67c27
testb $0x1, -0xe9(%rbp)
jne 0x67b10
movq -0xf8(%rbp), %rax
movl %eax, -0xa4(%rbp)
jmp 0x67b10
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0x67d44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x67d3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x67d32
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0x67d32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x67d29
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x67d1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0xac88
jmp 0x67d1d
movq -0xf8(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xa3e0
movq %rax, %rcx
movq -0x180(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x67c1b
testb $0x1, -0xe9(%rbp)
je 0x67bb1
movq -0x60(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0xab20
movq %rax, -0x188(%rbp)
jmp 0x67b62
movq -0x188(%rbp), %rdi
leaq 0xce36e(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x190(%rbp)
jmp 0x67b7e
movq -0x190(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0xa140
movq %rax, -0x198(%rbp)
jmp 0x67b9a
movq -0x198(%rbp), %rdi
movq 0x1313e0(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x67baf
jmp 0x67c19
movq -0x60(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0xa140
movq %rax, -0x1a0(%rbp)
jmp 0x67bca
movq -0x1a0(%rbp), %rdi
leaq 0xce306(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x1a8(%rbp)
jmp 0x67be6
movq -0x1a8(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0xa140
movq %rax, -0x1b0(%rbp)
jmp 0x67c02
movq -0x1b0(%rbp), %rdi
movq 0x131378(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x67c17
jmp 0x67c19
jmp 0x67c1b
movb $0x1, -0xe9(%rbp)
jmp 0x67cab
testb $0x1, -0xe9(%rbp)
je 0x67ca9
movl -0xf8(%rbp), %eax
decl %eax
movl %eax, -0xa8(%rbp)
movq -0x60(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0xab20
movq %rax, -0x1b8(%rbp)
jmp 0x67c56
movq -0x1b8(%rbp), %rdi
leaq 0xce27a(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x1c0(%rbp)
jmp 0x67c72
movq -0x1c0(%rbp), %rdi
movl -0xa8(%rbp), %esi
callq 0xab20
movq %rax, -0x1c8(%rbp)
jmp 0x67c8d
movq -0x1c8(%rbp), %rdi
movq 0x1312ed(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x67ca2
movb $0x0, -0xe9(%rbp)
jmp 0x67cab
jmp 0x67cad
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x679f0
leaq -0xc8(%rbp), %rdi
callq 0xac88
jmp 0x678fb
leaq -0x118(%rbp), %rdi
callq 0xa820
leaq -0x118(%rbp), %rdi
callq 0xac88
leaq -0xa0(%rbp), %rdi
callq 0xac88
leaq -0x80(%rbp), %rdi
callq 0xac88
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x38(%rbp), %rdi
callq 0xac88
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
leaq -0xa0(%rbp), %rdi
callq 0xac88
leaq -0x80(%rbp), %rdi
callq 0xac88
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x38(%rbp), %rdi
callq 0xac88
movq -0x10(%rbp), %rdi
callq 0xab50
nopl (%rax)