// File: /workspace/github_cpp_makefile_star2_O2/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 $0x278, %rsp            # imm = 0x278
movq %rdx, %r14
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %edx, %edx
movb %dl, (%rax)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %dl, (%rax)
leaq 0x70(%rsp), %rsi
andq $0x0, (%rsi)
movq %rcx, 0x20(%rsp)
movq %rcx, %rdi
callq 0x127d0
movq (%r12), %rsi
leaq 0x70(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x7620
leaq 0xe8(%rsp), %rdi
callq 0x70d0
testb %al, %al
je 0x14de6
movq $0x0, (%rsp)
leaq 0x70(%rsp), %r12
leaq 0x28(%rsp), %r13
pushq $0xa
popq %rbp
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x90(%rsp,%rax)
jne 0x14d04
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x7630
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x14ba8
movq 0x28(%rsp), %rbx
cmpb $0xd, -0x1(%rbx,%rax)
jne 0x14bfb
leaq (%rbx,%rax), %rsi
decq %rsi
movq %r13, %rdi
callq 0x73b0
movq 0x28(%rsp), %rbx
movq 0x30(%rsp), %rax
andq $0x0, 0x10(%rsp)
decq %rax
movq %rax, 0x18(%rsp)
cmpb $0x3e, (%rbx)
jne 0x14c73
cmpq $0x0, (%rsp)
jle 0x14c4c
movq %r14, %rdi
leaq 0x50(%rsp), %rsi
callq 0x10e56
movq 0x8(%rsp), %rdi
pushq $0x60
popq %rsi
callq 0x7260
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x127d0
movq $0x1, 0x10(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x1de3d(%rip), %rsi     # 0x32a9e
callq 0x7660
movq 0x28(%rsp), %rbx
movq $0x0, (%rsp)
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x14ad8
cmpb $0x3e, (%rbx)
jne 0x14cbf
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpq %r15, %rbx
jg 0x14ba8
movq 0x28(%rsp), %rax
movb (%rax,%rbx), %al
cmpb $0x20, %al
je 0x14ba8
movsbl %al, %esi
leaq 0x50(%rsp), %rdi
callq 0x7260
incq %rbx
jmp 0x14c94
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r15
movq (%rsp), %rax
addq %rbx, %rax
subq %r15, %rax
incq %rax
movq %rax, (%rsp)
cmpq %rbx, %r15
jg 0x14ba8
movq 0x28(%rsp), %rax
movsbl (%rax,%r15), %edi
callq 0x7490
movsbl %al, %esi
movq 0x8(%rsp), %rdi
callq 0x7260
incq %r15
jmp 0x14cda
cmpq $0x0, (%rsp)
jle 0x14d18
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x10e56
movq 0x352c9(%rip), %rdi     # 0x49fe8
leaq 0x21b3a(%rip), %rsi     # 0x36860
callq 0x72b0
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rsi
movq %rax, %rdi
callq 0x71d0
movq %rax, %rdi
callq 0x7160
xorl %ebp, %ebp
movq 0x3529b(%rip), %r15     # 0x49fe8
leaq 0x21b27(%rip), %r12     # 0x3687b
leaq 0x2372b(%rip), %r13     # 0x38486
xorl %ebx, %ebx
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x5, %rax
cmpq %rax, %rbx
jge 0x14db6
movq %r15, %rdi
movq %r12, %rsi
callq 0x72b0
movq (%r14), %rsi
addq %rbp, %rsi
movq %rax, %rdi
callq 0x7280
movq %rax, %rdi
movq %r13, %rsi
callq 0x72b0
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rbx,8), %rsi
movq %rax, %rdi
callq 0x72a0
movq %rax, %rdi
callq 0x7160
incq %rbx
addq $0x20, %rbp
jmp 0x14d5d
leaq 0x70(%rsp), %rdi
callq 0x70e0
leaq 0x28(%rsp), %rdi
callq 0x76a8
leaq 0x50(%rsp), %rdi
callq 0x76a8
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x351fb(%rip), %rdi     # 0x49fe8
leaq 0x2155f(%rip), %rsi     # 0x36353
callq 0x72b0
movq %rax, %rdi
movq %r12, %rsi
callq 0x7280
movq %rax, %rdi
callq 0x7160
pushq $0x1
popq %rdi
callq 0x7390
jmp 0x14e29
jmp 0x14e29
jmp 0x14e1a
movq %rax, %rbx
jmp 0x14e36
jmp 0x14e29
jmp 0x14e29
jmp 0x14e29
jmp 0x14e29
jmp 0x14e29
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x70e0
leaq 0x28(%rsp), %rdi
callq 0x76a8
leaq 0x50(%rsp), %rdi
callq 0x76a8
movq %rbx, %rdi
callq 0x75e0