// File: /workspace/github_c_makefile_star2_O2/fukunagatsu[P]RIblast/seed_search.cpp
// Function: SeedSearch::SeedSearchCore(std::vector<unsigned char, std::allocator<unsigned char>>&, std::vector<int, std::allocator<int>>&, std::vector<unsigned char, std::allocator<unsigned char>>&, std::vector<int, std::allocator<int>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, int, int, int, int, double, int)
void SeedSearch::SeedSearchCore(vector<unsigned char> &query_seq, vector<int> &query_suffix_array, vector<unsigned char> &db_seq, vector<int> &db_suffix_array,  vector<vector<int> > &start_hash,  vector<vector<int> > &end_hash, vector<int> &db_seed, vector<int> &q_seed, int sp_q, int ep_q, int sp_db, int ep_db, double score, int length){

  if(length < _max_seed_length){
    vector<int> sp_q_result; sp_q_result.reserve(_pair_size);
    vector<int> ep_q_result; ep_q_result.reserve(_pair_size);
    vector<int> sp_db_result; sp_db_result.reserve(_pair_size);
    vector<int> ep_db_result; ep_db_result.reserve(_pair_size);

    for(int i = 0; i< _pair_size; i++){
      int start = sp_q;
      int end = ep_q;
      int nucleotide_size = 4;
      SeedSearchNextCharacter(query_seq, query_suffix_array, &start, &end, _stem_pair[i][0], length);
      sp_q_result.push_back(start);
      ep_q_result.push_back(end);
      start = sp_db;
      end = ep_db;
      if(length+1 > _hash_size){
	SeedSearchNextCharacter(db_seq, db_suffix_array, &start, &end, _stem_pair[i][1], length);
      }else{
	int temp = _stem_pair[i][1]-2;
	for(int j = 0; j <length;j++){
	  temp += (int)pow(nucleotide_size,length-j) * (db_seed[j] - 2);
	}
	start = start_hash[length][temp];
	end = end_hash[length][temp];
      }
      sp_db_result.push_back(start);
      ep_db_result.push_back(end);
    }
    
    for(int i = 0; i< _pair_size; i++){
      if(sp_q_result[i] <= ep_q_result[i] && sp_db_result[i] <= ep_db_result[i]){
	double temp_score = 0.0;
	
	if(length > 0){
	  int type = BP_pair[q_seed[length-1]-1][db_seed[length-1]-1];
	  int type2 = BP_pair[_stem_pair[i][0]-1][_stem_pair[i][1]-1];
	  type2 = rtype[type2];
	  temp_score = score + ((double)stack37[type][type2])/100;
	}
	
	if(temp_score < _hybrid_energy_threshold && length+1 >= _min_accessible_length){
	  Hit_candidate temp_hit_candidate(sp_q_result[i], ep_q_result[i], sp_db_result[i], ep_db_result[i], length+1, temp_score);
	  _hit_candidate_result.push_back(temp_hit_candidate);
	}else{
	  q_seed.push_back(_stem_pair[i][0]);
	  db_seed.push_back(_stem_pair[i][1]);
	  SeedSearchCore(query_seq, query_suffix_array, db_seq, db_suffix_array, start_hash, end_hash, db_seed, q_seed, sp_q_result[i], ep_q_result[i], sp_db_result[i], ep_db_result[i], temp_score, length+1);
	}
      }
    }
  }
  q_seed.pop_back();
  db_seed.pop_back();
  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movsd %xmm0, 0xf0(%rsp)
movq %r9, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movl 0x168(%rsp), %r13d
movq 0x140(%rsp), %rbp
movq 0x138(%rsp), %rbx
cmpl %r13d, 0x1c(%rdi)
jle 0x10b3b
movq %rdi, %r15
xorpd %xmm0, %xmm0
leaq 0xd0(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x6488
leaq 0xb0(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x6488
xorpd %xmm0, %xmm0
leaq 0x90(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x6488
leaq 0x70(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x6488
movslq %r13d, %rax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %ebp
cmovgl %r13d, %ebp
leaq 0x50(%rsp), %rbx
imulq $0x18, %rax, %rax
movq %rax, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movslq 0x18(%r15), %rax
cmpq %rax, %rcx
jge 0x10924
movl 0x148(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0x150(%rsp), %eax
movl %eax, 0xc(%rsp)
movq (%r15), %rax
movq %rcx, 0x20(%rsp)
imulq $0x18, %rcx, %r12
movq (%rax,%r12), %rax
movzbl (%rax), %r9d
subq $0x8, %rsp
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rcx
leaq 0x14(%rsp), %r8
pushq %r13
callq 0x11008
popq %rax
popq %rcx
leaq 0xd0(%rsp), %rdi
movq %rbx, %r14
movq %rbx, %rsi
callq 0x651e
leaq 0xb0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x651e
movl 0x158(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0x160(%rsp), %eax
movl %eax, 0xc(%rsp)
movq (%r15), %rax
movq (%rax,%r12), %rax
movl 0x4(%rax), %r12d
cmpl %r13d, 0x20(%r15)
movq 0x138(%rsp), %rbx
jle 0x1088c
addl $-0x2, %r12d
xorl %r15d, %r15d
cmpq %r15, %rbp
je 0x108b4
cvtsi2sd %r13d, %xmm0
addsd %xmm0, %xmm0
callq 0x31d0
cvttsd2si %xmm0, %eax
movq (%rbx), %rcx
movl (%rcx,%r15,4), %ecx
addl $-0x2, %ecx
imull %eax, %ecx
addl %ecx, %r12d
incq %r15
decl %r13d
jmp 0x1085d
subq $0x8, %rsp
movzbl %r12b, %r9d
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r14, %r12
movq %r14, %rcx
leaq 0x14(%rsp), %r8
pushq %r13
callq 0x11008
popq %rax
popq %rcx
jmp 0x108f5
movq 0x38(%rsp), %rax
movq (%rax), %rax
movslq %r12d, %rcx
movq 0x10(%rsp), %rdx
movq (%rax,%rdx), %rax
movl (%rax,%rcx,4), %eax
movl %eax, 0x50(%rsp)
movq 0x130(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rdx), %rax
movl (%rax,%rcx,4), %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %r15
movl 0x168(%rsp), %r13d
movq %r14, %r12
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0x651e
leaq 0x70(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x651e
movq 0x20(%rsp), %rcx
incq %rcx
movq %r14, %rbx
jmp 0x107ac
leal -0x1(%r13), %ecx
movq %rcx, 0x10(%rsp)
leal 0x1(%r13), %r12d
leaq 0x30(%r15), %rcx
movq %rcx, 0xe8(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
movq 0x140(%rsp), %rbp
movq 0x138(%rsp), %rbx
cltq
cmpq %rax, %r14
jge 0x10b0a
movq 0xd0(%rsp), %rax
movl (%rax,%r14,4), %eax
movq 0xb0(%rsp), %rcx
movl (%rcx,%r14,4), %ecx
cmpl %ecx, %eax
jg 0x10afa
movq 0x90(%rsp), %rdx
movl (%rdx,%r14,4), %edx
movq 0x70(%rsp), %rsi
movl (%rsi,%r14,4), %esi
cmpl %esi, %edx
jg 0x10afa
movl 0x168(%rsp), %edi
testl %edi, %edi
jle 0x10a19
movq (%rbp), %rdi
movq 0x10(%rsp), %r9
movslq (%rdi,%r9,4), %rdi
imulq $0x14, %rdi, %rdi
movq (%rbx), %r8
movslq (%r8,%r9,4), %r8
leaq 0x9901b(%rip), %r10     # 0xa99e0
addq %r10, %rdi
movslq -0x18(%rdi,%r8,4), %rdi
movq (%r15), %r8
movq (%r8,%r13), %r8
movslq (%r8), %r9
imulq $0x14, %r9, %r9
movslq 0x4(%r8), %r8
addq %r10, %r9
movslq -0x18(%r9,%r8,4), %r8
leaq 0x99062(%rip), %r9      # 0xa9a50
movslq (%r9,%r8,4), %r8
imulq $0x1c, %rdi, %rdi
leaq 0x99073(%rip), %r9      # 0xa9a70
addq %r9, %rdi
cvtsi2sdl (%rdi,%r8,4), %xmm1
divsd 0x683e2(%rip), %xmm1    # 0x78df0
addsd 0xf0(%rsp), %xmm1
jmp 0x10a1d
xorpd %xmm1, %xmm1
movsd 0x28(%r15), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x10a61
cmpl 0x24(%r15), %r12d
jl 0x10a61
movl %eax, 0x50(%rsp)
movl %ecx, 0x54(%rsp)
movl %edx, 0x58(%rsp)
movl %esi, 0x5c(%rsp)
movl %r12d, 0x60(%rsp)
movsd %xmm1, 0x68(%rsp)
movq 0xe8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1121a
jmp 0x10afa
movsd %xmm1, 0x20(%rsp)
movq (%r15), %rax
movq (%rax,%r13), %rsi
movq %rbp, %rdi
callq 0x651e
movq (%r15), %rax
movq (%rax,%r13), %rsi
addq $0x4, %rsi
movq %rbx, %rdi
callq 0x651e
movq 0xd0(%rsp), %rax
movl (%rax,%r14,4), %eax
movq 0xb0(%rsp), %rcx
movl (%rcx,%r14,4), %r10d
movq 0x90(%rsp), %rcx
movl (%rcx,%r14,4), %r11d
movq 0x70(%rsp), %rcx
movl (%rcx,%r14,4), %r15d
movq 0x18(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
movsd 0x20(%rsp), %xmm0
pushq %r12
pushq %r15
movq 0x28(%rsp), %r15
pushq %r11
pushq %r10
pushq %rax
pushq %rbp
pushq %rbx
pushq 0x168(%rsp)
callq 0x106bc
addq $0x40, %rsp
incq %r14
movl 0x18(%r15), %eax
addq $0x18, %r13
jmp 0x10953
leaq 0x70(%rsp), %rdi
callq 0x4632
leaq 0x90(%rsp), %rdi
callq 0x4632
leaq 0xb0(%rsp), %rdi
callq 0x4632
leaq 0xd0(%rsp), %rdi
callq 0x4632
addq $-0x4, 0x8(%rbp)
addq $-0x4, 0x8(%rbx)
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10b6c
movq %rax, %rbx
jmp 0x10b79
movq %rax, %rbx
jmp 0x10b86
movq %rax, %rbx
jmp 0x10b93
jmp 0x10b6c
jmp 0x10b6c
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4632
leaq 0x90(%rsp), %rdi
callq 0x4632
leaq 0xb0(%rsp), %rdi
callq 0x4632
leaq 0xd0(%rsp), %rdi
callq 0x4632
movq %rbx, %rdi
callq 0x33a0