// File: zeeev[P]DASVC/bamtools/src/toolkit/bamtools_stats.cpp
// Function: BamTools::StatsTool::StatsToolPrivate::ProcessAlignment(BamTools::BamAlignment const&)
void StatsTool::StatsToolPrivate::ProcessAlignment(const BamAlignment& al) {
  
    // increment total alignment counter
    ++m_numReads;
    
    // incrememt counters for pairing-independent flags
    if ( al.IsDuplicate() ) ++m_numDuplicates;
    if ( al.IsFailedQC()  ) ++m_numFailedQC;
    if ( al.IsMapped()    ) ++m_numMapped;
    
    // increment strand counters
    if ( al.IsReverseStrand() ) 
        ++m_numReverseStrand;
    else 
        ++m_numForwardStrand;
    
    // if alignment is paired-end
    if ( al.IsPaired() ) {
      
        // increment PE counter
        ++m_numPaired;
      
        // increment first mate/second mate counters
        if ( al.IsFirstMate()  ) ++m_numFirstMate;
        if ( al.IsSecondMate() ) ++m_numSecondMate;
        
        // if alignment is mapped, check mate status
        if ( al.IsMapped() ) {
            // if mate mapped
            if ( al.IsMateMapped() ) 
                ++m_numBothMatesMapped;
            // else singleton
            else 
                ++m_numSingletons;
        }
        
        // check for explicit proper pair flag
        if ( al.IsProperPair() )
            ++m_numProperPair;
        
        // store insert size for first mate 
        if ( m_settings->IsShowingInsertSizeSummary && al.IsFirstMate() && (al.InsertSize != 0) ) {
            int insertSize = abs(al.InsertSize);
            m_insertSizes.push_back( insertSize );
        }
    }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq 0x18(%rsp), %rdi
callq 0x86e20
testb $0x1, %al
jne 0x107861
jmp 0x10786f
movq 0x8(%rsp), %rax
movl 0x34(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x34(%rax)
movq 0x18(%rsp), %rdi
callq 0x867c0
testb $0x1, %al
jne 0x10787f
jmp 0x10788d
movq 0x8(%rsp), %rax
movl 0x30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq 0x18(%rsp), %rdi
callq 0x860f0
testb $0x1, %al
jne 0x10789d
jmp 0x1078ab
movq 0x8(%rsp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movq 0x18(%rsp), %rdi
callq 0x86a40
testb $0x1, %al
jne 0x1078bb
jmp 0x1078cb
movq 0x8(%rsp), %rax
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
jmp 0x1078d9
movq 0x8(%rsp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
movq 0x18(%rsp), %rdi
callq 0x863d0
testb $0x1, %al
jne 0x1078ec
jmp 0x1079eb
movq 0x8(%rsp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq 0x18(%rsp), %rdi
callq 0x86340
testb $0x1, %al
jne 0x10790a
jmp 0x107918
movq 0x8(%rsp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
movq 0x18(%rsp), %rdi
callq 0x86df0
testb $0x1, %al
jne 0x107928
jmp 0x107936
movq 0x8(%rsp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movq 0x18(%rsp), %rdi
callq 0x860f0
testb $0x1, %al
jne 0x107946
jmp 0x107976
movq 0x18(%rsp), %rdi
callq 0x86880
testb $0x1, %al
jne 0x107956
jmp 0x107966
movq 0x8(%rsp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x107974
movq 0x8(%rsp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
jmp 0x107976
movq 0x18(%rsp), %rdi
callq 0x86ec0
testb $0x1, %al
jne 0x107986
jmp 0x107994
movq 0x8(%rsp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq 0x8(%rsp), %rax
movq (%rax), %rax
testb $0x1, 0x2(%rax)
je 0x1079e9
movq 0x18(%rsp), %rdi
callq 0x86340
testb $0x1, %al
jne 0x1079b2
jmp 0x1079e9
movq 0x18(%rsp), %rax
cmpl $0x0, 0xd8(%rax)
je 0x1079e9
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rax
movl 0xd8(%rax), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, 0x14(%rsp)
addq $0x38, %rdi
leaq 0x14(%rsp), %rsi
callq 0xd2500
jmp 0x1079eb
addq $0x28, %rsp
retq