// File: /workspace/github_cpp_makefile_star2_O1/brc7[P]DiversitySampling/src/io.cpp
// Function: SequenceFeatures(std::istream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool SequenceFeatures(std::istream& in, std::string& sequence, std::string& chunk, std::string fastWhat){

    int chunksize = 0; 
    char begin;
    int linesread = 0; 
    if (fastWhat == "fasta") {
        chunksize = 2;
        begin = '>';
    } else if (fastWhat == "fastq") {
        chunksize = 4;
        begin = '@';
    } else {
        std::cerr<<"Unsupported file type: "<<fastWhat<<std::endl; 
        return false; // unsupported file type
    }

    sequence = "";
    chunk = ""; 

    // read meta data
    std::string buffer;
    std::getline(in, buffer);
    linesread++;
    if (buffer.length() == 0) {
        std::cerr<<"Found empty line - probably reached the end of the input "<<fastWhat<<" file."<<std::endl; 
        std::cerr<<buffer<<std::endl; 
        return false; 
    }
    if (buffer.at(0) != begin){
        std::cerr<<"Error reading line of "<<fastWhat<<" file: Expected a line beginning with "<<begin<<" but instead found: "<<std::endl; 
        std::cerr<<buffer<<std::endl; 
        return false; 
    }

    chunk += buffer; 
    chunk += "\n"; 

    std::getline(in, sequence); 
    linesread++; 
    if (sequence.length() == 0){
        std::cerr<<"Error reading "<<fastWhat<<" file: Expected a sequence, but found empty line for read ID: "<<std::endl; 
        std::cerr<<chunk<<std::endl; 
        return false; 
    }
    chunk += sequence; 
    chunk += "\n"; 

    while((linesread < chunksize) && (in)){
        std::getline(in, buffer); 
        linesread++; 
        chunk += buffer; 
        chunk += "\n"; 
    }

    if (linesread != chunksize){
        std::cerr<<"Error reading "<<fastWhat<<" file: Expected "<<chunksize<<" lines of input, got "<<linesread<<" instead. The sequence data should still be valid. "<<std::endl; 
        return false; 
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
leaq 0x2a4b(%rip), %rsi      # 0x5004
movq %rcx, %rdi
callq 0x2080
testl %eax, %eax
je 0x2633
leaq 0x3159(%rip), %rsi      # 0x5725
movq %rbx, %rdi
callq 0x2080
testl %eax, %eax
je 0x263f
movq 0x5a11(%rip), %r14      # 0x7ff0
leaq 0x2a24(%rip), %rsi      # 0x500a
movl $0x17, %edx
movq %r14, %rdi
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2120
xorl %ebp, %ebp
jmp 0x2a79
movl $0x2, (%rsp)
movb $0x3e, %bpl
jmp 0x2649
movl $0x4, (%rsp)
movb $0x40, %bpl
movq 0x8(%r12), %rdx
leaq 0x2a62(%rip), %r13      # 0x50b7
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2270
movq 0x8(%r14), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2270
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %edx
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x22c0
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
je 0x279d
movq 0x8(%rsp), %rsi
cmpb %bpl, (%rsi)
jne 0x2838
movq %r14, %rdi
callq 0x2090
leaq 0x29d8(%rip), %rsi      # 0x50b6
movq %r14, %rdi
callq 0x22d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x22c0
movq 0x8(%r12), %rdx
testq %rdx, %rdx
je 0x28ff
movq (%r12), %rsi
movq %r14, %rdi
callq 0x2090
leaq 0x298d(%rip), %rsi      # 0x50b6
movq %r14, %rdi
callq 0x22d0
movl $0x2, %r12d
leaq 0x8(%rsp), %r13
leaq 0x2973(%rip), %rbp      # 0x50b6
cmpl %r12d, (%rsp)
je 0x2997
movq (%r15), %rax
movq -0x18(%rax), %rdi
testb $0x5, 0x20(%r15,%rdi)
jne 0x299f
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x22c0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x2090
incl %r12d
movq %r14, %rdi
movq %rbp, %rsi
callq 0x22d0
jmp 0x2743
movq 0x584c(%rip), %rdi      # 0x7ff0
leaq 0x2877(%rip), %rsi      # 0x5022
movl $0x39, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x582d(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x288a(%rip), %rsi      # 0x505c
movl $0x6, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x57d9(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
jmp 0x2a4d
movq 0x57b1(%rip), %rdi      # 0x7ff0
leaq 0x281d(%rip), %rsi      # 0x5063
movl $0x16, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x5792(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x280d(%rip), %rsi      # 0x507a
movl $0x26, %edx
movq %rax, %rdi
callq 0x21c0
leaq 0x7(%rsp), %rsi
movb %bpl, (%rsi)
movl $0x1, %edx
movq %rbx, %rdi
callq 0x21c0
movq %rax, %rbx
leaq 0x2808(%rip), %rsi      # 0x50a1
movl $0x14, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x5712(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
jmp 0x2a4d
movq 0x56ea(%rip), %rdi      # 0x7ff0
leaq 0x27ab(%rip), %rsi      # 0x50b8
movl $0xe, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x56cb(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x2793(%rip), %rsi      # 0x50c7
movl $0x3e, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2120
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x567a(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
jmp 0x2a4d
movl (%rsp), %eax
movl %eax, %r12d
jmp 0x29a2
movl (%rsp), %eax
movb $0x1, %bpl
cmpl %eax, %r12d
leaq 0x18(%rsp), %r13
je 0x2a62
movq 0x5636(%rip), %rdi      # 0x7ff0
leaq 0x26f7(%rip), %rsi      # 0x50b8
movl $0xe, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x5617(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x271e(%rip), %rsi      # 0x5106
movl $0x10, %edx
movq %rax, %rdi
callq 0x21c0
movq %rbx, %rdi
movl (%rsp), %esi
callq 0x2290
movq %rax, %rbx
leaq 0x270d(%rip), %rsi      # 0x5117
movl $0x15, %edx
movq %rax, %rdi
callq 0x21c0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2290
movq %rax, %rbx
leaq 0x2701(%rip), %rsi      # 0x512d
movl $0x33, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2120
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x2a79
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a8c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2aab
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x22a0