// File: /workspace/github_cpp_makefile_star2_O3/afinit[P]afin/fusion.cpp
// Function: Fusion::process_fusions()
void Fusion::process_fusions(){
  for( int i=0; i<match_list.size(); i++ ){
    // fuse contigs
    int index_i = match_list[i].get_index_i();
    int index_j = match_list[i].get_index_j();
    string contig_i = contigs->get_contig(index_i).get_sequence();
    string contig_j = contigs->get_contig(index_j).get_sequence();
    string fused_id("");
    string fused("");
    string rev_i("");
    string rev_j("");

    // find the reverse compliment of the contigs where necessary
    if( match_list[i].get_end_i() == 0 ){
      contig_i = revcomp( contig_i );
      rev_i = "_r";
    }
    
    if( match_list[i].get_end_j() == 1 ){
      contig_j = revcomp( contig_j );
      rev_j = "_r";
    }

    contig_fusion_log( match_list[i] );
    fused_id = get_fused_id( contigs->get_contig(index_i).get_contig_id()+rev_i, contigs->get_contig(index_j).get_contig_id()+rev_j );
    fused_id = "fused(" + fused_id + ")";
 
    // push each index onto the remove vector
    contig_remove_list.push_back( index_i );
    contig_remove_list.push_back( index_j );

    // create fused contig
    fused = build_fusion_string( contig_i, contig_j, match_list[i].get_length() );
            
    // commit fusion here
    commit_fusion( fused, fused_id, index_i, index_j );
    int new_index = contigs->get_list_size()-1;

    // check for additional appearances of the current contigs in match_list
    for( int j=i+1; j<match_list.size(); j++ ){
      // change reference index and end variables where necessary
      if( index_i == match_list[j].get_index_i() ){
        match_list[j].set_index_i( new_index );
        match_list[j].set_end_i( 0 );
      }
      else if( index_i == match_list[j].get_index_j() ){
        match_list[j].set_index_j( new_index );
        match_list[j].set_end_j( 0 );
      }
      else if( index_j == match_list[j].get_index_i() ){
        match_list[j].set_index_i( new_index );
        match_list[j].set_end_i( 1 );
      }
      else if( index_j == match_list[j].get_index_j() ){
        match_list[j].set_index_j( new_index );
        match_list[j].set_end_j( 1 );
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
cmpq %rdi, 0x18(%rbx)
je 0xcf0c
leaq 0x28(%rbx), %rax
movq %rax, -0x78(%rbp)
movl $0x1, %eax
movq %rax, -0x88(%rbp)
movl $0x20, %eax
movq %rax, -0x80(%rbp)
xorl %r14d, %r14d
movq %r14, %r13
shlq $0x5, %r13
addq %r13, %rdi
callq 0x965e
movl %eax, -0x30(%rbp)
movq 0x10(%rbx), %rdi
addq %r13, %rdi
callq 0x9668
movl %eax, -0x2c(%rbp)
movq (%rbx), %rsi
movl -0x30(%rbp), %edx
leaq -0x198(%rbp), %r15
movq %r15, %rdi
callq 0x13d9c
leaq -0x148(%rbp), %rdi
movq %r15, %rsi
callq 0x5c92
movq %r15, %rdi
callq 0x59be
movq (%rbx), %rsi
movl -0x2c(%rbp), %edx
movq %r15, %rdi
callq 0x13d9c
leaq -0x128(%rbp), %rdi
movq %r15, %rsi
callq 0x5c92
movq %r15, %rdi
callq 0x59be
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
leaq 0x984a(%rip), %r15      # 0x15f4c
movq %r15, %rsi
movq %r15, %rdx
callq 0x6be0
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x6be0
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0xc8(%rbp), %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x6be0
leaq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x6be0
movq 0x10(%rbx), %rdi
addq %r13, %rdi
callq 0x9672
testl %eax, %eax
jne 0xc819
leaq -0x250(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rdx
addq %rsi, %rdx
leaq -0x260(%rbp), %r12
movq %r12, %rdi
callq 0x68f6
leaq -0x198(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x94d8
leaq -0x148(%rbp), %rdi
movq %r15, %rsi
callq 0x43b0
movq -0x198(%rbp), %rdi
leaq -0x188(%rbp), %rax
cmpq %rax, %rdi
je 0xc7df
callq 0x42f0
movq -0x260(%rbp), %rdi
leaq -0x250(%rbp), %rax
cmpq %rax, %rdi
je 0xc7f7
callq 0x42f0
movq -0xc0(%rbp), %rdx
movl $0x2, %r8d
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
leaq 0x997a(%rip), %rcx      # 0x1618e
callq 0x44f0
movq 0x10(%rbx), %rdi
addq %r13, %rdi
callq 0x967c
cmpl $0x1, %eax
jne 0xc8cf
leaq -0x230(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
addq %rsi, %rdx
leaq -0x240(%rbp), %r12
movq %r12, %rdi
callq 0x68f6
leaq -0x198(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x94d8
leaq -0x128(%rbp), %rdi
movq %r15, %rsi
callq 0x43b0
movq -0x198(%rbp), %rdi
leaq -0x188(%rbp), %rax
cmpq %rax, %rdi
je 0xc895
callq 0x42f0
movq -0x240(%rbp), %rdi
leaq -0x230(%rbp), %rax
cmpq %rax, %rdi
je 0xc8ad
callq 0x42f0
movq -0xa0(%rbp), %rdx
movl $0x2, %r8d
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
leaq 0x98c4(%rip), %rcx      # 0x1618e
callq 0x44f0
movq 0x10(%rbx), %rax
movups (%rax,%r13), %xmm0
movups 0x10(%rax,%r13), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0xa3a0
movq (%rbx), %rsi
movl -0x30(%rbp), %edx
leaq -0x198(%rbp), %r15
movq %r15, %rdi
callq 0x13d9c
leaq -0x2a0(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x5cc0
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq %r12, %rdi
callq 0x40f0
leaq -0xf8(%rbp), %rsi
movq %rsi, -0x108(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq -0x2f0(%rbp), %r15
je 0xc963
movq %rdx, -0x108(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xf8(%rbp)
jmp 0xc969
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x100(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rbx), %rsi
movl -0x2c(%rbp), %edx
movq %r15, %rdi
callq 0x13d9c
leaq -0x280(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x5cc0
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq %r12, %rdi
callq 0x40f0
leaq -0xd8(%rbp), %rsi
movq %rsi, -0xe8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq -0x310(%rbp), %r15
je 0xc9f0
movq %rdx, -0xe8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xd8(%rbp)
jmp 0xc9f6
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0xe0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r15, %rdi
leaq -0x108(%rbp), %rdx
leaq -0xe8(%rbp), %rcx
callq 0xa21c
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x43b0
movq -0x310(%rbp), %rdi
leaq -0x300(%rbp), %rax
cmpq %rax, %rdi
je 0xca4a
callq 0x42f0
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0xca62
callq 0x42f0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rax
cmpq %rax, %rdi
je 0xca7a
callq 0x42f0
leaq -0x2f0(%rbp), %rdi
callq 0x59be
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0xca9e
callq 0x42f0
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0xcab6
callq 0x42f0
leaq -0x198(%rbp), %rdi
callq 0x59be
leaq -0x2f0(%rbp), %r12
movq %r12, %rdi
leaq 0x96be(%rip), %rsi      # 0x16191
leaq -0x50(%rbp), %rdx
callq 0xd79e
movq %r14, %r15
movq %r12, %rdi
leaq 0x973a(%rip), %rsi      # 0x16223
callq 0x45f0
leaq -0x188(%rbp), %r14
movq %r14, -0x198(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xcb1e
movq %rdx, -0x198(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x188(%rbp)
jmp 0xcb25
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x190(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x50(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x43b0
movq -0x198(%rbp), %rdi
cmpq %r14, %rdi
je 0xcb60
callq 0x42f0
movq -0x2f0(%rbp), %rdi
leaq -0x2e0(%rbp), %rax
cmpq %rax, %rdi
movq %r15, %r14
je 0xcb7b
callq 0x42f0
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rax
cmpq %rax, %rsi
je 0xcb97
movl -0x30(%rbp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x30(%rbx)
jmp 0xcbac
movq -0x78(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0xda1a
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rax
cmpq %rax, %rsi
je 0xcbc0
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x30(%rbx)
jmp 0xcbcd
movq -0x78(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0xda1a
leaq -0x1f0(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rdx
addq %rsi, %rdx
leaq -0x200(%rbp), %rdi
callq 0x68f6
leaq -0x1d0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
addq %rsi, %rdx
leaq -0x1e0(%rbp), %rdi
callq 0x68f6
addq 0x10(%rbx), %r13
movq %r13, %rdi
callq 0x9654
leaq -0x198(%rbp), %r15
movq %r15, %rdi
leaq -0x200(%rbp), %rdx
leaq -0x1e0(%rbp), %rcx
movl %eax, %r8d
callq 0xb890
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x43b0
movq -0x198(%rbp), %rdi
leaq -0x188(%rbp), %rax
cmpq %rax, %rdi
je 0xcc73
callq 0x42f0
movq -0x1e0(%rbp), %rdi
leaq -0x1d0(%rbp), %rax
cmpq %rax, %rdi
je 0xcc8b
callq 0x42f0
movq -0x200(%rbp), %rdi
leaq -0x1f0(%rbp), %rax
cmpq %rax, %rdi
je 0xcca3
callq 0x42f0
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0x1c0(%rbp), %rdi
callq 0x68f6
leaq -0x210(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x220(%rbp), %r15
movq %r15, %rdi
callq 0x68f6
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movq %rbx, %rdi
leaq -0x1c0(%rbp), %rsi
movq %r15, %rdx
callq 0xa8f8
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rax
cmpq %rax, %rdi
je 0xcd21
callq 0x42f0
movq -0x1c0(%rbp), %rdi
leaq -0x1b0(%rbp), %rax
cmpq %rax, %rdi
je 0xcd39
callq 0x42f0
movq (%rbx), %rdi
callq 0x13ddc
movl %eax, %r13d
incq %r14
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rax
subq %rdi, %rax
sarq $0x5, %rax
movq %r14, -0x1a0(%rbp)
cmpq %r14, %rax
jbe 0xce5d
decl %r13d
movq -0x80(%rbp), %r12
movq -0x88(%rbp), %r15
movl -0x30(%rbp), %r14d
addq %r12, %rdi
callq 0x965e
cmpl %eax, %r14d
jne 0xcda8
movq 0x10(%rbx), %rdi
addq %r12, %rdi
xorl %r14d, %r14d
movl %r13d, %esi
callq 0x9616
movq 0x10(%rbx), %rdi
addq %r12, %rdi
movl %r14d, %esi
callq 0x9636
jmp 0xcdde
movl -0x30(%rbp), %r14d
movq 0x10(%rbx), %rdi
addq %r12, %rdi
callq 0x9668
cmpl %eax, %r14d
jne 0xcdff
movq 0x10(%rbx), %rdi
addq %r12, %rdi
xorl %r14d, %r14d
movl %r13d, %esi
callq 0x9620
movq 0x10(%rbx), %rdi
addq %r12, %rdi
movl %r14d, %esi
callq 0x9640
incq %r15
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rax
subq %rdi, %rax
sarq $0x5, %rax
addq $0x20, %r12
cmpq %r15, %rax
ja 0xcd74
jmp 0xce5d
movl -0x2c(%rbp), %r14d
movq 0x10(%rbx), %rdi
addq %r12, %rdi
callq 0x965e
cmpl %eax, %r14d
jne 0xce2e
movq 0x10(%rbx), %rdi
addq %r12, %rdi
movl $0x1, %r14d
movl %r13d, %esi
callq 0x9616
jmp 0xcd97
movl -0x2c(%rbp), %r14d
movq 0x10(%rbx), %rdi
addq %r12, %rdi
callq 0x9668
cmpl %eax, %r14d
jne 0xcdde
movq 0x10(%rbx), %rdi
addq %r12, %rdi
movl $0x1, %r14d
movl %r13d, %esi
callq 0x9620
jmp 0xcdcf
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xce75
callq 0x42f0
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %r12
cmpq %r12, %rdi
leaq -0x40(%rbp), %r14
leaq -0x60(%rbp), %r15
je 0xce95
callq 0x42f0
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0xcea3
callq 0x42f0
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
movq -0x1a0(%rbp), %r14
je 0xceb8
callq 0x42f0
movq -0x128(%rbp), %rdi
leaq -0x118(%rbp), %rax
cmpq %rax, %rdi
je 0xced0
callq 0x42f0
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0xcee8
callq 0x42f0
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rax
subq %rdi, %rax
sarq $0x5, %rax
incq -0x88(%rbp)
addq $0x20, -0x80(%rbp)
cmpq %r14, %rax
ja 0xc67d
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x260(%rbp), %rdi
leaq -0x250(%rbp), %rax
jmp 0xd0e7
jmp 0xd0f5
jmp 0xd0f5
movq %rax, %rbx
movq -0x240(%rbp), %rdi
leaq -0x230(%rbp), %rax
jmp 0xd0e7
movq %rax, %rbx
jmp 0xcf74
movq %rax, %rbx
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rax
cmpq %rax, %rdi
je 0xcf74
callq 0x42f0
movq -0x1c0(%rbp), %rdi
leaq -0x1b0(%rbp), %rax
jmp 0xd0e7
jmp 0xd0f5
movq %rax, %rbx
jmp 0xcfc9
movq %rax, %rbx
jmp 0xcfb1
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0xcfb1
callq 0x42f0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rax
cmpq %rax, %rdi
je 0xcfc9
callq 0x42f0
leaq -0x2f0(%rbp), %rdi
callq 0x59be
jmp 0xd078
jmp 0xd0f5
movq %rax, %rbx
movq -0x2f0(%rbp), %rdi
leaq -0x2e0(%rbp), %rax
jmp 0xd0e7
jmp 0xd0f5
movq %rax, %rbx
jmp 0xd0d9
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x59be
jmp 0xd17c
movq %rax, %rbx
jmp 0xd164
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x59be
jmp 0xd164
movq %rax, %rbx
jmp 0xd14c
movq %rax, %rbx
leaq -0x40(%rbp), %r14
jmp 0xd13e
movq %rax, %rbx
leaq -0x40(%rbp), %r14
leaq -0x60(%rbp), %r15
jmp 0xd130
movq %rax, %rbx
leaq -0x40(%rbp), %r14
leaq -0x60(%rbp), %r15
jmp 0xd118
jmp 0xd0f5
movq %rax, %rbx
jmp 0xd0a8
movq %rax, %rbx
jmp 0xd090
movq %rax, %rbx
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0xd090
callq 0x42f0
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0xd0a8
callq 0x42f0
leaq -0x40(%rbp), %r14
leaq -0x60(%rbp), %r15
leaq -0x198(%rbp), %rdi
callq 0x59be
jmp 0xd100
movq %rax, %rbx
movq -0x1e0(%rbp), %rdi
leaq -0x1d0(%rbp), %rax
cmpq %rax, %rdi
je 0xd0d9
callq 0x42f0
movq -0x200(%rbp), %rdi
leaq -0x1f0(%rbp), %rax
cmpq %rax, %rdi
je 0xd0f8
callq 0x42f0
jmp 0xd0f8
jmp 0xd0f5
movq %rax, %rbx
leaq -0x40(%rbp), %r14
leaq -0x60(%rbp), %r15
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xd118
callq 0x42f0
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xd130
callq 0x42f0
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0xd13e
callq 0x42f0
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0xd14c
callq 0x42f0
movq -0x128(%rbp), %rdi
leaq -0x118(%rbp), %rax
cmpq %rax, %rdi
je 0xd164
callq 0x42f0
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0xd17c
callq 0x42f0
movq %rbx, %rdi
callq 0x4590