// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x46e0
movq -0xe0(%rbp), %rdx
leaq 0x74f0(%rip), %rsi      # 0x2c938
leaq -0x28(%rbp), %rdi
callq 0x4530
jmp 0x25453
leaq -0x29(%rbp), %rdi
callq 0x4420
movl $0x0, -0x40(%rbp)
movq -0xe8(%rbp), %rcx
movl -0x40(%rbp), %eax
cmpl 0xcc(%rcx), %eax
jge 0x25829
movl $0x0, -0x78(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x0, -0x6c(%rbp)
leaq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x4, -0x60(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0xcd30
movq -0xf0(%rbp), %rcx
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x25c20
jmp 0x254cf
leaq -0x79(%rbp), %rdi
callq 0x8a20
movq -0xe8(%rbp), %rdi
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl 0x80(%rdi), %esi
movl 0xc8(%rdi), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
addl %eax, %esi
callq 0x17e10
movl %eax, -0xf4(%rbp)
jmp 0x25511
movl -0xf4(%rbp), %eax
leaq 0x191aa(%rip), %rcx     # 0x3e6c8
cmpl (%rcx), %eax
jge 0x25576
movl $0x2, -0x88(%rbp)
jmp 0x257f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x4420
jmp 0x25844
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x8a20
jmp 0x2583b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x2581e
movl $0x0, -0x8c(%rbp)
movl $0x0, -0x90(%rbp)
movq -0xe8(%rbp), %rdi
movslq -0x90(%rbp), %rax
movq %rax, -0x108(%rbp)
callq 0x17330
movq %rax, -0x100(%rbp)
jmp 0x255ad
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rcx
cmpq %rcx, %rax
jae 0x2569a
movq -0xe8(%rbp), %rdi
movl -0x90(%rbp), %esi
movl 0x80(%rdi), %edx
movl 0xc8(%rdi), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
addl %eax, %edx
callq 0x17350
movb %al, -0x109(%rbp)
jmp 0x255f2
movb -0x109(%rbp), %al
movsbl %al, %eax
movl %eax, -0x8c(%rbp)
cmpl $0x41, -0x8c(%rbp)
jne 0x25620
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x25684
cmpl $0x54, -0x8c(%rbp)
jne 0x25640
leaq -0x58(%rbp), %rdi
movl $0x1, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x25682
cmpl $0x43, -0x8c(%rbp)
jne 0x25660
leaq -0x58(%rbp), %rdi
movl $0x2, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x25680
cmpl $0x47, -0x8c(%rbp)
jne 0x2567e
leaq -0x58(%rbp), %rdi
movl $0x3, %esi
callq 0x153d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x25680
jmp 0x25682
jmp 0x25684
jmp 0x25686
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x2558a
movl $0x1, -0x94(%rbp)
cmpl $0x4, -0x94(%rbp)
jge 0x256fb
movslq -0x94(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x153d0
movl (%rax), %eax
movl %eax, -0x110(%rbp)
movslq -0x80(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x153d0
movq %rax, %rcx
movl -0x110(%rbp), %eax
cmpl (%rcx), %eax
jle 0x256e8
movl -0x94(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x256ea
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x256a4
movq -0xe8(%rbp), %rax
testb $0x1, 0x84(%rax)
je 0x2577d
movq -0xe8(%rbp), %rax
addq $0xa8, %rax
movq %rax, -0x118(%rbp)
movslq -0x80(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x1, %ecx
callq 0x43e0
jmp 0x2573a
movq -0x118(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4750
jmp 0x2574f
leaq -0xb8(%rbp), %rdi
callq 0x4270
jmp 0x257ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x4270
jmp 0x2581e
movq -0xe8(%rbp), %rax
addq $0xa8, %rax
movq %rax, -0x120(%rbp)
movslq -0x80(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x1, %ecx
callq 0x43e0
jmp 0x257ac
movq -0x120(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0xd8(%rbp), %rdx
callq 0x4620
jmp 0x257c5
leaq -0xd8(%rbp), %rdi
callq 0x4270
jmp 0x257ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4270
jmp 0x2581e
movl $0x0, -0x88(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6b60
movl -0x88(%rbp), %eax
testl %eax, %eax
je 0x2580e
jmp 0x2580c
jmp 0x25829
jmp 0x25810
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x25463
leaq -0x58(%rbp), %rdi
callq 0x6b60
jmp 0x2583b
leaq -0x28(%rbp), %rdi
callq 0x4270
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x4270
movq -0x38(%rbp), %rdi
callq 0x46c0
nopl (%rax)