// File: /workspace/github_c_makefile_star2_O3/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, 0xe8(%rsp)
movq %r9, 0xd0(%rsp)
movq %r8, 0xc8(%rsp)
movq %rcx, 0xc0(%rsp)
movq %rdx, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movl 0x168(%rsp), %eax
movq 0x140(%rsp), %r14
movq 0x138(%rsp), %rcx
cmpl %eax, 0x1c(%rdi)
jle 0x166cf
movq %rdi, %rbx
xorpd %xmm0, %xmm0
leaq 0xa0(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%rbx), %rsi
callq 0x8732
leaq 0x80(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%rbx), %rsi
callq 0x8732
xorpd %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%rbx), %rsi
callq 0x8732
leaq 0x40(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%rbx), %rsi
callq 0x8732
cmpl $0x0, 0x18(%rbx)
jle 0x16657
movl 0x158(%rsp), %r15d
movl 0x168(%rsp), %r12d
movslq %r12d, %rax
movl %eax, %ecx
movq %rcx, 0x38(%rsp)
xorl %r14d, %r14d
leaq 0x18(%rsp), %r13
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0x10(%rsp)
movq %rbx, 0xf0(%rsp)
movl 0x148(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x150(%rsp), %eax
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
leaq (%r14,%r14,2), %rbp
movq (%rax,%rbp,8), %rax
movzbl (%rax), %r9d
subq $0x8, %rsp
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
movq %r13, %rcx
leaq 0x14(%rsp), %r8
pushq %r12
callq 0x16d10
addq $0x10, %rsp
movq 0xa8(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
je 0x1625c
movl 0x18(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xa8(%rsp)
jmp 0x1626c
leaq 0xa0(%rsp), %rdi
movq %r13, %rdx
callq 0x8e4c
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x16292
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x88(%rsp)
jmp 0x162a4
leaq 0x80(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x8e4c
movl %r15d, 0x18(%rsp)
movl 0x160(%rsp), %eax
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
movq (%rax,%rbp,8), %rax
movl 0x4(%rax), %ebp
cmpl %r12d, 0x20(%rbx)
jle 0x1635b
addl $-0x2, %ebp
testl %r12d, %r12d
jle 0x1630d
xorl %r12d, %r12d
movq 0x38(%rsp), %r13
movq 0x138(%rsp), %r15
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
addsd %xmm0, %xmm0
callq 0x31f0
cvttsd2si %xmm0, %eax
movq (%r15), %rcx
movl (%rcx,%r12), %ecx
addl $-0x2, %ecx
imull %eax, %ecx
addl %ecx, %ebp
addq $0x4, %r12
decq %r13
jne 0x162e0
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movslq %ebp, %rcx
movq 0x10(%rsp), %rdx
movq (%rax,%rdx), %rax
movl (%rax,%rcx,4), %eax
movl %eax, 0x18(%rsp)
movq 0x130(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rdx), %rax
movl (%rax,%rcx,4), %eax
movl %eax, 0xc(%rsp)
movl 0x168(%rsp), %r12d
movq 0xf0(%rsp), %rbx
movl 0x158(%rsp), %r15d
jmp 0x16388
subq $0x8, %rsp
movzbl %bpl, %r9d
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x14(%rsp), %r8
pushq %r12
callq 0x16d10
addq $0x10, %rsp
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x163a5
movl 0x18(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x163b4
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x8e4c
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x163d1
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x163e0
leaq 0x40(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x8e4c
incq %r14
movslq 0x18(%rbx), %rax
cmpq %rax, %r14
leaq 0x18(%rsp), %r13
jl 0x161ea
testl %eax, %eax
jle 0x16657
movl 0x168(%rsp), %eax
leal -0x1(%rax), %r15d
leal 0x1(%rax), %r12d
leaq 0x30(%rbx), %rax
movq %rax, 0x38(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
movq 0xa0(%rsp), %rax
movl (%rax,%r14,4), %eax
movq 0x80(%rsp), %rcx
movl (%rcx,%r14,4), %ecx
cmpl %ecx, %eax
jg 0x16643
movq 0x60(%rsp), %rdx
movl (%rdx,%r14,4), %edx
movq 0x40(%rsp), %rsi
movl (%rsi,%r14,4), %esi
cmpl %esi, %edx
jg 0x16643
movl 0x168(%rsp), %edi
testl %edi, %edi
jle 0x164ed
movq 0x140(%rsp), %rdi
movq (%rdi), %rdi
movslq (%rdi,%r15,4), %rdi
leaq (%rdi,%rdi,4), %rdi
movq 0x138(%rsp), %r8
movq (%r8), %r8
movslq (%r8,%r15,4), %r8
leaq 0x99713(%rip), %r10     # 0xafba0
leaq (%r10,%rdi,4), %rdi
movslq -0x18(%rdi,%r8,4), %rdi
movq (%rbx), %r8
movq (%r8,%r13), %r8
movslq (%r8), %r9
leaq (%r9,%r9,4), %r9
movslq 0x4(%r8), %r8
leaq (%r10,%r9,4), %r9
movslq -0x18(%r9,%r8,4), %r8
leaq 0x99758(%rip), %r9      # 0xafc10
movslq (%r9,%r8,4), %r8
leaq (%rdi,%rdi,8), %r9
leaq (%r9,%r9,2), %r9
leaq 0x99765(%rip), %r10     # 0xafc30
addq %r10, %rdi
addq %r9, %rdi
xorps %xmm1, %xmm1
cvtsi2sdl (%rdi,%r8,4), %xmm1
divsd 0x68ace(%rip), %xmm1    # 0x7efb0
addsd 0xe8(%rsp), %xmm1
jmp 0x164f1
xorpd %xmm1, %xmm1
movsd 0x28(%rbx), %xmm0
movsd %xmm1, 0x10(%rsp)
ucomisd %xmm1, %xmm0
jbe 0x16552
cmpl 0x24(%rbx), %r12d
jl 0x16552
movl %eax, 0x18(%rsp)
movl %ecx, 0x1c(%rsp)
movl %edx, 0x20(%rsp)
movl %esi, 0x24(%rsp)
movl %r12d, 0x28(%rsp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x165a9
movupd 0x18(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, 0x38(%rbx)
jmp 0x16643
movq (%rbx), %rax
movq (%rax,%r13), %rdx
movq 0x140(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x16579
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x16585
callq 0x8e4c
movq (%rbx), %rax
movq (%rax,%r13), %rdx
addq $0x4, %rdx
movq 0x138(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x165bd
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x165c2
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x173a8
jmp 0x16643
callq 0x8e4c
movq 0xa0(%rsp), %rax
movl (%rax,%r14,4), %eax
movq 0x80(%rsp), %rcx
movl (%rcx,%r14,4), %r10d
movq 0x60(%rsp), %rcx
movl (%rcx,%r14,4), %r11d
movq 0x40(%rsp), %rcx
movl (%rcx,%r14,4), %ebp
movq %rbx, %rdi
movq 0xd8(%rsp), %rsi
movq 0xe0(%rsp), %rdx
movq 0xc0(%rsp), %rcx
movq 0xc8(%rsp), %r8
movq 0xd0(%rsp), %r9
movsd 0x10(%rsp), %xmm0
pushq %r12
pushq %rbp
pushq %r11
pushq %r10
pushq %rax
pushq 0x168(%rsp)
pushq 0x168(%rsp)
pushq 0x168(%rsp)
callq 0x160c6
addq $0x40, %rsp
incq %r14
movslq 0x18(%rbx), %rax
addq $0x18, %r13
cmpq %rax, %r14
jl 0x1641b
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1666e
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
movq 0x140(%rsp), %r14
je 0x1668d
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x166aa
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x166c7
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x138(%rsp), %rcx
addq $-0x4, 0x8(%r14)
addq $-0x4, 0x8(%rcx)
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16700
jmp 0x16700
movq %rax, %rbx
jmp 0x1671a
movq %rax, %rbx
jmp 0x16731
movq %rax, %rbx
jmp 0x1674e
jmp 0x16700
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1671a
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x16731
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1674e
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1676b
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0
nop