// File: /workspace/github_c_makefile_star2_O1/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 $0x1e8, %rsp            # imm = 0x1E8
movq %r9, 0xe8(%rsp)
movq %r8, 0x160(%rsp)
movq %rcx, 0xa8(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rsi, %rbp
movq %rdi, 0x58(%rsp)
movl 0x8(%rsi), %r15d
cmpb $0x0, 0x230(%rsp)
je 0x158b3
movzwl 0x10(%rbp), %eax
addl %eax, %r15d
decl %r15d
movl 0xc(%rbp), %eax
movzwl 0x14(%rbp), %ecx
leal (%rax,%rcx), %r12d
decl %r12d
jmp 0x158b7
movl 0xc(%rbp), %r12d
movq 0x58(%rsp), %rax
movl 0x4(%rax), %eax
movq %rax, 0x1b8(%rsp)
movsd 0x28(%rbp), %xmm0
movsd %xmm0, 0xf0(%rsp)
movsd 0x18(%rbp), %xmm0
movsd %xmm0, 0x178(%rsp)
movslq (%rbp), %rax
movq %rax, 0x108(%rsp)
movl 0x4(%rbp), %ebx
movzwl 0x14(%rbp), %r14d
movzwl 0x10(%rbp), %eax
movq %rax, 0x110(%rsp)
xorl %eax, %eax
movq %rax, 0xe0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq %rax, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movl $0x960, %edi            # imm = 0x960
callq 0x3220
movzbl 0x230(%rsp), %ecx
movq %rcx, 0x180(%rsp)
movq %rbx, 0x118(%rsp)
movslq %ebx, %rcx
movq %r14, %rdx
movq %rcx, 0x158(%rsp)
addq %rcx, %rdx
movq %rdx, 0x150(%rsp)
movq %rax, 0x30(%rsp)
movq %rax, 0x38(%rsp)
leaq 0x960(%rax), %rcx
movq %rcx, 0x40(%rsp)
xorl %ecx, %ecx
movabsq $0x412e848000000000, %rdx # imm = 0x412E848000000000
movq $-0x1, (%rax,%rcx)
movq %rdx, 0x8(%rax,%rcx)
movl $0x0, 0x10(%rax,%rcx)
addq $0x18, %rcx
cmpq $0x960, %rcx            # imm = 0x960
jne 0x15982
addq %rcx, %rax
leaq 0x30(%rsp), %rdx
movq %rax, 0x8(%rdx)
leaq 0xd0(%rsp), %rdi
movl $0x64, %esi
callq 0x1713c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x159d9
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x64, %esi
callq 0x14f96
leaq 0x60(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x64, %esi
callq 0x14f96
testl %r15d, %r15d
js 0x15a38
movl %r15d, %eax
movq 0xa0(%rsp), %rcx
movq (%rcx), %rcx
movzbl (%rcx,%rax), %eax
cmpq $0x2, %rax
jae 0x168a7
xorl %eax, %eax
testl %r12d, %r12d
movq %rbp, 0x148(%rsp)
js 0x15a63
movl %r12d, %ecx
movq 0xa8(%rsp), %rdx
movq (%rdx), %rdx
movzbl (%rdx,%rcx), %ecx
cmpq $0x2, %rcx
jae 0x168b3
xorl %ecx, %ecx
leaq (%rax,%rax,4), %rax
leaq 0x990e0(%rip), %rdx     # 0xaeb50
leaq (%rdx,%rax,4), %rax
movl (%rax,%rcx,4), %ebx
cmpb $0x0, 0x230(%rsp)
jne 0x15a8e
movslq %ebx, %rax
leaq 0x99135(%rip), %rcx     # 0xaebc0
movl (%rcx,%rax,4), %ebx
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movq $-0x1, (%rax)
movl %ebx, 0x10(%rax)
movsd 0xf0(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
xorpd %xmm0, %xmm0
leaq 0x80(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x64, %esi
callq 0x1717e
movq $0x0, 0x13c(%rsp)
movl %ebx, 0x144(%rsp)
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x15b20
movl 0x144(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x13c(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x88(%rsp)
movq 0x118(%rsp), %rcx
jmp 0x15b3d
leaq 0x80(%rsp), %rdi
leaq 0x13c(%rsp), %rdx
callq 0x17a46
movq 0x118(%rsp), %rcx
leal -0x1(%r15), %eax
cltq
movq %rax, 0x1a8(%rsp)
movslq %r15d, %rax
movq %rax, 0x98(%rsp)
leal -0x1(%rcx), %eax
movslq %r12d, %rdx
movq %rdx, 0x168(%rsp)
movl $0x186a0, (%rsp)        # imm = 0x186A0
movq %rcx, %rdx
xorl %ebx, %ebx
movl $0x1, %ecx
movq %rcx, 0x190(%rsp)
movq 0x108(%rsp), %rcx
leaq (,%rcx,8), %rsi
movq %rsi, 0x1a0(%rsp)
cltq
movq %rax, 0x198(%rsp)
leaq (,%rcx,8), %rax
movq %rax, 0x1b0(%rsp)
movsd 0x178(%rsp), %xmm0
movsd %xmm0, 0x170(%rsp)
movl $0x0, 0xcc(%rsp)
movl %edx, 0x78(%rsp)
movl %r14d, 0xc4(%rsp)
movq 0x110(%rsp), %rax
movl %eax, 0xc8(%rsp)
movl %r12d, 0x54(%rsp)
movl %r15d, 0x50(%rsp)
movl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
movq %r15, 0x100(%rsp)
movq %r12, 0xf8(%rsp)
movq %r14, 0x188(%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0x8(%rsp)
cmpb $0x0, 0x230(%rsp)
je 0x15c8c
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x15c56
movq 0xa0(%rsp), %rax
movq (%rax), %rax
addq 0x8(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpb $0x2, (%rcx,%rax)
movl $0x186a0, %eax          # imm = 0x186A0
cmovbl %ebx, %eax
movl %eax, 0x4(%rsp)
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x15cf5
movq 0xa8(%rsp), %rax
movq (%rax), %rax
addq 0x8(%rsp), %rax
movq 0x168(%rsp), %rcx
cmpb $0x2, (%rcx,%rax)
movl $0x186a0, %eax          # imm = 0x186A0
cmovbl %ebx, %eax
movl %eax, (%rsp)
jmp 0x15cf5
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x15cc2
movq 0x98(%rsp), %rax
subq 0x8(%rsp), %rax
js 0x15cbe
movq 0xa0(%rsp), %rcx
movq (%rcx), %rcx
movl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
cmpb $0x1, (%rcx,%rax)
ja 0x15cc2
movl %ebx, 0x4(%rsp)
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x15cf5
movq 0x168(%rsp), %rax
subq 0x8(%rsp), %rax
js 0x15cf2
movq 0xa8(%rsp), %rcx
movq (%rcx), %rcx
movl $0x186a0, (%rsp)        # imm = 0x186A0
cmpb $0x1, (%rcx,%rax)
ja 0x15cf5
movl %ebx, (%rsp)
cmpb $0x0, 0x230(%rsp)
je 0x15d71
testq %rbx, %rbx
je 0x15e0f
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x15eea
movq 0x8(%rsp), %rax
leaq (,%rax,4), %rax
movq 0xe8(%rsp), %rcx
addq (%rcx), %rax
movq 0x98(%rsp), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rcx,4), %xmm0
movq 0x30(%rsp), %rax
addsd -0x8(%rax,%rbx,8), %xmm0
movq 0x38(%rsp), %rsi
movsd %xmm0, 0x10(%rsp)
cmpq 0x40(%rsp), %rsi
je 0x15edb
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x15eea
testq %rbx, %rbx
je 0x15e61
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x15fa3
movq 0x98(%rsp), %rax
subq 0x8(%rsp), %rax
movq 0x160(%rsp), %rcx
movq (%rcx), %rcx
leaq (,%rax,4), %rdx
xorps %xmm1, %xmm1
cvtss2sd (%rcx,%rax,4), %xmm1
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
addsd -0x8(%rdi,%rbx,8), %xmm1
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rcx,%rax,4), %xmm0
subsd %xmm0, %xmm1
movq 0x58(%rsp), %rax
movslq (%rax), %rax
movq 0xe8(%rsp), %rcx
addq (%rcx), %rdx
xorps %xmm0, %xmm0
cvtss2sd (%rdx,%rax,4), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
cmpq 0x40(%rsp), %rsi
je 0x15f94
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x15fa3
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x16024
movq 0xe8(%rsp), %rax
movq (%rax), %rax
movq 0x98(%rsp), %rcx
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rax,%rcx,4), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x16015
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x16024
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x160b9
movq 0x160(%rsp), %rax
movq (%rax), %rax
movq 0x1a8(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0x98(%rsp), %rdx
subss (%rax,%rdx,4), %xmm0
movq 0x58(%rsp), %rax
movslq (%rax), %rax
addq %rcx, %rax
movq 0xe8(%rsp), %rcx
movq (%rcx), %rcx
addss (%rcx,%rax,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x160aa
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x160b9
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x16110
movq 0x220(%rsp), %rax
movq (%rax), %rax
movq 0x1b0(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x158(%rsp), %rdx
subq 0x8(%rsp), %rdx
movq (%rax,%rcx), %rax
leaq (,%rdx,4), %rdi
xorps %xmm1, %xmm1
cvtss2sd (%rax,%rdx,4), %xmm1
movq 0x60(%rsp), %rsi
addsd -0x8(%rsi,%rbx,8), %xmm1
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rax,%rdx,4), %xmm0
movq 0x68(%rsp), %rsi
subsd %xmm0, %xmm1
movq 0x228(%rsp), %rax
movq (%rax), %rax
movq 0x58(%rsp), %rdx
movslq (%rdx), %rdx
addq (%rax,%rcx), %rdi
xorps %xmm0, %xmm0
cvtss2sd (%rdi,%rdx,4), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
cmpq 0x70(%rsp), %rsi
jne 0x16103
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
jmp 0x16110
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x16110
movq 0x228(%rsp), %rax
movq (%rax), %rax
movq 0x108(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x150(%rsp), %rdx
addl %ebx, %edx
movslq %edx, %rdx
movq (%rax,%rcx,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rdx,4), %xmm0
movq 0x60(%rsp), %rax
addsd -0x8(%rax,%rbx,8), %xmm0
movq 0x68(%rsp), %rsi
movsd %xmm0, 0x10(%rsp)
cmpq 0x70(%rsp), %rsi
jne 0x16103
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
jmp 0x16110
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x16110
movq 0x220(%rsp), %rax
movq (%rax), %rax
movq 0x1a0(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx), %rax
movq 0x158(%rsp), %rdx
movss -0x4(%rax,%rdx,4), %xmm0
subss (%rax,%rdx,4), %xmm0
movq 0x228(%rsp), %rax
movq (%rax), %rax
movq 0x58(%rsp), %rdx
movslq (%rdx), %rdx
addq 0x198(%rsp), %rdx
movq (%rax,%rcx), %rax
addss (%rax,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
jne 0x16103
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
jmp 0x16110
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
jne 0x16110
movq 0x228(%rsp), %rax
movq (%rax), %rax
movq 0x108(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq 0x150(%rsp), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rcx,4), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x16771
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
leaq -0x1(%rbx), %rax
movq 0x58(%rsp), %rcx
movslq 0x4(%rcx), %rcx
cmpq %rcx, %rax
jle 0x16173
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x8(%rsp), %rdx
shlq $0x20, %rdx
addq 0x1b8(%rsp), %rdx
callq 0x17baf
movq 0x88(%rsp), %rcx
cmpq %rcx, %rax
je 0x16173
movq 0x88(%rsp), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
addq %rsi, %rax
cmpq %rax, %rdx
je 0x16173
movq %rax, 0x88(%rsp)
testq %rbx, %rbx
je 0x1672e
movslq (%rsp), %rax
movq %rax, 0x1c0(%rsp)
movslq 0x4(%rsp), %rax
movq %rax, 0x1c8(%rsp)
movl $0x1, %ebp
cmpq 0x1c8(%rsp), %rbp
movq %rbp, 0xb8(%rsp)
jg 0x165ac
movq 0x8(%rsp), %rax
movq %rax, %rcx
subq %rbp, %rcx
movq %rcx, 0x128(%rsp)
cmpq 0x1c0(%rsp), %rcx
jg 0x165ac
movq %r14, %r13
movl %eax, %r10d
subl %ebp, %r10d
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
movq 0x188(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0xb0(%rsp), %rcx
movl %r15d, %r8d
movl %r12d, %r9d
leaq 0xd8(%rsp), %rax
pushq %rax
movq %r10, %r14
pushq %r10
pushq %rbp
callq 0x16bc8
addq $0x20, %rsp
movl %eax, 0x7c(%rsp)
testl %eax, %eax
je 0x163d7
movq 0x88(%rsp), %rbx
subq 0x80(%rsp), %rbx
sarq $0x2, %rbx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rbx
testl %ebx, %ebx
jle 0x163df
movl %r12d, %eax
subl %r14d, %eax
movl %eax, 0x138(%rsp)
addl %r12d, %r14d
movq %r14, 0x120(%rsp)
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl %r15d, %ecx
movq 0xb8(%rsp), %rax
subl %eax, %ecx
movl %ecx, 0x134(%rsp)
addl %r15d, %eax
movl %eax, 0x130(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x8, %r13d
xorl %r12d, %r12d
movsd 0x98887(%rip), %xmm0    # 0xaeb28
movsd %xmm0, 0xb0(%rsp)
movq 0x80(%rsp), %rax
movslq -0x8(%rax,%r13), %r15
movl -0x4(%rax,%r13), %r8d
movslq %r8d, %r14
cmpq %r15, 0xb8(%rsp)
setg %cl
cmpq %r14, 0x128(%rsp)
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x163b1
movl (%rax,%r13), %edx
cmpb $0x0, 0x230(%rsp)
je 0x1632e
movq 0x100(%rsp), %rax
leal (%r15,%rax), %ecx
addl 0xf8(%rsp), %r8d
subq $0x8, %rsp
movl %edx, %esi
movl 0x84(%rsp), %edx
movl 0x138(%rsp), %r9d
pushq 0xb0(%rsp)
pushq 0xb0(%rsp)
pushq 0x138(%rsp)
jmp 0x16370
movq 0x100(%rsp), %rax
movl %eax, %r9d
subl %r15d, %r9d
movq 0xf8(%rsp), %rax
subl %r8d, %eax
subq $0x8, %rsp
movl 0x84(%rsp), %esi
movl 0x13c(%rsp), %ecx
movl 0x140(%rsp), %r8d
pushq 0xb0(%rsp)
pushq 0xb0(%rsp)
pushq %rax
callq 0x16cde
addq $0x20, %rsp
movq 0xd0(%rsp), %rax
leaq (%r15,%r15,2), %rcx
movq (%rax,%rcx,8), %rax
leaq (%r14,%r14,2), %rcx
addsd 0x8(%rax,%rcx,8), %xmm0
movsd 0xb0(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmoval %r12d, %ebp
minsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
incq %r12
addq $0xc, %r13
cmpq %r12, %rbx
jne 0x162aa
movslq %ebp, %rax
movq 0x188(%rsp), %r14
movsd 0xb0(%rsp), %xmm0
jmp 0x163f1
movq %r13, %r14
jmp 0x165ac
movq $-0x1, %rax
movsd 0x9873a(%rip), %xmm0    # 0xaeb28
movq %r13, %r14
movq 0xd0(%rsp), %rcx
movq 0xb8(%rsp), %r8
leaq (%r8,%r8,2), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x128(%rsp), %r9
leaq (%r9,%r9,2), %rdx
movq 0x80(%rsp), %rsi
leaq (%rax,%rax,2), %rax
movq (%rsi,%rax,4), %rdi
movl 0x8(%rsi,%rax,4), %eax
movq %rdi, (%rcx,%rdx,8)
movl %eax, 0x10(%rcx,%rdx,8)
movsd %xmm0, 0xb0(%rsp)
movsd %xmm0, 0x8(%rcx,%rdx,8)
movq 0x30(%rsp), %rax
movsd -0x8(%rax,%r8,8), %xmm0
movq 0x60(%rsp), %rax
addsd -0x8(%rax,%r9,8), %xmm0
movsd %xmm0, 0x120(%rsp)
movslq 0x7c(%rsp), %rax
leaq 0x98753(%rip), %rcx     # 0xaebc0
movl (%rcx,%rax,4), %eax
movl %r8d, 0x10(%rsp)
movl %r9d, 0x14(%rsp)
movl %eax, 0x18(%rsp)
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
movq 0x118(%rsp), %rbx
je 0x164c2
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x88(%rsp)
movq 0x100(%rsp), %r15
movq 0xf8(%rsp), %r12
jmp 0x164e4
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x17d2a
movq 0x100(%rsp), %r15
movq 0xf8(%rsp), %r12
movsd 0xb0(%rsp), %xmm1
addsd 0x120(%rsp), %xmm1
movsd 0xf0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x165ac
movq 0x30(%rsp), %rax
movq 0xb8(%rsp), %rdi
movsd -0x8(%rax,%rdi,8), %xmm0
addsd 0x178(%rsp), %xmm0
movq 0x60(%rsp), %rax
movq 0x128(%rsp), %r8
addsd -0x8(%rax,%r8,8), %xmm0
movsd %xmm0, 0x170(%rsp)
movl %ebx, %eax
subl %r8d, %eax
movl %r12d, %ecx
subl %r8d, %ecx
movl %r15d, %edx
subl %edi, %edx
cmpb $0x0, 0x230(%rsp)
movl 0x78(%rsp), %esi
cmovnel %eax, %esi
movl %esi, 0x78(%rsp)
movl 0x54(%rsp), %eax
cmovel %ecx, %eax
movl %eax, 0x54(%rsp)
movl 0x50(%rsp), %eax
cmovel %edx, %eax
movl %eax, 0x50(%rsp)
movq 0x110(%rsp), %rax
addl %edi, %eax
movl %eax, 0xc8(%rsp)
addl %r14d, %r8d
movq 0x8(%rsp), %rax
movl %eax, 0xcc(%rsp)
movl %r8d, 0xc4(%rsp)
movsd %xmm1, 0xf0(%rsp)
movq 0xd8(%rsp), %rax
subq 0xd0(%rsp), %rax
movq 0xb8(%rsp), %rbp
incq %rbp
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rbp, %rax
jne 0x16720
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
je 0x1668b
xorl %ebx, %ebx
xorl %r14d, %r14d
movq $-0x1, 0x10(%rsp)
movl $0x0, 0x20(%rsp)
movabsq $0x412e848000000000, %rax # imm = 0x412E848000000000
movq %rax, 0x18(%rsp)
movq 0x8(%rdi,%rbx), %rsi
cmpq 0x10(%rdi,%rbx), %rsi
je 0x16647
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0x10(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x8(%rdi,%rbx)
jmp 0x16654
addq %rbx, %rdi
leaq 0x10(%rsp), %rdx
callq 0x17e42
incq %r14
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
addq $0x18, %rbx
cmpq %r14, %rsi
ja 0x16600
jmp 0x1669d
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
incq %rsi
movq $-0x1, 0x1d0(%rsp)
movl $0x0, 0x1e0(%rsp)
movabsq $0x412e848000000000, %rax # imm = 0x412E848000000000
movq %rax, 0x1d8(%rsp)
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1d0(%rsp), %rdx
callq 0x17240
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x17286
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x16718
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x188(%rsp), %r14
cmpq 0x190(%rsp), %rbp
jne 0x1619a
movq 0x8(%rsp), %rcx
movl %ecx, %eax
subl 0xcc(%rsp), %eax
movq 0x58(%rsp), %rdx
cmpl 0x4(%rdx), %eax
jge 0x16785
incq 0x190(%rsp)
movq %rcx, %rbx
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
je 0x15c11
movq %rcx, %rbx
cmpl $0x186a0, (%rsp)        # imm = 0x186A0
je 0x15c11
jmp 0x16785
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x15198
jmp 0x16110
movl 0xc8(%rsp), %ebx
movl %ebx, %eax
subl 0x110(%rsp), %eax
movl 0xc4(%rsp), %r13d
je 0x167ea
movl %r13d, %edx
subl %r14d, %edx
je 0x167ea
movl %r15d, %ecx
subl 0x50(%rsp), %ecx
movl %r12d, %r9d
subl 0x54(%rsp), %r9d
cmpb $0x0, 0x230(%rsp)
cmovnel %eax, %ecx
cmovnel %edx, %r9d
leaq 0xd0(%rsp), %rdx
movq 0x148(%rsp), %rsi
movl %r15d, %r8d
pushq 0x180(%rsp)
pushq %r12
callq 0x16fde
addq $0x10, %rsp
movq 0x148(%rsp), %rax
movl 0x78(%rsp), %ecx
movl %ecx, 0x4(%rax)
cmpb $0x0, 0x230(%rsp)
jne 0x16811
movl 0x50(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0x54(%rsp), %ecx
movl %ecx, 0xc(%rax)
movl %ebx, 0x10(%rax)
movl %r13d, 0x14(%rax)
movsd 0xf0(%rsp), %xmm0
movsd %xmm0, 0x28(%rax)
movsd 0x170(%rsp), %xmm1
movsd %xmm1, 0x18(%rax)
subsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rax)
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1685a
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x16871
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x16888
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
leaq 0xd0(%rsp), %rdi
callq 0x172b2
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x5, %al
ja 0x168c0
decq %rax
jmp 0x15a3a
cmpb $0x5, %cl
ja 0x168c9
decq %rcx
jmp 0x15a65
addq $-0x5, %rax
jmp 0x15a3a
addq $-0x5, %rcx
jmp 0x15a65
jmp 0x16919
jmp 0x16919
jmp 0x16919
jmp 0x16919
jmp 0x16919
jmp 0x16919
jmp 0x16919
jmp 0x16919
jmp 0x16919
jmp 0x16919
movq %rax, %rbx
jmp 0x16939
jmp 0x168ed
movq %rax, %rbx
jmp 0x16950
movq %rax, %rbx
jmp 0x16967
jmp 0x16919
jmp 0x16919
jmp 0x168fd
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1691c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
jmp 0x1691c
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x16939
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x16950
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x16967
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
leaq 0xd0(%rsp), %rdi
callq 0x172b2
movq %rbx, %rdi
callq 0x33e0