// File: /workspace/github_cpp_makefile_star2_O1/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 -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x3cf2(%rip), %rsi      # 0x16671
leaq 0x3cef(%rip), %rdx      # 0x16675
leaq -0x90(%rbp), %rdi
callq 0x6b5c
cmpl $0x0, 0xcc(%rbx)
jle 0x12b36
leaq 0xa8(%rbx), %rax
movq %rax, -0x58(%rbp)
xorl %r12d, %r12d
leaq -0x50(%rbp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movl $0x4, %edx
leaq -0x70(%rbp), %rdi
movq %r13, %rsi
leaq -0x29(%rbp), %rcx
callq 0x12e0c
movl 0xc8(%rbx), %esi
imull %r12d, %esi
addl 0x80(%rbx), %esi
movq %rbx, %rdi
callq 0xe366
movl %eax, %r15d
leaq 0xac29(%rip), %rax      # 0x1d618
movl (%rax), %r14d
cmpl %r14d, %r15d
jl 0x12b28
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0xdaf2
cmpq %r13, %rax
jbe 0x12a6b
movl 0xc8(%rbx), %edx
imull %r12d, %edx
addl 0x80(%rbx), %edx
movq %rbx, %rdi
movl %r13d, %esi
callq 0xdb12
movzbl %al, %eax
cmpl $0x46, %eax
jg 0x12a42
cmpl $0x41, %eax
je 0x12a56
cmpl $0x43, %eax
jne 0x12a66
movq -0x70(%rbp), %rax
addq $0x8, %rax
jmp 0x12a64
cmpl $0x47, %eax
je 0x12a5c
cmpl $0x54, %eax
jne 0x12a66
movq -0x70(%rbp), %rax
addq $0x4, %rax
jmp 0x12a64
movq -0x70(%rbp), %rax
jmp 0x12a64
movq -0x70(%rbp), %rax
addq $0xc, %rax
incl (%rax)
incq %r13
jmp 0x129fe
xorl %edx, %edx
movl $0x1, %eax
movq -0x70(%rbp), %rcx
leaq -0x50(%rbp), %r13
movl (%rcx,%rax,4), %edi
movslq %edx, %r8
movl %eax, %esi
cmpl (%rcx,%r8,4), %edi
jg 0x12a8a
movl %edx, %esi
incq %rax
movl %esi, %edx
cmpq $0x4, %rax
jne 0x12a7a
movslq %esi, %rdx
cmpb $0x0, 0x84(%rbx)
je 0x12ac8
movl $0x1, %ecx
movq %r13, %rdi
leaq -0x90(%rbp), %rsi
callq 0x4330
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x58(%rbp), %rdi
callq 0x40f0
jmp 0x12af1
movl $0x1, %ecx
movq %r13, %rdi
leaq -0x90(%rbp), %rsi
callq 0x4330
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x58(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4350
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x12b03
callq 0x42f0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x12b11
callq 0x42f0
cmpl %r14d, %r15d
jl 0x12b36
incl %r12d
cmpl 0xcc(%rbx), %r12d
jl 0x129b1
jmp 0x12b36
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x12b36
callq 0x42f0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x12b4b
callq 0x42f0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12b5e
jmp 0x12b7e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x12b81
callq 0x42f0
jmp 0x12b81
jmp 0x12b7e
jmp 0x12b7e
movq %rax, %rbx
jmp 0x12b8f
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x12b8f
callq 0x42f0
leaq -0x80(%rbp), %rax
movq -0x90(%rbp), %rdi
cmpq %rax, %rdi
je 0x12ba4
callq 0x42f0
movq %rbx, %rdi
callq 0x4590