// File: /workspace/github_c_makefile_star2_O3/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, 0xf8(%rsp)
movq %r8, 0x160(%rsp)
movq %rcx, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq %rsi, %rbx
movq %rdi, %r13
movl 0x8(%rsi), %r15d
cmpb $0x0, 0x230(%rsp)
je 0x176eb
movzwl 0x10(%rbx), %eax
movq %rax, 0x100(%rsp)
addl %eax, %r15d
decl %r15d
movl 0xc(%rbx), %eax
movzwl 0x14(%rbx), %ecx
movq %rcx, 0xb0(%rsp)
leal (%rax,%rcx), %r12d
decl %r12d
jmp 0x17707
movl 0xc(%rbx), %r12d
movzwl 0x14(%rbx), %eax
movq %rax, 0xb0(%rsp)
movzwl 0x10(%rbx), %eax
movq %rax, 0x100(%rsp)
movl 0x4(%r13), %eax
movq %rax, 0x1a8(%rsp)
movsd 0x28(%rbx), %xmm0
movsd %xmm0, 0x108(%rsp)
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x178(%rsp)
movslq (%rbx), %rax
movq %rax, 0xf0(%rsp)
movl 0x4(%rbx), %r14d
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
movl %ecx, 0x134(%rsp)
movslq %r14d, %rcx
movq %rcx, 0x158(%rsp)
movq 0xb0(%rsp), %rcx
addl %r14d, %ecx
movq %rcx, 0x150(%rsp)
movq %rax, 0x30(%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 0x177b4
addq %rcx, %rax
leaq 0x30(%rsp), %rdx
movq %rax, 0x8(%rdx)
leaq 0xd0(%rsp), %rdi
movl $0x64, %esi
callq 0x18f2e
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1780b
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 0x16e36
leaq 0x50(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x64, %esi
callq 0x16e36
xorl %eax, %eax
movl $0x0, %ecx
testl %r15d, %r15d
js 0x1787f
movl %r15d, %ecx
movq 0x98(%rsp), %rdx
movq (%rdx), %rdx
movzbl (%rdx,%rcx), %edx
movl $0x0, %ecx
cmpl $0x2, %edx
jb 0x1787f
cmpb $0x5, %dl
ja 0x1787a
decl %edx
jmp 0x1787d
addl $-0x5, %edx
movl %edx, %ecx
testl %r12d, %r12d
js 0x178a9
movl %r12d, %edx
movq 0xa0(%rsp), %rsi
movq (%rsi), %rsi
movzbl (%rsi,%rdx), %edx
cmpl $0x2, %edx
jb 0x178a9
cmpb $0x5, %dl
ja 0x178a4
decl %edx
jmp 0x178a7
addl $-0x5, %edx
movl %edx, %eax
movq %rbx, 0xe8(%rsp)
movslq %ecx, %rcx
cltq
leaq (%rcx,%rcx,4), %rcx
leaq 0x9845f(%rip), %rdx     # 0xafd20
leaq (%rdx,%rcx,4), %rcx
movl (%rcx,%rax,4), %ebx
cmpb $0x0, 0x230(%rsp)
jne 0x178df
movslq %ebx, %rax
leaq 0x984b4(%rip), %rcx     # 0xafd90
movl (%rcx,%rax,4), %ebx
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movq $-0x1, (%rax)
movl %ebx, 0x10(%rax)
movsd 0x108(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
xorpd %xmm0, %xmm0
leaq 0x70(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x64, %esi
callq 0x18f70
movq $0x0, 0x144(%rsp)
movl %ebx, 0x14c(%rsp)
movq 0x78(%rsp), %rsi
cmpq 0x80(%rsp), %rsi
je 0x17960
movl 0x14c(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x144(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x78(%rsp)
jmp 0x17972
leaq 0x70(%rsp), %rdi
leaq 0x144(%rsp), %rdx
callq 0x19810
leal -0x1(%r15), %eax
cltq
movq %rax, 0x1a0(%rsp)
movslq %r15d, %rax
movq %rax, 0x90(%rsp)
movslq 0x150(%rsp), %rax
movq %rax, 0x198(%rsp)
leal -0x1(%r14), %eax
movslq %r12d, %rcx
movq %rcx, 0x168(%rsp)
movl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
xorl %ebx, %ebx
movl $0x1, %ecx
movq %rcx, 0x188(%rsp)
cltq
movq %rax, 0x190(%rsp)
movsd 0x178(%rsp), %xmm0
movsd %xmm0, 0x170(%rsp)
movl $0x0, 0xcc(%rsp)
movq %r14, 0x1b0(%rsp)
movl %r14d, 0xc(%rsp)
movq 0xb0(%rsp), %rax
movl %eax, 0xc4(%rsp)
movq 0x100(%rsp), %rax
movl %eax, 0xc8(%rsp)
movl %r12d, 0x4c(%rsp)
movl %r15d, 0x48(%rsp)
movl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
movq %r15, 0x118(%rsp)
movq %r12, 0x110(%rsp)
movq %r13, 0x1b8(%rsp)
leaq 0x1(%rbx), %r14
cmpb $0x0, 0x230(%rsp)
je 0x17b1c
cmpl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
jne 0x17a7f
movq 0x98(%rsp), %rax
movq (%rax), %rax
addq %r14, %rax
movq 0x90(%rsp), %rcx
cmpb $0x2, (%rcx,%rax)
movl $0x186a0, %eax          # imm = 0x186A0
cmovbl %ebx, %eax
movl %eax, 0x8(%rsp)
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x17aaf
movq 0xa0(%rsp), %rax
movq (%rax), %rax
addq %r14, %rax
movq 0x168(%rsp), %rcx
cmpb $0x2, (%rcx,%rax)
movl $0x186a0, %eax          # imm = 0x186A0
cmovbl %ebx, %eax
movl %eax, 0x4(%rsp)
testq %rbx, %rbx
je 0x17c1c
cmpl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
jne 0x17cf3
leaq (,%r14,4), %rax
movq 0xf8(%rsp), %rcx
addq (%rcx), %rax
movq 0x90(%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 0x17ce4
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x17cf3
cmpl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
jne 0x17b50
movq 0x90(%rsp), %rax
subq %r14, %rax
js 0x17b4c
movq 0x98(%rsp), %rcx
movq (%rcx), %rcx
movl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
cmpb $0x1, (%rcx,%rax)
ja 0x17b50
movl %ebx, 0x8(%rsp)
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x17b84
movq 0x168(%rsp), %rax
subq %r14, %rax
js 0x17b80
movq 0xa0(%rsp), %rcx
movq (%rcx), %rcx
movl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
cmpb $0x1, (%rcx,%rax)
ja 0x17b84
movl %ebx, 0x4(%rsp)
testq %rbx, %rbx
je 0x17c6e
cmpl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
jne 0x17daf
movq 0x90(%rsp), %rax
subq %r14, %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
movslq (%r13), %rax
movq 0xf8(%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 0x17da0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x17daf
cmpl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
jne 0x17e31
movq 0xf8(%rsp), %rax
movq (%rax), %rax
movq 0x90(%rsp), %rcx
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rax,%rcx,4), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x17e22
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x17e31
cmpl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
jne 0x17ecb
movq 0x160(%rsp), %rax
movq (%rax), %rax
movq 0x1a0(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0x90(%rsp), %rdx
subss (%rax,%rdx,4), %xmm0
movslq (%r13), %rax
addq %rcx, %rax
movq 0xf8(%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 0x17ebc
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x17ecb
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x17f2b
movq 0x220(%rsp), %rax
movq (%rax), %rax
movq 0xf0(%rsp), %rcx
leaq (,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x158(%rsp), %rdx
subq %r14, %rdx
movq (%rax,%rcx), %rax
leaq (,%rdx,4), %rdi
xorps %xmm1, %xmm1
cvtss2sd (%rax,%rdx,4), %xmm1
movq 0x50(%rsp), %rsi
addsd -0x8(%rsi,%rbx,8), %xmm1
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rax,%rdx,4), %xmm0
movq 0x58(%rsp), %rsi
subsd %xmm0, %xmm1
movq 0x228(%rsp), %rax
movq (%rax), %rax
movslq (%r13), %rdx
addq (%rax,%rcx), %rdi
xorps %xmm0, %xmm0
cvtss2sd (%rdi,%rdx,4), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
cmpq 0x60(%rsp), %rsi
jne 0x17f16
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
jmp 0x17f23
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x17f2b
movq 0x228(%rsp), %rax
movq (%rax), %rax
movq 0xf0(%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 0x50(%rsp), %rax
addsd -0x8(%rax,%rbx,8), %xmm0
movq 0x58(%rsp), %rsi
movsd %xmm0, 0x10(%rsp)
cmpq 0x60(%rsp), %rsi
jne 0x17f16
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
jmp 0x17f23
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x17f2b
movq 0x220(%rsp), %rax
movq (%rax), %rax
movq 0xf0(%rsp), %rcx
leaq (,%rcx,8), %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
movslq (%r13), %rdx
addq 0x190(%rsp), %rdx
movq (%rax,%rcx), %rax
addss (%rax,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
jne 0x17f16
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
jmp 0x17f23
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
jne 0x17f2b
movq 0x228(%rsp), %rax
movq (%rax), %rax
movq 0xf0(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq 0x198(%rsp), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rcx,4), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x18536
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x58(%rsp)
movl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
leaq -0x1(%rbx), %rax
movslq 0x4(%r13), %rcx
cmpq %rcx, %rax
jle 0x17f62
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq %r14, %rdx
shlq $0x20, %rdx
addq 0x1a8(%rsp), %rdx
callq 0x19979
cmpq 0x78(%rsp), %rax
je 0x17f62
movq %rax, 0x78(%rsp)
testq %rbx, %rbx
je 0x184fa
movslq 0x4(%rsp), %rax
movq %rax, 0x1c0(%rsp)
movslq 0x8(%rsp), %rax
movq %rax, 0x1c8(%rsp)
movl $0x1, %eax
movq %r14, 0x180(%rsp)
cmpq 0x1c8(%rsp), %rax
jg 0x18392
movq %r14, %rcx
subq %rax, %rcx
movq %rcx, 0x128(%rsp)
cmpq 0x1c0(%rsp), %rcx
jg 0x18392
movl %r14d, %r11d
subl %eax, %r11d
subq $0x8, %rsp
movq %r13, %rdi
movl 0x13c(%rsp), %esi
movq 0xa0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
movl %r15d, %r8d
movl %r12d, %r9d
movq %rax, %r10
leaq 0xd8(%rsp), %rax
pushq %rax
movq %r11, %rbp
pushq %r11
movq %r10, 0xc0(%rsp)
pushq %r10
callq 0x189b0
addq $0x20, %rsp
movl %eax, 0x6c(%rsp)
testl %eax, %eax
je 0x1838a
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rsi
movq %rsi, %rbx
subq %rax, %rbx
sarq $0x2, %rbx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rbx
testl %ebx, %ebx
jle 0x181d0
movl %r12d, %eax
subl %ebp, %eax
movl %eax, 0x140(%rsp)
addl %r12d, %ebp
movq %rbp, 0x120(%rsp)
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl %r15d, %ecx
movq 0xa8(%rsp), %rax
subl %eax, %ecx
movl %ecx, 0x13c(%rsp)
addl %r15d, %eax
movl %eax, 0x138(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x8, %r12d
xorl %r13d, %r13d
movsd 0x97c67(%rip), %xmm0    # 0xafcf8
movsd %xmm0, 0xb8(%rsp)
movq 0x70(%rsp), %rax
movslq -0x8(%rax,%r12), %r14
movl -0x4(%rax,%r12), %r8d
cmpq %r14, 0xa8(%rsp)
setg %cl
movslq %r8d, %r15
cmpq %r15, 0x128(%rsp)
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x18198
movl (%rax,%r12), %edx
cmpb $0x0, 0x230(%rsp)
je 0x18118
movq 0x118(%rsp), %rax
leal (%r14,%rax), %ecx
addl 0x110(%rsp), %r8d
subq $0x8, %rsp
movl %edx, %esi
movl 0x74(%rsp), %edx
movl 0x140(%rsp), %r9d
pushq 0xa8(%rsp)
pushq 0xa8(%rsp)
pushq 0x138(%rsp)
jmp 0x18157
movq 0x118(%rsp), %rax
movl %eax, %r9d
subl %r14d, %r9d
movq 0x110(%rsp), %rax
subl %r8d, %eax
subq $0x8, %rsp
movl 0x74(%rsp), %esi
movl 0x144(%rsp), %ecx
movl 0x148(%rsp), %r8d
pushq 0xa8(%rsp)
pushq 0xa8(%rsp)
pushq %rax
callq 0x18aaa
addq $0x20, %rsp
movq 0xd0(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
leaq (%r15,%r15,2), %rcx
addsd 0x8(%rax,%rcx,8), %xmm0
movsd 0xb8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmoval %r13d, %ebp
minsd %xmm1, %xmm0
movsd %xmm0, 0xb8(%rsp)
incq %r13
addq $0xc, %r12
cmpq %r13, %rbx
jne 0x1809a
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rsi
movslq %ebp, %rcx
movq 0x1b8(%rsp), %r13
movq 0x180(%rsp), %r14
movsd 0xb8(%rsp), %xmm0
jmp 0x181df
movq $-0x1, %rcx
movsd 0x97b19(%rip), %xmm0    # 0xafcf8
movq 0xd0(%rsp), %rdx
movq 0xa8(%rsp), %r9
leaq (%r9,%r9,2), %rdi
movq (%rdx,%rdi,8), %rdx
movq 0x128(%rsp), %r10
leaq (%r10,%r10,2), %rdi
leaq (%rcx,%rcx,2), %rcx
movl 0x8(%rax,%rcx,4), %r8d
movq (%rax,%rcx,4), %rax
movq %rax, (%rdx,%rdi,8)
movl %r8d, 0x10(%rdx,%rdi,8)
movsd %xmm0, 0xb8(%rsp)
movsd %xmm0, 0x8(%rdx,%rdi,8)
movq 0x30(%rsp), %rax
movsd -0x8(%rax,%r9,8), %xmm0
movq 0x50(%rsp), %rax
addsd -0x8(%rax,%r10,8), %xmm0
movsd %xmm0, 0x120(%rsp)
movslq 0x6c(%rsp), %rax
leaq 0x97b3b(%rip), %rcx     # 0xafd90
movl (%rcx,%rax,4), %eax
movl %r9d, 0x10(%rsp)
movl %r10d, 0x14(%rsp)
movl %eax, 0x18(%rsp)
cmpq 0x80(%rsp), %rsi
leaq 0x10(%rsp), %rdx
je 0x1829c
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x78(%rsp)
movq 0x118(%rsp), %r15
movq 0x110(%rsp), %r12
jmp 0x182b6
leaq 0x70(%rsp), %rdi
callq 0x19af2
movq 0x118(%rsp), %r15
movq 0x110(%rsp), %r12
movsd 0xb8(%rsp), %xmm1
addsd 0x120(%rsp), %xmm1
movsd 0x108(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1838a
movq 0x30(%rsp), %rax
movq 0xa8(%rsp), %rdi
movsd -0x8(%rax,%rdi,8), %xmm0
addsd 0x178(%rsp), %xmm0
movq 0x50(%rsp), %rax
movq 0x128(%rsp), %r8
addsd -0x8(%rax,%r8,8), %xmm0
movsd %xmm0, 0x170(%rsp)
movq 0x1b0(%rsp), %rax
subl %r8d, %eax
movl %r12d, %ecx
subl %r8d, %ecx
movl %r15d, %edx
subl %edi, %edx
cmpb $0x0, 0x230(%rsp)
movl 0xc(%rsp), %esi
cmovnel %eax, %esi
movl %esi, 0xc(%rsp)
movl 0x4c(%rsp), %eax
cmovel %ecx, %eax
movl %eax, 0x4c(%rsp)
movl 0x48(%rsp), %eax
cmovel %edx, %eax
movl %eax, 0x48(%rsp)
movq 0x100(%rsp), %rax
addl %edi, %eax
movl %eax, 0xc8(%rsp)
addl 0xb0(%rsp), %r8d
movl %r14d, 0xcc(%rsp)
movl %r8d, 0xc4(%rsp)
movq %rdi, %rax
movsd %xmm1, 0x108(%rsp)
jmp 0x18392
movq 0xa8(%rsp), %rax
incq %rax
movq 0xd0(%rsp), %rdi
movq %rax, %rsi
movq 0xd8(%rsp), %rax
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %rsi, %rcx
jne 0x184e9
movq %rsi, %rbp
cmpq %rdi, %rax
je 0x18463
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 0x18421
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0x10(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x8(%rdi,%rbx)
jmp 0x1842e
addq %rbx, %rdi
leaq 0x10(%rsp), %rdx
callq 0x19c0a
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 0x183da
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 0x19032
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x19078
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x184de
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x180(%rsp), %r14
movq %rbp, %rsi
cmpq 0x188(%rsp), %rsi
movq %rsi, %rax
jne 0x17f92
movl %r14d, %eax
subl 0xcc(%rsp), %eax
cmpl 0x4(%r13), %eax
jge 0x1854a
incq 0x188(%rsp)
movq %r14, %rbx
cmpl $0x186a0, 0x8(%rsp)     # imm = 0x186A0
je 0x17a3d
movq %r14, %rbx
cmpl $0x186a0, 0x4(%rsp)     # imm = 0x186A0
je 0x17a3d
jmp 0x1854a
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1703e
jmp 0x17f23
movl 0xc8(%rsp), %ebx
movl %ebx, %ecx
subl 0x100(%rsp), %ecx
movl 0xc4(%rsp), %ebp
je 0x185ab
movl %ebp, %r9d
subl 0xb0(%rsp), %r9d
je 0x185ab
cmpb $0x0, 0x230(%rsp)
movq 0xe8(%rsp), %rsi
je 0x185c6
leaq 0xd0(%rsp), %rdx
movl %r15d, %r8d
pushq $0x1
pushq %r12
callq 0x18d88
addq $0x10, %rsp
movq 0xe8(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0x4(%rax)
jmp 0x1860a
movq 0xe8(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0x4(%rax)
cmpb $0x0, 0x230(%rsp)
je 0x185fc
jmp 0x1860a
movl %r15d, %ecx
subl 0x48(%rsp), %ecx
movl %r12d, %r9d
subl 0x4c(%rsp), %r9d
leaq 0xd0(%rsp), %rdx
movl %r15d, %r8d
pushq $0x0
pushq %r12
callq 0x18d88
addq $0x10, %rsp
movq 0xe8(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0x4(%rax)
movl 0x48(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0x4c(%rsp), %ecx
movl %ecx, 0xc(%rax)
movl %ebx, 0x10(%rax)
movl %ebp, 0x14(%rax)
movsd 0x108(%rsp), %xmm0
movsd %xmm0, 0x28(%rax)
movsd 0x170(%rsp), %xmm1
movsd %xmm1, 0x18(%rax)
subsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rax)
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1864f
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x18666
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1867d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
leaq 0xd0(%rsp), %rdi
callq 0x190a4
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
jmp 0x186e3
movq %rax, %rbx
jmp 0x18700
jmp 0x186b7
movq %rax, %rbx
jmp 0x18717
movq %rax, %rbx
jmp 0x1872e
jmp 0x186e3
jmp 0x186e3
jmp 0x186c7
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x186e6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
jmp 0x186e6
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x18700
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x18717
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1872e
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
leaq 0xd0(%rsp), %rdi
callq 0x190a4
movq %rbx, %rdi
callq 0x33e0
nop