// File: zeeev[P]DASVC/bamtools/src/toolkit/bamtools_convert.cpp
// Function: BamTools::ConvertTool::ConvertToolPrivate::PrintFasta(BamTools::BamAlignment const&)
void ConvertTool::ConvertToolPrivate::PrintFasta(const BamAlignment& a) { 
    
    // >BamAlignment.Name
    // BamAlignment.QueryBases (up to FASTA_LINE_MAX bases per line)
    // ...
    //
    // N.B. - QueryBases are reverse-complemented if aligned to reverse strand
  
    // print header
    m_out << ">" << a.Name << endl;
    
    // handle reverse strand alignment - bases 
    string sequence = a.QueryBases;
    if ( a.IsReverseStrand() )
        Utilities::ReverseComplement(sequence);
    
    // if sequence fits on single line
    if ( sequence.length() <= FASTA_LINE_MAX )
        m_out << sequence << endl;
    
    // else split over multiple lines
    else {
      
        size_t position = 0;
        size_t seqLength = sequence.length(); // handle reverse strand alignment - bases & qualitiesth();
        
        // write subsequences to each line
        while ( position < (seqLength - FASTA_LINE_MAX) ) {
            m_out << sequence.substr(position, FASTA_LINE_MAX) << endl;
            position += FASTA_LINE_MAX;
        }
        
        // write final subsequence
        m_out << sequence.substr(position) << endl;
    }
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq 0xd0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
addq $0x20, %rdi
leaq 0xa4230(%rip), %rsi     # 0x1308af
callq 0x86700
movq %rax, %rdi
movq 0xc8(%rsp), %rsi
callq 0x86640
movq %rax, %rdi
movq 0xd88d2(%rip), %rsi     # 0x164f70
callq 0x86770
movq 0xc8(%rsp), %rsi
addq $0x28, %rsi
leaq 0xa8(%rsp), %rdi
callq 0x86350
movq 0xc8(%rsp), %rdi
callq 0x86a40
movb %al, 0x47(%rsp)
jmp 0x8c6cf
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x8c6d9
jmp 0x8c703
leaq 0xa8(%rsp), %rdi
callq 0x115c30
jmp 0x8c6e8
jmp 0x8c703
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x8c8e0
leaq 0xa8(%rsp), %rdi
callq 0x86ac0
movq %rax, 0x30(%rsp)
jmp 0x8c717
movq 0x30(%rsp), %rax
cmpq $0x32, %rax
ja 0x8c757
movq 0x38(%rsp), %rdi
addq $0x20, %rdi
leaq 0xa8(%rsp), %rsi
callq 0x86640
movq %rax, 0x28(%rsp)
jmp 0x8c73f
movq 0x28(%rsp), %rdi
movq 0xd8825(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0x8c752
jmp 0x8c8cb
movq $0x0, 0x90(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x86ac0
movq %rax, 0x20(%rsp)
jmp 0x8c777
movq 0x20(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rax
movq 0x88(%rsp), %rcx
subq $0x32, %rcx
cmpq %rcx, %rax
jae 0x8c843
movq 0x38(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x18(%rsp)
movq 0x90(%rsp), %rdx
leaq 0x68(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movl $0x32, %ecx
callq 0x86750
jmp 0x8c7d0
movq 0x18(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x86640
movq %rax, 0x10(%rsp)
jmp 0x8c7e6
movq 0x10(%rsp), %rdi
movq 0xd877e(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0x8c7f9
leaq 0x68(%rsp), %rdi
callq 0x86f68
jmp 0x8c805
movq 0x90(%rsp), %rax
addq $0x32, %rax
movq %rax, 0x90(%rsp)
jmp 0x8c784
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x86f68
jmp 0x8c83e
jmp 0x8c8e0
movq 0x38(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rsp), %rdx
leaq 0x48(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movq $-0x1, %rcx
callq 0x86750
jmp 0x8c874
movq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x86640
movq %rax, (%rsp)
jmp 0x8c889
movq (%rsp), %rdi
movq 0xd86dc(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0x8c89b
leaq 0x48(%rsp), %rdi
callq 0x86f68
jmp 0x8c8a7
jmp 0x8c8cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x86f68
jmp 0x8c8c9
jmp 0x8c8e0
leaq 0xa8(%rsp), %rdi
callq 0x86f68
addq $0xd8, %rsp
retq
leaq 0xa8(%rsp), %rdi
callq 0x86f68
jmp 0x8c8ef
jmp 0x8c8f1
movq 0xa0(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290
nopw %cs:(%rax,%rax)