// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/fasta.cpp
// Function: load_fasta(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::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::vector<long, std::allocator<long>>&)
void load_fasta(string filename, string &S, vector<string> &descr, vector<long> &startpos) {
  string meta, line;
  long length = 0;

  // Everything starts at zero.
  startpos.push_back(0);

  ifstream data(filename.c_str());

  if(!data.is_open()) { cerr << "unable to open " << filename << endl; exit(1); }

  while(!data.eof()) {
    getline(data, line, '\n'); // Load one line at a time.
    if(line.length() == 0) continue;
    if(line[line.length()-1]=='\r')
        line.erase(--line.end());

    long start = 0, end = line.length() - 1;

    // Meta tag line and start of a new sequence.
    if(line[0] == '>') {
      // Save previous sequence and meta data.
      if(length > 0) {
	descr.push_back(meta);
	S += '`'; // ` character used to separate strings
	startpos.push_back(S.length());
	//lengths.push_back(length+1);
      }
      // Reset parser state.
      start = 1; meta = ""; length = 0;
    }
    trim(line, start, end);
    // Collect meta data.
    if(line[0] == '>') {
      for(long i = start; i <= end; i++) { if(line[i] == ' ') break; meta += line[i]; }
    }
    else { // Collect sequence data.
      length += end - start + 1;
      for(long i = start; i <= end; i++) {
	S += std::tolower(line[i]);
      }
    }
  }
  if(length > 0) {
    descr.push_back(meta);
  }
  cerr << "# full reference length = " << S.length() << endl;
  for(long i = 0; i < (long)descr.size(); i++) {
    cerr << "# " << descr[i] << " " << startpos[i] << endl;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
leaq 0x48(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x20(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq %rax, 0x60(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x1976b
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x19778
leaq 0x60(%rsp), %rdx
movq %rbx, %rdi
callq 0x17184
movq (%r12), %rsi
leaq 0x60(%rsp), %rdi
movl $0x8, %edx
callq 0x7640
movq %rbx, 0x30(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x70c0
testb %al, %al
je 0x19adc
movq $0x0, 0x8(%rsp)
leaq 0x60(%rsp), %r12
leaq 0x10(%rsp), %r13
movq %r15, %rbx
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x80(%rsp,%rax)
jne 0x19967
movq %r12, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x7650
movq 0x18(%rsp), %rbp
testq %rbp, %rbp
je 0x197bb
movq 0x10(%rsp), %rax
cmpb $0xd, -0x1(%rax,%rbp)
jne 0x19819
leaq (%rax,%rbp), %rsi
decq %rsi
subq %rax, %rsi
movl $0x1, %edx
movq %r13, %rdi
callq 0x7370
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rbp
cmpb $0x3e, (%rax)
jne 0x19865
cmpq $0x0, 0x8(%rsp)
jle 0x19877
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x15962
movq %rbx, %rdi
movl $0x60, %esi
callq 0x7270
movq 0x8(%rbx), %rax
movq %rax, 0x58(%rsp)
movq 0x30(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x1986d
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x19877
movq %rbp, %rcx
xorl %r15d, %r15d
jmp 0x198ab
leaq 0x58(%rsp), %rdx
callq 0x17184
movq 0x40(%rsp), %rdx
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
leaq 0x27194(%rip), %rcx     # 0x40a1e
xorl %r8d, %r8d
callq 0x7510
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movl $0x1, %r15d
movq $0x0, 0x8(%rsp)
movslq %ecx, %rdx
cmpq %rdx, %r15
jge 0x198c9
movq %r15, %rsi
cmpb $0x20, (%rax,%rsi)
jne 0x198c6
incq %rsi
cmpq %rsi, %rdx
jne 0x198b6
jmp 0x198c9
movq %rsi, %r15
decq %rbp
decq %rcx
testq %rcx, %rcx
js 0x198e5
cmpb $0x20, (%rax,%rcx)
jne 0x198e2
addq $-0x1, %rcx
jb 0x198cf
jmp 0x198e5
movq %rcx, %rbp
cmpb $0x3e, (%rax)
jne 0x19921
cmpq %rbp, %r15
jg 0x197bb
incq %rbp
movq 0x10(%rsp), %rax
movb (%rax,%r15), %al
cmpb $0x20, %al
je 0x197bb
movsbl %al, %esi
leaq 0x38(%rsp), %rdi
callq 0x7270
incq %r15
cmpq %r15, %rbp
jne 0x198f6
jmp 0x197bb
movq 0x8(%rsp), %rax
subq %r15, %rax
addq %rbp, %rax
incq %rax
movq %rax, 0x8(%rsp)
cmpq %rbp, %r15
jg 0x197bb
incq %rbp
movq 0x10(%rsp), %rax
movsbl (%rax,%r15), %edi
callq 0x7480
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7270
incq %r15
cmpq %r15, %rbp
jne 0x19940
jmp 0x197bb
cmpq $0x0, 0x8(%rsp)
jle 0x1997c
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x15962
movq 0x3a665(%rip), %rdi     # 0x53fe8
leaq 0x2aeb6(%rip), %rsi     # 0x44840
movl $0x1a, %edx
callq 0x7340
movq 0x8(%rbx), %rsi
movq 0x3a649(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x8(%r14), %rax
subq (%r14), %rax
testq %rax, %rax
jle 0x19a88
movl $0x8, %ebx
xorl %r12d, %r12d
movq 0x3a5fb(%rip), %r15     # 0x53fe8
leaq 0x2cad2(%rip), %r13     # 0x464c6
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2ae58(%rip), %rsi     # 0x4485b
callq 0x7340
movq (%r14), %rax
movq -0x8(%rax,%rbx), %rsi
movq (%rax,%rbx), %rdx
movq %r15, %rdi
callq 0x7340
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x7340
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r12,8), %rsi
movq %rbp, %rdi
callq 0x72a0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x8(%r14), %rax
subq (%r14), %rax
incq %r12
sarq $0x5, %rax
addq $0x20, %rbx
cmpq %rax, %r12
jl 0x199f4
leaq 0x60(%rsp), %rdi
callq 0x70d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x19aae
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x19aca
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x72f0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3a505(%rip), %rdi     # 0x53fe8
leaq 0x2a819(%rip), %rsi     # 0x44303
movl $0xf, %edx
callq 0x7340
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x3a4e4(%rip), %rdi     # 0x53fe8
callq 0x7340
movq %rax, %rdi
callq 0x7150
movl $0x1, %edi
callq 0x73b0
jmp 0x19b30
jmp 0x19b21
jmp 0x19b30
movq %rax, %rbx
jmp 0x19b3d
jmp 0x19b30
jmp 0x19b30
jmp 0x19b30
jmp 0x19b30
jmp 0x19b30
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x70d0
leaq 0x20(%rsp), %rax
movq 0x10(%rsp), %rdi
cmpq %rax, %rdi
je 0x19b59
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x19b75
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x72f0
movq %rbx, %rdi
callq 0x7600
nop