// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/db_construction.cpp
// Function: DbConstruction::ConstructHashForShortSubstring(DbConstructionParameters, 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>>>>&)
void DbConstruction::ConstructHashForShortSubstring(const DbConstructionParameters parameters,  vector<unsigned char> &encoded_sequences, vector<int> &suffix_array, vector<vector <int> > &start_hash, vector<vector <int> > &end_hash){
  int nucleotide_size = 4;
  
  for(int i = 0; i < parameters.GetHashSize(); i++){
    vector<int> temp_vector; temp_vector.reserve((int)pow(nucleotide_size,i+1));
    start_hash.push_back(temp_vector);
    vector<int> temp_vector2; temp_vector2.reserve((int)pow(nucleotide_size,i+1));
    end_hash.push_back(temp_vector2);
  }

  int start = 0;  int end = 0;
  for(int i = 0; i < parameters.GetHashSize(); i++){
    for(int j  =0; j < (int)pow(nucleotide_size,i+1); j++){
      unsigned char c = (j%4)+2;
      if(i == 0){
	start = 0;
	end = suffix_array.size()-1;
      }else{
	start = start_hash[i-1][j/4];
	end = end_hash[i-1][j/4];
      }
      Search(encoded_sequences, suffix_array, &start, &end, c, i);
      start_hash[i].push_back(start);
      end_hash[i].push_back(end);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, 0x60(%rsp)
movq %r8, 0x58(%rsp)
movq %rcx, %r14
movq %rdx, 0x78(%rsp)
movq %rsi, 0x50(%rsp)
cmpl $0x0, 0x40(%rsi)
jle 0x6686
xorl %r12d, %r12d
movl $0x2, %r13d
leaq 0x10(%rsp), %r15
leaq 0x30(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl %r13d, %ebx
xorps %xmm0, %xmm0
cvtsi2sd %rbx, %xmm0
callq 0x31f0
cvttsd2si %xmm0, %eax
movslq %eax, %rsi
movq %r15, %rdi
callq 0x7740
movq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x489c
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rbx, %xmm0
callq 0x31f0
cvttsd2si %xmm0, %eax
movslq %eax, %rsi
movq %rbp, %rdi
callq 0x7740
movq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0x489c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6659
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6670
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
incl %r12d
addl $0x2, %r13d
movq 0x50(%rsp), %rax
cmpl 0x40(%rax), %r12d
jl 0x65c9
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0x30(%rsp)
movq 0x50(%rsp), %rcx
cmpl %eax, 0x40(%rcx)
jle 0x67f9
xorl %r12d, %r12d
leaq 0x1(%r12), %rax
movq %rax, 0x68(%rsp)
addl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x80(%rsp)
callq 0x31f0
cvttsd2si %xmm0, %eax
testl %eax, %eax
jle 0x67e2
leaq -0x1(%r12), %rax
xorl %ebp, %ebp
leaq (%r12,%r12,2), %r13
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0x70(%rsp)
testq %r12, %r12
je 0x671f
movq 0x58(%rsp), %r15
movq (%r15), %rax
movq 0x70(%rsp), %rdx
movq (%rax,%rdx), %rax
movl %ebp, %ecx
andl $-0x4, %ecx
movl (%rax,%rcx), %eax
movl %eax, 0x10(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rdx), %rax
movl (%rax,%rcx), %eax
leaq 0x10(%rsp), %rcx
jmp 0x673e
movl $0x0, 0x10(%rsp)
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x2, %rax
decl %eax
leaq 0x10(%rsp), %rcx
movq 0x58(%rsp), %r15
movl %ebp, %edx
andb $0x3, %dl
addb $0x2, %dl
movl %eax, 0x30(%rsp)
movl %r12d, (%rsp)
movzbl %dl, %r9d
movq 0x78(%rsp), %rsi
movq %r14, %rbx
movq %r14, %rdx
leaq 0x30(%rsp), %r8
movq %rcx, %r14
callq 0x6f52
movq (%r15), %rax
leaq (%rax,%r13,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x678b
movl 0x10(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x6793
movq %r14, %rdx
callq 0x7da6
movq 0x60(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%r13,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
movq %rbx, %r14
je 0x67bc
movl 0x30(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x67c6
leaq 0x30(%rsp), %rdx
callq 0x7da6
incl %ebp
movsd 0x80(%rsp), %xmm0
callq 0x31f0
cvttsd2si %xmm0, %eax
cmpl %eax, %ebp
jl 0x66e7
movq 0x50(%rsp), %rax
movslq 0x40(%rax), %rax
movq 0x68(%rsp), %r12
cmpq %rax, %r12
jl 0x66a1
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x682a
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x682a
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6841
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0
nop