// File: /workspace/github_cpp_makefile_star2_O1/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 0x19a10
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x19a1d
leaq 0x60(%rsp), %rdx
movq %rbx, %rdi
callq 0x173e4
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 0x19d7c
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 0x19c07
movq %r12, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x7650
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x19a60
movq 0x10(%rsp), %rax
cmpb $0xd, -0x1(%rax,%rsi)
jne 0x19aad
decq %rsi
movl $0x1, %edx
movq %r13, %rdi
callq 0x7370
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rbp
cmpb $0x3e, (%rax)
jne 0x19b03
cmpq $0x0, 0x8(%rsp)
jle 0x19b12
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x15ace
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 0x19b08
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x19b12
xorl %r15d, %r15d
jmp 0x19b3c
leaq 0x58(%rsp), %rdx
callq 0x173e4
movl $0x1, %r15d
movq 0x40(%rsp), %rdx
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
leaq 0x26ef3(%rip), %rcx     # 0x40a1e
xorl %r8d, %r8d
callq 0x7510
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %rax
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x19b64
movq 0x10(%rsp), %rsi
movq %r15, %rdx
cmpb $0x20, (%rsi,%rdx)
jne 0x19b61
incq %rdx
cmpq %rdx, %rcx
jne 0x19b51
jmp 0x19b64
movq %rdx, %r15
decq %rbp
movq 0x10(%rsp), %rcx
decq %rax
testq %rax, %rax
js 0x19b85
cmpb $0x20, (%rcx,%rax)
jne 0x19b82
addq $-0x1, %rax
jb 0x19b6f
jmp 0x19b85
movq %rax, %rbp
cmpb $0x3e, (%rcx)
jne 0x19bc1
cmpq %rbp, %r15
jg 0x19a60
incq %rbp
movq 0x10(%rsp), %rax
movb (%rax,%r15), %al
cmpb $0x20, %al
je 0x19a60
movsbl %al, %esi
leaq 0x38(%rsp), %rdi
callq 0x7270
incq %r15
cmpq %r15, %rbp
jne 0x19b96
jmp 0x19a60
movq 0x8(%rsp), %rax
subq %r15, %rax
addq %rbp, %rax
incq %rax
movq %rax, 0x8(%rsp)
cmpq %rbp, %r15
jg 0x19a60
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 0x19be0
jmp 0x19a60
cmpq $0x0, 0x8(%rsp)
jle 0x19c1c
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x15ace
movq 0x3a3c5(%rip), %rdi     # 0x53fe8
leaq 0x2ac16(%rip), %rsi     # 0x44840
movl $0x1a, %edx
callq 0x7340
movq 0x8(%rbx), %rsi
movq 0x3a3a9(%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 0x19d28
movl $0x8, %ebx
xorl %r12d, %r12d
movq 0x3a35b(%rip), %r15     # 0x53fe8
leaq 0x2c832(%rip), %r13     # 0x464c6
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2abb8(%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 0x19c94
leaq 0x60(%rsp), %rdi
callq 0x70d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x19d4e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x19d6a
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 0x3a265(%rip), %rdi     # 0x53fe8
leaq 0x2a579(%rip), %rsi     # 0x44303
movl $0xf, %edx
callq 0x7340
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x3a244(%rip), %rdi     # 0x53fe8
callq 0x7340
movq %rax, %rdi
callq 0x7150
movl $0x1, %edi
callq 0x73b0
jmp 0x19dd0
jmp 0x19dc1
jmp 0x19dd0
movq %rax, %rbx
jmp 0x19ddd
jmp 0x19dd0
jmp 0x19dd0
jmp 0x19dd0
jmp 0x19dd0
jmp 0x19dd0
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x70d0
leaq 0x20(%rsp), %rax
movq 0x10(%rsp), %rdi
cmpq %rax, %rdi
je 0x19df9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x19e15
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x72f0
movq %rbx, %rdi
callq 0x7600
nop