// File: /workspace/github_c_makefile_star2_O2/fukunagatsu[P]RIblast/gapped_extension.cpp
// Function: GappedExtension::extension(Hit&, std::vector<unsigned char, std::allocator<unsigned char>>&, std::vector<unsigned char, std::allocator<unsigned char>>&, std::vector<float, std::allocator<float>>&, std::vector<float, std::allocator<float>>&, std::vector<std::vector<float, std::allocator<float>>, std::allocator<std::vector<float, std::allocator<float>>>>&, std::vector<std::vector<float, std::allocator<float>>, std::allocator<std::vector<float, std::allocator<float>>>>&, bool)
void GappedExtension::extension(Hit &candidate, vector<unsigned char> &query_seq, vector<unsigned char> &db_seq, vector<float> &query_accessibility, vector<float> &query_conditional_accessibility, vector<vector<float> > &db_accessibility,vector<vector<float> > &db_conditional_accessibility, bool flag){
  CheckStemCandidate stem_check(_drop_out_score);
  double min_energy = candidate.GetEnergy();
  double first_a_energy = candidate.GetAccessibilityEnergy();
  double min_a_energy = first_a_energy;
  int q_start = 0;
  int db_start = 0;
  if(flag == 0){
    q_start = candidate.GetQSp();  
    db_start = candidate.GetDbSp(); 
  }else{
    q_start = candidate.GetQSp()+ candidate.GetQLength()-1;
    db_start = candidate.GetDbSp()+ candidate.GetDbLength()-1;
  }
   
  int max_q_extension = MAX_EXTENSION;
  int max_db_extension = MAX_EXTENSION;
  int db_seq_id = candidate.GetDbSeqId();
  int db_seq_id_start = candidate.GetDbSeqIdStart();
  int db_seq_id_end = db_seq_id_start + candidate.GetDbLength()-1;

  int min_q_start = q_start;
  int min_db_start = db_start;
  int q_length = candidate.GetQLength(); 
  int db_length = candidate.GetDbLength();
  int min_q_length = candidate.GetQLength(); 
  int min_db_length = candidate.GetDbLength();
  int min_db_seq_id_start = db_seq_id_start;

  int length = 0;
  int min_length = 0;
  vector<vector<Cell> > matrix_c; matrix_c.resize(100,vector<Cell>(100, Cell(-1,-1, 0, INF)));
  vector<double> extension_q_accessibility; extension_q_accessibility.reserve(100);
  vector<double> extension_db_accessibility;extension_db_accessibility.reserve(100);

  int q_char = GetChar(query_seq,q_start);
  int db_char = GetChar(db_seq,db_start);
  int type = BP_pair[q_char][db_char];
  
  if(flag == 0){type = rtype[type];}
  matrix_c[0][0].set(-1,-1,type,min_energy);
  vector<Stem> stem_candidate; stem_candidate.reserve(100);
  Stem temp_stem(0,0, type);
  stem_candidate.push_back(temp_stem);
  
  while(true){
    length++;
    stem_check.SetLength(length);
    if(flag == 0){
      if(max_q_extension == MAX_EXTENSION){
	if(q_start-length < 0 || query_seq[q_start-length] < 2){ max_q_extension = length-1;}
      }
      if(max_db_extension == MAX_EXTENSION){
	if(db_start-length < 0 || db_seq[db_start-length] < 2){max_db_extension = length-1;}
      }
    }else{
      if(max_q_extension == MAX_EXTENSION){
	if(query_seq[q_start+length] < 2){ max_q_extension = length-1;}
      }
      if(max_db_extension == MAX_EXTENSION){
	if(db_seq[db_start+length]  < 2){max_db_extension = length-1;}
      }
    }
    
    if(flag == 0){
      if(length == 1){
	if(max_q_extension == MAX_EXTENSION){
	  extension_q_accessibility.push_back(query_accessibility[q_start-length] - query_accessibility[q_start-length+1] + query_conditional_accessibility[q_start-length+_min_accessible_length]);
	}
	if(max_db_extension == MAX_EXTENSION){
	  extension_db_accessibility.push_back(db_conditional_accessibility[db_seq_id][db_seq_id_end+length]);
	}
      }else{
	if(max_q_extension == MAX_EXTENSION){
	  extension_q_accessibility.push_back(extension_q_accessibility[length-2]+query_accessibility[q_start-length] - query_accessibility[q_start-length+1] + query_conditional_accessibility[q_start-length+_min_accessible_length]);
	}
	if(max_db_extension == MAX_EXTENSION){
	  extension_db_accessibility.push_back(extension_db_accessibility[length-2]+db_conditional_accessibility[db_seq_id][db_seq_id_end+length]);
	}
      }
    }else{
      if(length == 1){
	if(max_q_extension == MAX_EXTENSION){
	  extension_q_accessibility.push_back(query_conditional_accessibility[q_start+length]);
	}
	if(max_db_extension == MAX_EXTENSION){
	  extension_db_accessibility.push_back(db_accessibility[db_seq_id][db_seq_id_start-length] - db_accessibility[db_seq_id][db_seq_id_start-length+1] + db_conditional_accessibility[db_seq_id][db_seq_id_start-length+_min_accessible_length]);
	}
      }else{
	if(max_q_extension == MAX_EXTENSION){
	  extension_q_accessibility.push_back(extension_q_accessibility[length-2]+query_conditional_accessibility[q_start+length]);
	}
	if(max_db_extension == MAX_EXTENSION){
	  extension_db_accessibility.push_back(extension_db_accessibility[length-2]+db_accessibility[db_seq_id][db_seq_id_start-length] - db_accessibility[db_seq_id][db_seq_id_start-length+1] + db_conditional_accessibility[db_seq_id][db_seq_id_start-length+_min_accessible_length]);
	}
      }
    }
    if(length-2 > _drop_out_score){      
      stem_candidate.erase(remove_if(stem_candidate.begin(), stem_candidate.end(),stem_check), stem_candidate.end());
    }
    for(int i = 1; i <= length-1; i++){
      int j = length-i;
      
      if(i<=max_q_extension && j <=max_db_extension){
	int type = CheckHelixLength(flag, query_seq, db_seq, q_start, db_start, i, j, matrix_c);
	
	if(type!=0){
	  int min_k = -1;
	  int sc_size = stem_candidate.size();
	  double hybrid_energy = INF;
	  
	  for(int k = 0; k < sc_size; k++){
	    Stem this_candidate = stem_candidate[k];
	    if(this_candidate.first < i && this_candidate.second < j){
	      double this_energy = 0.0;
	      if(flag == 0){
		this_energy =  LoopEnergy(type, this_candidate.type, q_start-i, db_start-j, q_start-this_candidate.first, db_start-this_candidate.second, query_seq, db_seq);
	      }else{
	        this_energy =  LoopEnergy(this_candidate.type, type, q_start+this_candidate.first, db_start+this_candidate.second, q_start+i, db_start+j, query_seq, db_seq);
	      }
	      this_energy += matrix_c[this_candidate.first][this_candidate.second].hybrid_energy;
	      
	      if(this_energy < hybrid_energy){
		hybrid_energy =  this_energy;
		min_k = k;
	      }
	    }
	  }
	  
	  matrix_c[i][j].set(stem_candidate[min_k].first, stem_candidate[min_k].second, stem_candidate[min_k].type, hybrid_energy);
	  
	  double interaction_energy = extension_q_accessibility[i-1] + extension_db_accessibility[j-1] + hybrid_energy;
	  
	  stem_candidate.push_back(Stem(i,j,rtype[type]));
	  if(interaction_energy < min_energy){
	    min_energy = interaction_energy;
	    min_a_energy = first_a_energy + extension_q_accessibility[i-1] + extension_db_accessibility[j-1];
	    min_length = length;
	    if(flag == 0){
	      min_q_start = q_start-i;
	      min_db_start = db_start-j;
	    }else{
	      min_db_seq_id_start = db_seq_id_start -j;
	    }
	    min_q_length = q_length+i;
	    min_db_length = db_length+j;
	  }
	}
      }
      
      if(i+1 == matrix_c.size()){
	for(int x = 0; x< matrix_c.size();x++){
	  matrix_c[x].push_back(Cell(-1,-1,0,INF));
	}
	vector<Cell> tempcell_vector; tempcell_vector.resize(matrix_c.size()+1, Cell(-1,-1,0,INF));
	matrix_c.push_back(tempcell_vector);
      }
    }
     
    if(length-min_length>=_drop_out_score){break;}
    if(max_q_extension != MAX_EXTENSION && max_db_extension != MAX_EXTENSION){break;}
  }
 
  if(q_length-min_q_length != 0 && db_length-min_db_length != 0){
    if(flag == 0){
      traceback(candidate,matrix_c, q_start-min_q_start, q_start, db_start-min_db_start,db_start, flag);
    }else{
      traceback(candidate,matrix_c, min_q_length-q_length ,q_start, min_db_length-db_length ,db_start, flag);
    }
  }
  candidate.SetDbSeqIdStart(min_db_seq_id_start);
  if(flag == 0){
    candidate.SetQSp(min_q_start);
    candidate.SetDbSp(min_db_start);
  }
  candidate.SetQLength(min_q_length);
  candidate.SetDbLength(min_db_length);
  candidate.SetEnergy(min_energy);
  candidate.SetAccessibilityEnergy(min_a_energy);
  candidate.SetHybridizationEnergy(min_energy-min_a_energy);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %r9, 0xc8(%rsp)
movq %r8, 0x160(%rsp)
movq %rcx, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rsi, %rbx
movq %rdi, 0x20(%rsp)
movl 0x8(%rsi), %r14d
cmpb $0x0, 0x240(%rsp)
je 0x118f3
movzwl 0x10(%rbx), %eax
movq %rax, 0xd8(%rsp)
addl %eax, %r14d
decl %r14d
movl 0xc(%rbx), %eax
movzwl 0x14(%rbx), %ecx
movq %rcx, 0xd0(%rsp)
leal (%rax,%rcx), %r12d
decl %r12d
jmp 0x1190f
movl 0xc(%rbx), %r12d
movzwl 0x14(%rbx), %eax
movq %rax, 0xd0(%rsp)
movzwl 0x10(%rbx), %eax
movq %rax, 0xd8(%rsp)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
movq %rax, 0x1b0(%rsp)
movsd 0x28(%rbx), %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x178(%rsp)
movslq (%rbx), %rax
movq %rax, 0xc0(%rsp)
movl 0x4(%rbx), %eax
movq %rax, 0x170(%rsp)
andq $0x0, 0x90(%rsp)
leaq 0x110(%rsp), %rdx
orq $-0x1, (%rdx)
andl $0x0, 0x10(%rdx)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movabsq $0x412e848000000000, %r13 # imm = 0x412E848000000000
movq %r13, 0x8(%rdx)
leaq 0xa0(%rsp), %rdi
pushq $0x64
popq %rsi
leaq 0xf0(%rsp), %rcx
callq 0x12dc6
movq %rbx, 0xb8(%rsp)
leaq 0x80(%rsp), %rdi
pushq $0x64
popq %rsi
leaq 0xa0(%rsp), %rdx
movq %rdi, %r15
callq 0x12d8a
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x1303a
xorpd %xmm0, %xmm0
movapd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0xa0(%rsp), %rdi
pushq $0x64
popq %rsi
callq 0x110f6
leaq 0x110(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
pushq $0x64
popq %rsi
callq 0x110f6
movq 0x58(%rsp), %rsi
movl %r14d, %edx
callq 0x1288a
movl %eax, %ebx
movq 0x60(%rsp), %rsi
movl %r12d, %edx
callq 0x1288a
movslq %ebx, %rcx
cltq
imulq $0x14, %rcx, %rcx
leaq 0x9812a(%rip), %rdx     # 0xa9b60
addq %rcx, %rdx
movl (%rdx,%rax,4), %ebx
cmpb $0x0, 0x240(%rsp)
jne 0x11a53
movslq %ebx, %rax
leaq 0x98180(%rip), %rcx     # 0xa9bd0
movl (%rcx,%rax,4), %ebx
movq 0x80(%rsp), %rax
movq (%rax), %rax
orq $-0x1, (%rax)
movl %ebx, 0x10(%rax)
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
xorpd %xmm0, %xmm0
leaq 0xf0(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
pushq $0x64
popq %rsi
callq 0x12e1c
leaq 0x1ec(%rsp), %rsi
andq $0x0, (%rsi)
movl %ebx, 0x8(%rsi)
leaq 0xf0(%rsp), %rdi
callq 0x12ee2
movq 0x170(%rsp), %rdx
movslq %edx, %rax
movq %rax, 0x158(%rsp)
movzbl 0x240(%rsp), %eax
movl %eax, 0x150(%rsp)
movq 0xd0(%rsp), %rcx
leal (%rcx,%rdx), %esi
leal -0x1(%r14), %eax
cltq
movq %rax, 0x1a0(%rsp)
movslq %r14d, %rax
movq %rax, 0x50(%rsp)
movq %rsi, 0x1a8(%rsp)
movslq %esi, %rax
movq %rax, 0x198(%rsp)
leal -0x1(%rdx), %eax
movslq %r12d, %rsi
movq %rsi, 0x128(%rsp)
movl $0x186a0, %edi          # imm = 0x186A0
pushq $0x1
popq %rsi
movq %r14, %r8
leaq 0x30(%rsp), %r14
cltq
movq %rax, 0x190(%rsp)
movsd 0x178(%rsp), %xmm0
movsd %xmm0, 0x168(%rsp)
xorl %ebx, %ebx
movq %rsi, 0x180(%rsp)
movl $0x0, 0x7c(%rsp)
movl %edx, 0x14(%rsp)
movl %ecx, 0x74(%rsp)
movq 0xd8(%rsp), %rax
movl %eax, 0x78(%rsp)
movl %r12d, 0x18(%rsp)
movq %r8, 0x68(%rsp)
movl %r8d, 0x1c(%rsp)
movl $0x186a0, (%rsp)        # imm = 0x186A0
movq %r12, 0xe8(%rsp)
leaq 0x1(%rbx), %r8
cmpb $0x0, 0x240(%rsp)
movq %r8, 0x8(%rsp)
je 0x11cd5
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x11bbf
movq 0x58(%rsp), %rax
movq (%rax), %rax
addq %r8, %rax
movq 0x50(%rsp), %rcx
cmpb $0x2, (%rcx,%rax)
movl $0x186a0, %eax          # imm = 0x186A0
cmovbl %ebx, %eax
movl %eax, (%rsp)
cmpl $0x186a0, %edi          # imm = 0x186A0
jne 0x11be6
movq 0x60(%rsp), %rax
movq (%rax), %rax
addq %r8, %rax
movq 0x128(%rsp), %rcx
cmpb $0x2, (%rcx,%rax)
movl $0x186a0, %edi          # imm = 0x186A0
cmovbl %ebx, %edi
testq %rbx, %rbx
je 0x11e12
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x11c46
movl %edi, 0x4(%rsp)
leaq (,%r8,4), %rax
movq 0xc8(%rsp), %rcx
addq (%rcx), %rax
movq 0x50(%rsp), %rcx
cvtss2sd (%rax,%rcx,4), %xmm0
movq 0xa0(%rsp), %rax
addsd -0x8(%rax,%rbx,8), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
movq 0x8(%rsp), %r8
movl 0x4(%rsp), %edi
cmpl $0x186a0, %edi          # imm = 0x186A0
jne 0x11f88
movq 0x110(%rsp), %rax
movq 0x230(%rsp), %rcx
movq (%rcx), %rcx
imulq $0x18, 0xc0(%rsp), %rdx
movq 0x158(%rsp), %rsi
subq %r8, %rsi
movq (%rcx,%rdx), %rcx
cvtss2sd (%rcx,%rsi,4), %xmm0
addsd -0x8(%rax,%rbx,8), %xmm0
leaq (,%rsi,4), %rax
cvtss2sd 0x4(%rcx,%rsi,4), %xmm1
subsd %xmm1, %xmm0
movq 0x238(%rsp), %rcx
movq (%rcx), %rcx
movq 0x20(%rsp), %rsi
movslq (%rsi), %rsi
addq (%rcx,%rdx), %rax
cvtss2sd (%rax,%rsi,4), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
jmp 0x11f7e
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x11d00
movq 0x50(%rsp), %rax
subq %r8, %rax
js 0x11cfd
movq 0x58(%rsp), %rcx
movq (%rcx), %rcx
movl $0x186a0, (%rsp)        # imm = 0x186A0
cmpb $0x1, (%rcx,%rax)
ja 0x11d00
movl %ebx, (%rsp)
cmpl $0x186a0, %edi          # imm = 0x186A0
jne 0x11d2a
movq 0x128(%rsp), %rax
subq %r8, %rax
js 0x11d28
movq 0x60(%rsp), %rcx
movq (%rcx), %rcx
movl $0x186a0, %edi          # imm = 0x186A0
cmpb $0x1, (%rcx,%rax)
ja 0x11d2a
movl %ebx, %edi
testq %rbx, %rbx
je 0x11ece
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x11db3
movl %edi, 0x4(%rsp)
movq 0xa0(%rsp), %rax
movq 0x50(%rsp), %rcx
subq %r8, %rcx
movq 0x160(%rsp), %rdx
movq (%rdx), %rdx
leaq (,%rcx,4), %rsi
cvtss2sd (%rdx,%rcx,4), %xmm0
addsd -0x8(%rax,%rbx,8), %xmm0
cvtss2sd 0x4(%rdx,%rcx,4), %xmm1
subsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
movslq (%rax), %rax
movq 0xc8(%rsp), %rcx
addq (%rcx), %rsi
cvtss2sd (%rsi,%rax,4), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
movq 0x8(%rsp), %r8
movl 0x4(%rsp), %edi
cmpl $0x186a0, %edi          # imm = 0x186A0
jne 0x11f88
movq 0x238(%rsp), %rax
movq (%rax), %rax
imulq $0x18, 0xc0(%rsp), %rcx
movq 0x1a8(%rsp), %rdx
addl %ebx, %edx
movslq %edx, %rdx
movq (%rax,%rcx), %rax
cvtss2sd (%rax,%rdx,4), %xmm0
movq 0x110(%rsp), %rax
addsd -0x8(%rax,%rbx,8), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
jmp 0x11f7e
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x11e54
movl %edi, 0x4(%rsp)
movq 0xc8(%rsp), %rax
movq (%rax), %rax
movq 0x50(%rsp), %rcx
cvtss2sd 0x4(%rax,%rcx,4), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
movq 0x8(%rsp), %r8
movl 0x4(%rsp), %edi
cmpl $0x186a0, %edi          # imm = 0x186A0
jne 0x11f88
movq 0x230(%rsp), %rax
movq (%rax), %rax
imulq $0x18, 0xc0(%rsp), %rcx
movq (%rax,%rcx), %rax
movq 0x158(%rsp), %rdx
movss -0x4(%rax,%rdx,4), %xmm0
subss (%rax,%rdx,4), %xmm0
movq 0x238(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdx
movslq (%rdx), %rdx
addq 0x190(%rsp), %rdx
movq (%rax,%rcx), %rax
addss (%rax,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
jmp 0x11f7e
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x11f3b
movl %edi, 0x4(%rsp)
movq 0x160(%rsp), %rax
movq (%rax), %rax
movq 0x1a0(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0x50(%rsp), %rdx
subss (%rax,%rdx,4), %xmm0
movq 0x20(%rsp), %rax
movslq (%rax), %rax
addq %rcx, %rax
movq 0xc8(%rsp), %rcx
movq (%rcx), %rcx
addss (%rcx,%rax,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
movq 0x8(%rsp), %r8
movl 0x4(%rsp), %edi
cmpl $0x186a0, %edi          # imm = 0x186A0
jne 0x11f88
movq 0x238(%rsp), %rax
movq (%rax), %rax
imulq $0x18, 0xc0(%rsp), %rcx
movq (%rax,%rcx), %rax
movq 0x198(%rsp), %rcx
cvtss2sd (%rax,%rcx,4), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x112de
movl $0x186a0, %edi          # imm = 0x186A0
movq 0x8(%rsp), %r8
decq %rbx
movq 0x20(%rsp), %rax
movslq 0x4(%rax), %rax
cmpq %rax, %rbx
jle 0x11fde
movl %edi, %ebx
movq 0xf0(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movq %r8, %rdx
shlq $0x20, %rdx
addq 0x1b0(%rsp), %rdx
callq 0x1382d
movq 0xf8(%rsp), %rdx
leaq 0xf0(%rsp), %rdi
movq %rax, %rsi
callq 0x12f06
movq 0x8(%rsp), %r8
movl %ebx, %edi
movslq (%rsp), %rax
movq %rax, 0x1c0(%rsp)
movl %edi, 0x4(%rsp)
movslq %edi, %rax
movq %rax, 0x1b8(%rsp)
pushq $0x1
popq %r10
cmpq 0x180(%rsp), %r10
je 0x124a9
cmpq 0x1c0(%rsp), %r10
jg 0x123c4
movq %r8, %rax
subq %r10, %rax
cmpq 0x1b8(%rsp), %rax
jg 0x123c4
movq %rax, 0x140(%rsp)
movl %r8d, %eax
subl %r10d, %eax
subq $0x8, %rsp
movq 0x28(%rsp), %rdi
movl 0x158(%rsp), %esi
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %rbp
movl %ebp, %r8d
movl %r12d, %r9d
pushq %r15
pushq %rax
pushq %r10
movq %r10, %rbx
callq 0x128ae
addq $0x20, %rsp
movl %eax, 0x2c(%rsp)
testl %eax, %eax
je 0x12393
movq 0xf8(%rsp), %rax
subq 0xf0(%rsp), %rax
cqto
pushq $0xc
popq %rcx
idivq %rcx
movq %rax, %r13
movl %ebp, %eax
subl %ebx, %eax
movl %eax, 0x130(%rsp)
movq 0x128(%rsp), %rax
movq 0x140(%rsp), %r10
subq %r10, %rax
movq %rax, 0x188(%rsp)
leal (%rbx,%rbp), %eax
movl %eax, 0x154(%rsp)
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
leal (%r12,%r10), %eax
movq %rax, 0x1c8(%rsp)
pushq $0x8
popq %r15
xorl %ebp, %ebp
pushq $-0x1
popq %r14
movsd 0x97a46(%rip), %xmm0    # 0xa9b38
movq %rbx, %r9
movq %rbx, 0x138(%rsp)
cmpq %rbp, %r13
je 0x12207
movq 0xf0(%rsp), %rax
movslq -0x8(%rax,%r15), %r12
movl -0x4(%rax,%r15), %r8d
cmpq %r12, %r9
setg %cl
movslq %r8d, %rbx
cmpq %rbx, %r10
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x121fb
movsd %xmm0, 0x148(%rsp)
movl (%rax,%r15), %edx
cmpb $0x0, 0x240(%rsp)
je 0x1217d
movq 0x68(%rsp), %rax
leal (%r12,%rax), %ecx
addl 0xe8(%rsp), %r8d
subq $0x8, %rsp
movl %edx, %esi
movl 0x34(%rsp), %edx
movl 0x15c(%rsp), %r9d
pushq 0x68(%rsp)
pushq 0x68(%rsp)
pushq 0x1e0(%rsp)
jmp 0x121b3
movq 0x68(%rsp), %rax
movl %eax, %r9d
subl %r12d, %r9d
movq 0xe8(%rsp), %rax
subl %r8d, %eax
subq $0x8, %rsp
movl 0x34(%rsp), %esi
movl 0x138(%rsp), %ecx
movq 0x190(%rsp), %r8
pushq 0x68(%rsp)
pushq 0x68(%rsp)
pushq %rax
callq 0x1299e
addq $0x20, %rsp
movq 0x80(%rsp), %rax
imulq $0x18, %r12, %rcx
movq (%rax,%rcx), %rax
imulq $0x18, %rbx, %rcx
addsd 0x8(%rax,%rcx), %xmm0
movsd 0x148(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmoval %ebp, %r14d
minsd %xmm1, %xmm0
movq 0x138(%rsp), %r9
movq 0x140(%rsp), %r10
incq %rbp
addq $0xc, %r15
jmp 0x120fd
movq 0x80(%rsp), %rax
imulq $0x18, %r9, %rcx
movq (%rax,%rcx), %rax
imulq $0x18, %r10, %rcx
movslq %r14d, %rdx
movq 0xf0(%rsp), %rsi
imulq $0xc, %rdx, %rdx
movl 0x8(%rsi,%rdx), %edi
movq (%rsi,%rdx), %rdx
movq %rdx, (%rax,%rcx)
movl %edi, 0x10(%rax,%rcx)
movsd %xmm0, 0x8(%rax,%rcx)
movq 0xa0(%rsp), %rax
movsd -0x8(%rax,%r9,8), %xmm1
movq 0x110(%rsp), %rax
addsd -0x8(%rax,%r10,8), %xmm1
movsd %xmm1, 0x130(%rsp)
movslq 0x2c(%rsp), %rax
leaq 0x9795d(%rip), %rcx     # 0xa9bd0
movl (%rcx,%rax,4), %eax
movl %r9d, 0x30(%rsp)
movl %r10d, 0x34(%rsp)
movl %eax, 0x38(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
movsd %xmm0, 0x148(%rsp)
callq 0x139bc
movsd 0x148(%rsp), %xmm1
addsd 0x130(%rsp), %xmm1
movsd 0xe0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1239d
movq 0xa0(%rsp), %rax
movq 0x138(%rsp), %r10
movsd -0x8(%rax,%r10,8), %xmm0
addsd 0x178(%rsp), %xmm0
movq 0x110(%rsp), %rax
movq 0x140(%rsp), %rsi
addsd -0x8(%rax,%rsi,8), %xmm0
movsd %xmm0, 0x168(%rsp)
movq 0x170(%rsp), %rax
subl %esi, %eax
movq 0x68(%rsp), %r15
movl %r15d, %ecx
subl %r10d, %ecx
cmpb $0x0, 0x240(%rsp)
movl 0x14(%rsp), %edx
cmovnel %eax, %edx
movl %edx, 0x14(%rsp)
movq 0x188(%rsp), %rdx
cmovnel 0x18(%rsp), %edx
movl 0x1c(%rsp), %eax
cmovel %ecx, %eax
movl %eax, 0x1c(%rsp)
addl 0xd0(%rsp), %esi
movq 0xd8(%rsp), %rax
addl %r10d, %eax
movl %eax, 0x78(%rsp)
movq 0x8(%rsp), %r8
movl %r8d, 0x7c(%rsp)
movl %esi, 0x74(%rsp)
movl %edx, 0x18(%rsp)
movsd %xmm1, 0xe0(%rsp)
movq 0xe8(%rsp), %r12
movabsq $0x412e848000000000, %r13 # imm = 0x412E848000000000
leaq 0x80(%rsp), %r15
jmp 0x123c4
movq 0x8(%rsp), %r8
movq %rbx, %r10
jmp 0x123c4
movq 0xe8(%rsp), %r12
movabsq $0x412e848000000000, %r13 # imm = 0x412E848000000000
leaq 0x80(%rsp), %r15
movq 0x8(%rsp), %r8
movq 0x138(%rsp), %r10
incq %r10
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rcx
movq %rcx, %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %r10, %rax
jne 0x11ffd
movq %r12, %rbp
movq %r10, %r12
xorl %ebx, %ebx
xorl %r14d, %r14d
subq %rdi, %rcx
movq %rcx, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %r14, %rax
jbe 0x12442
addq %rbx, %rdi
orq $-0x1, 0x30(%rsp)
andl $0x0, 0x40(%rsp)
movq %r13, 0x38(%rsp)
leaq 0x30(%rsp), %rsi
callq 0x13ace
incq %r14
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rcx
addq $0x18, %rbx
jmp 0x123f9
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
incq %rax
orq $-0x1, 0x1d0(%rsp)
andl $0x0, 0x1e0(%rsp)
movq %r13, 0x1d8(%rsp)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
leaq 0x1d0(%rsp), %rdx
callq 0x12f0c
movq %r15, %rdi
movq %r14, %rsi
callq 0x12f48
movq %r14, %rdi
callq 0x1303a
movq 0x8(%rsp), %r8
movq %r12, %r10
movq %rbp, %r12
jmp 0x11ffd
movl %r8d, %eax
subl 0x7c(%rsp), %eax
movq 0x20(%rsp), %rcx
cmpl 0x4(%rcx), %eax
movl 0x4(%rsp), %edi
jge 0x124e5
incq 0x180(%rsp)
movq %r8, %rbx
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
je 0x11b80
movq %r8, %rbx
cmpl $0x186a0, %edi          # imm = 0x186A0
je 0x11b80
movl 0x78(%rsp), %ebx
movl %ebx, %ecx
subl 0xd8(%rsp), %ecx
movl 0x74(%rsp), %ebp
je 0x12540
movl %ebp, %r9d
subl 0xd0(%rsp), %r9d
je 0x12540
cmpb $0x0, 0x240(%rsp)
movq 0xb8(%rsp), %rsi
je 0x1255b
leaq 0x80(%rsp), %rdx
movq 0x68(%rsp), %r8
pushq $0x1
pushq %r12
callq 0x12c6e
popq %rax
popq %rcx
movq 0xb8(%rsp), %rax
movl 0x14(%rsp), %ecx
movl %ecx, 0x4(%rax)
jmp 0x1259f
movq 0xb8(%rsp), %rax
movl 0x14(%rsp), %ecx
movl %ecx, 0x4(%rax)
cmpb $0x0, 0x240(%rsp)
je 0x12591
jmp 0x1259f
movq 0x68(%rsp), %r8
movl %r8d, %ecx
subl 0x1c(%rsp), %ecx
movl %r12d, %r9d
subl 0x18(%rsp), %r9d
leaq 0x80(%rsp), %rdx
pushq $0x0
pushq %r12
callq 0x12c6e
popq %rax
popq %rcx
movq 0xb8(%rsp), %rax
movl 0x14(%rsp), %ecx
movl %ecx, 0x4(%rax)
movl 0x1c(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0x18(%rsp), %ecx
movl %ecx, 0xc(%rax)
movl %ebx, 0x10(%rax)
movl %ebp, 0x14(%rax)
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x28(%rax)
movsd 0x168(%rsp), %xmm1
movsd %xmm1, 0x18(%rax)
subsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rax)
leaq 0xf0(%rsp), %rdi
callq 0x13688
leaq 0x110(%rsp), %rdi
callq 0x6a68
leaq 0xa0(%rsp), %rdi
callq 0x6a68
leaq 0x80(%rsp), %rdi
callq 0x12f74
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1265c
movq %rax, %rbx
jmp 0x1266c
movq %rax, %rbx
jmp 0x12679
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x1303a
jmp 0x12686
movq %rax, %rbx
jmp 0x12686
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1265c
jmp 0x1264d
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x1303a
jmp 0x1265f
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x13688
leaq 0x110(%rsp), %rdi
callq 0x6a68
leaq 0xa0(%rsp), %rdi
callq 0x6a68
leaq 0x80(%rsp), %rdi
callq 0x12f74
movq %rbx, %rdi
callq 0x33a0
nop