// File: /workspace/github_cpp_makefile_star2_O2/afinit[P]afin/extension.cpp
// Function: Extension::build_string()
void Extension::build_string(){
  string ATCGstr( "ATCG" );

  // loop len times processing 1 basepair at a time
  for( int i=0; i<len; i++ ){
    vector<int> ATCG_curr = { 0,0,0,0 };
    int max = 0;
    int avg = 0;
    
    // check coverage at current position
    if( matches.check_cov( start+(pos_mult*i) ) < min_cov ){
      break;
    }
    
    int next_char = 0;

    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]++;
      }
    }

    // find character with greatest appearance
    for( int j=1; j<4; j++ ){
      if( ATCG_curr[j] > ATCG_curr[max] ) {
        max = j;
      }
    }

    // add next base
    if( back ){
      exten_seq.append( ATCGstr.substr( max, 1 ) );
    }
    else{
      exten_seq.insert( 0, ATCGstr.substr( max, 1 ) );
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
leaq 0x3ddc(%rip), %rsi      # 0x13671
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %r15
movq %r15, %rdx
callq 0x4120
leaq 0xa8(%rbx), %rax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
leaq -0x50(%rbp), %r12
cmpl 0xcc(%rbx), %r14d
jge 0xf9ff
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movq %r12, %rdi
movq %r15, %rsi
pushq $0x4
popq %rdx
leaq -0x29(%rbp), %rcx
callq 0xfc24
movl 0xc8(%rbx), %esi
imull %r14d, %esi
addl 0x80(%rbx), %esi
movq %rbx, %rdi
callq 0xba36
leaq 0xbd26(%rip), %rcx      # 0x1b628
cmpl (%rcx), %eax
jl 0xf9f6
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0xb3dc
cmpq %r13, %rax
jbe 0xf974
movl 0xc8(%rbx), %edx
imull %r14d, %edx
addl 0x80(%rbx), %edx
movq %rbx, %rdi
movl %r13d, %esi
callq 0xb3fa
cmpb $0x54, %al
je 0xf965
movzbl %al, %eax
cmpl $0x43, %eax
je 0xf951
cmpl $0x47, %eax
je 0xf95b
cmpl $0x41, %eax
jne 0xf96f
movq -0x50(%rbp), %rax
jmp 0xf96d
movq -0x50(%rbp), %rax
addq $0x8, %rax
jmp 0xf96d
movq -0x50(%rbp), %rax
addq $0xc, %rax
jmp 0xf96d
movq -0x50(%rbp), %rax
addq $0x4, %rax
incl (%rax)
incq %r13
jmp 0xf90d
xorl %esi, %esi
movq -0x50(%rbp), %rax
pushq $0x1
popq %rcx
movslq %esi, %rdx
cmpq $0x4, %rcx
je 0xf99b
movl (%rax,%rcx,4), %r8d
movl %ecx, %edi
cmpl (%rax,%rdx,4), %r8d
jg 0xf994
movl %esi, %edi
incq %rcx
movl %edi, %esi
jmp 0xf97d
cmpb $0x0, 0x84(%rbx)
je 0xf9c1
movq %r15, %rdi
leaq -0x70(%rbp), %rsi
pushq $0x1
popq %rcx
callq 0x4330
movq -0x38(%rbp), %rdi
movq %r15, %rsi
callq 0x4630
jmp 0xf9de
movq %r15, %rdi
leaq -0x70(%rbp), %rsi
pushq $0x1
popq %rcx
callq 0x4330
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x4500
movq %r15, %rdi
callq 0x4160
movq %r12, %rdi
callq 0x5b30
incl %r14d
jmp 0xf8ba
leaq -0x50(%rbp), %rdi
callq 0x5b30
leaq -0x70(%rbp), %rdi
callq 0x4160
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfa1b
jmp 0xfa35
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x4160
jmp 0xfa38
jmp 0xfa35
movq %rax, %rbx
jmp 0xfa41
jmp 0xfa35
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x5b30
leaq -0x70(%rbp), %rdi
callq 0x4160
movq %rbx, %rdi
callq 0x4590