// File: /workspace/github_c_makefile_star2_O1/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 $0xe8, %rsp
movsd %xmm0, 0xe0(%rsp)
movq %r9, 0xc8(%rsp)
movq %r8, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movq %rdx, 0xd8(%rsp)
movq %rsi, 0xd0(%rsp)
movl 0x158(%rsp), %r13d
movq 0x130(%rsp), %rax
movq 0x128(%rsp), %rcx
cmpl %r13d, 0x1c(%rdi)
jle 0x1482c
movq %rdi, %r15
xorpd %xmm0, %xmm0
leaq 0xa0(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x7740
leaq 0x80(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x7740
xorpd %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x7740
leaq 0x40(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq 0x18(%r15), %rsi
callq 0x7740
cmpl $0x0, 0x18(%r15)
jle 0x14550
movl 0x148(%rsp), %r12d
movslq %r13d, %rax
movl %eax, %ecx
movq %rcx, 0x38(%rsp)
xorl %r14d, %r14d
leaq 0x18(%rsp), %rbx
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0x10(%rsp)
movl 0x138(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x140(%rsp), %eax
movl %eax, 0xc(%rsp)
movq (%r15), %rax
leaq (%r14,%r14,2), %rbp
movq (%rax,%rbp,8), %rax
movzbl (%rax), %r9d
subq $0x8, %rsp
movq 0xd8(%rsp), %rsi
movq 0xe0(%rsp), %rdx
movq %rbx, %rcx
leaq 0x14(%rsp), %r8
pushq %r13
callq 0x14e70
addq $0x10, %rsp
movq 0xa8(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
je 0x143bf
movl 0x18(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xa8(%rsp)
jmp 0x143cf
leaq 0xa0(%rsp), %rdi
movq %rbx, %rdx
callq 0x7da6
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x143f5
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x88(%rsp)
jmp 0x14407
leaq 0x80(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x7da6
movl %r12d, 0x18(%rsp)
movl 0x150(%rsp), %eax
movl %eax, 0xc(%rsp)
movq (%r15), %rax
movq (%rax,%rbp,8), %rax
movl 0x4(%rax), %ebp
cmpl %r13d, 0x20(%r15)
jle 0x144b6
addl $-0x2, %ebp
testl %r13d, %r13d
jle 0x14470
xorl %r12d, %r12d
movq 0x38(%rsp), %r13
movq 0x128(%rsp), %rbx
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
addsd %xmm0, %xmm0
callq 0x31f0
cvttsd2si %xmm0, %eax
movq (%rbx), %rcx
movl (%rcx,%r12), %ecx
addl $-0x2, %ecx
imull %eax, %ecx
addl %ecx, %ebp
addq $0x4, %r12
decq %r13
jne 0x14443
movq 0xc8(%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 0x120(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rdx), %rax
movl (%rax,%rcx,4), %eax
movl %eax, 0xc(%rsp)
movl 0x158(%rsp), %r13d
movl 0x148(%rsp), %r12d
jmp 0x144e3
subq $0x8, %rsp
movzbl %bpl, %r9d
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x14(%rsp), %r8
pushq %r13
callq 0x14e70
addq $0x10, %rsp
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x14500
movl 0x18(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x1450f
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x7da6
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x1452c
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x1453b
leaq 0x40(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x7da6
incq %r14
movslq 0x18(%r15), %rax
cmpq %rax, %r14
leaq 0x18(%rsp), %rbx
jl 0x1434d
cmpl $0x0, 0x18(%r15)
jle 0x147b4
leal -0x1(%r13), %ebx
leal 0x1(%r13), %r12d
leaq 0x30(%r15), %rax
movq %rax, 0x38(%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0xa0(%rsp), %rax
movl (%rax,%rbp,4), %edx
movq 0x80(%rsp), %rcx
cmpl (%rcx,%rbp,4), %edx
jg 0x147a0
movq 0x60(%rsp), %rdx
movl (%rdx,%rbp,4), %edi
movq 0x40(%rsp), %rsi
cmpl (%rsi,%rbp,4), %edi
jg 0x147a0
testl %r13d, %r13d
jle 0x14635
movq 0x130(%rsp), %rdi
movq (%rdi), %rdi
movslq (%rdi,%rbx,4), %rdi
leaq (%rdi,%rdi,4), %rdi
movq 0x128(%rsp), %r8
movq (%r8), %r8
movslq (%r8,%rbx,4), %r8
leaq 0x9a3fb(%rip), %r10     # 0xae9d0
leaq (%r10,%rdi,4), %rdi
movslq -0x18(%rdi,%r8,4), %rdi
movq (%r15), %r8
movq (%r8,%r14), %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 0x9a440(%rip), %r9      # 0xaea40
movslq (%r9,%r8,4), %r8
leaq (%rdi,%rdi,8), %r9
leaq (%r9,%r9,2), %r9
leaq 0x9a44d(%rip), %r10     # 0xaea60
addq %r10, %rdi
addq %r9, %rdi
xorps %xmm1, %xmm1
cvtsi2sdl (%rdi,%r8,4), %xmm1
divsd 0x697b6(%rip), %xmm1    # 0x7dde0
addsd 0xe0(%rsp), %xmm1
jmp 0x14639
xorpd %xmm1, %xmm1
movsd 0x28(%r15), %xmm0
movsd %xmm1, 0x10(%rsp)
ucomisd %xmm1, %xmm0
jbe 0x146a7
cmpl 0x24(%r15), %r12d
jl 0x146a7
movl (%rax,%rbp,4), %eax
movl (%rcx,%rbp,4), %ecx
movl (%rdx,%rbp,4), %edx
movl (%rsi,%rbp,4), %esi
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(%r15), %rsi
cmpq 0x40(%r15), %rsi
je 0x146fe
movupd 0x18(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, 0x38(%r15)
jmp 0x147a0
movq (%r15), %rax
movq (%rax,%r14), %rdx
movq 0x130(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x146ce
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x146d3
callq 0x7da6
movq (%r15), %rax
movq (%rax,%r14), %rdx
addq $0x4, %rdx
movq 0x128(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x14712
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x14717
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x1554c
jmp 0x147a0
callq 0x7da6
movq 0xa0(%rsp), %rax
movl (%rax,%rbp,4), %eax
movq 0x80(%rsp), %rcx
movl (%rcx,%rbp,4), %r10d
movq 0x60(%rsp), %rcx
movl (%rcx,%rbp,4), %r11d
movq 0x40(%rsp), %rcx
movl (%rcx,%rbp,4), %r13d
movq %r15, %rdi
movq 0xd0(%rsp), %rsi
movq 0xd8(%rsp), %rdx
movq 0xb8(%rsp), %rcx
movq 0xc0(%rsp), %r8
movq 0xc8(%rsp), %r9
movsd 0x10(%rsp), %xmm0
pushq %r12
pushq %r13
movl 0x168(%rsp), %r13d
pushq %r11
pushq %r10
pushq %rax
pushq 0x158(%rsp)
pushq 0x158(%rsp)
pushq 0x158(%rsp)
callq 0x14236
addq $0x40, %rsp
incq %rbp
movslq 0x18(%r15), %rax
addq $0x18, %r14
cmpq %rax, %rbp
jl 0x14571
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x147cb
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x147e2
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x147ff
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1481c
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x130(%rsp), %rax
movq 0x128(%rsp), %rcx
addq $-0x4, 0x8(%rax)
addq $-0x4, 0x8(%rcx)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1485d
jmp 0x1485d
movq %rax, %rbx
jmp 0x14877
movq %rax, %rbx
jmp 0x1488e
movq %rax, %rbx
jmp 0x148ab
jmp 0x1485d
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x14877
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1488e
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x148ab
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x148c8
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0