// File: afinit[P]afin/extension.cpp
// Function: Extension::bp_count()
void Extension::bp_count(){
  for( int i=0; i<len; i++ ){
    // initialize temporary vector 
    vector<int> ATCG_curr = { 0,0,0,0,0 };
    int next_char = 0;

    // loop through matches to get count of each nucleotide present at the current position
    for( int j=0; j<matches.get_matchlist_size(); j++ ){
      next_char = matches.get_pos( j, start+(pos_mult*i) );

      if ( next_char == 'A' ) {
        ATCG_curr[0]++;
      }
      else if ( next_char == 'T' ) {
        ATCG_curr[1]++;
      }
      else if ( next_char == 'C' ) {
        ATCG_curr[2]++;
      }
      else if ( next_char == 'G' ) {
        ATCG_curr[3]++;
      }
    }

    // determine maximum number of any nucleotide 
    for( int j=0; j<4; j++ ){
      if( ATCG_curr[j] > ATCG_curr[4] ){
        ATCG_curr[4] = ATCG_curr[j];
      }
    }

    // check coverage level and break if below min
    if( ATCG_curr[4] < min_cov ){
      len = i;
      break;
    }

    // initialize next bp to 0 for each nucleotide
    ATCG.push_back( ATCG_curr );
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x80(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0xcc(%rcx), %eax
jge 0x24fe5
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movl $0x0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movl $0x0, -0x40(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x5, -0x30(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0xcd30
movq -0x88(%rbp), %rcx
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x28(%rbp), %rdi
callq 0x25c20
jmp 0x24dc4
leaq -0x51(%rbp), %rdi
callq 0x8a20
movl $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movq -0x80(%rbp), %rdi
movslq -0x6c(%rbp), %rax
movq %rax, -0x98(%rbp)
callq 0x17330
movq %rax, -0x90(%rbp)
jmp 0x24df8
movq -0x98(%rbp), %rax
movq -0x90(%rbp), %rcx
cmpq %rcx, %rax
jae 0x24f01
movq -0x80(%rbp), %rdi
movl -0x6c(%rbp), %esi
movl 0x80(%rdi), %edx
movl 0xc8(%rdi), %eax
movl -0xc(%rbp), %ecx
imull %ecx, %eax
addl %eax, %edx
callq 0x17350
movb %al, -0x99(%rbp)
jmp 0x24e37
movb -0x99(%rbp), %al
movsbl %al, %eax
movl %eax, -0x68(%rbp)
cmpl $0x41, -0x68(%rbp)
jne 0x24e96
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x24ef1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x8a20
jmp 0x24fee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x6b60
jmp 0x24fee
cmpl $0x54, -0x68(%rbp)
jne 0x24eb3
leaq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x24eef
cmpl $0x43, -0x68(%rbp)
jne 0x24ed0
leaq -0x28(%rbp), %rdi
movl $0x2, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x24eed
cmpl $0x47, -0x68(%rbp)
jne 0x24eeb
leaq -0x28(%rbp), %rdi
movl $0x3, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x24eed
jmp 0x24eef
jmp 0x24ef1
jmp 0x24ef3
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x24ddb
movl $0x0, -0x70(%rbp)
cmpl $0x4, -0x70(%rbp)
jge 0x24f76
movslq -0x70(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x153d0
movl (%rax), %eax
movl %eax, -0xa0(%rbp)
leaq -0x28(%rbp), %rdi
movl $0x4, %esi
callq 0x153d0
movq %rax, %rcx
movl -0xa0(%rbp), %eax
cmpl (%rcx), %eax
jle 0x24f69
movslq -0x70(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x153d0
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
leaq -0x28(%rbp), %rdi
movl $0x4, %esi
callq 0x153d0
movl -0xa4(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x24f6b
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x24f08
leaq -0x28(%rbp), %rdi
movl $0x4, %esi
callq 0x153d0
movl (%rax), %eax
leaq 0x1973b(%rip), %rcx     # 0x3e6c8
cmpl (%rcx), %eax
jge 0x24fa7
movq -0x80(%rbp), %rax
movl -0xc(%rbp), %ecx
movl %ecx, 0xcc(%rax)
movl $0x2, -0x74(%rbp)
jmp 0x24fc1
movq -0x80(%rbp), %rdi
addq $0x50, %rdi
leaq -0x28(%rbp), %rsi
callq 0x25ca0
jmp 0x24fba
movl $0x0, -0x74(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x6b60
movl -0x74(%rbp), %eax
testl %eax, %eax
je 0x24fd5
jmp 0x24fd3
jmp 0x24fe5
jmp 0x24fd7
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x24d5e
addq $0xb0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x46c0
nopw (%rax,%rax)