// File: /workspace/github_cpp_makefile_star2_O3/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 0x2634
leaq 0x3153(%rip), %rsi      # 0x571f
movq %rbx, %rdi
callq 0x2080
testl %eax, %eax
je 0x2640
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 %r13d, %r13d
jmp 0x2a6c
movl $0x2, (%rsp)
movb $0x3e, %bpl
jmp 0x264a
movl $0x4, (%rsp)
movb $0x40, %bpl
movq 0x8(%r12), %rdx
leaq 0x2a61(%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), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
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 0x279c
movq 0x8(%rsp), %rsi
cmpb %bpl, (%rsi)
jne 0x2837
movq %r14, %rdi
callq 0x2090
leaq 0x29d9(%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 0x28fe
movq (%r12), %rsi
movq %r14, %rdi
callq 0x2090
leaq 0x298e(%rip), %rsi      # 0x50b6
movq %r14, %rdi
callq 0x22d0
movl $0x2, %r12d
leaq 0x2979(%rip), %rbp      # 0x50b6
movb $0x1, %r13b
cmpl %r12d, (%rsp)
je 0x2a50
movq (%r15), %rax
movq -0x18(%rax), %rdi
testb $0x5, 0x20(%r15,%rdi)
jne 0x2996
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %edx
movq %r15, %rdi
leaq 0x8(%rsp), %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 0x273d
movq 0x584d(%rip), %rdi      # 0x7ff0
leaq 0x2878(%rip), %rsi      # 0x5022
movl $0x39, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x582e(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x288b(%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 0x57da(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
jmp 0x2a3a
movq 0x57b2(%rip), %rdi      # 0x7ff0
leaq 0x281e(%rip), %rsi      # 0x5063
movl $0x16, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x5793(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x280e(%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 0x2809(%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 0x5713(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
jmp 0x2a3a
movq 0x56eb(%rip), %rdi      # 0x7ff0
leaq 0x27ac(%rip), %rsi      # 0x50b8
movl $0xe, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x56cc(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x2794(%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 0x567b(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
jmp 0x2a3a
cmpl %r12d, (%rsp)
je 0x2a50
movq 0x5649(%rip), %rdi      # 0x7ff0
leaq 0x270a(%rip), %rsi      # 0x50b8
movl $0xe, %edx
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x562a(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x2731(%rip), %rsi      # 0x5106
movl $0x10, %edx
movq %rax, %rdi
callq 0x21c0
movq %rbx, %rdi
movl (%rsp), %esi
callq 0x2290
movq %rax, %rbx
leaq 0x2720(%rip), %rsi      # 0x5117
movl $0x15, %edx
movq %rax, %rdi
callq 0x21c0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2290
movq %rax, %rbx
leaq 0x2714(%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 %r13d, %r13d
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2a6c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a80
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2a9f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x22a0