// File: /workspace/github_c_makefile_star2_O2/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 $0x98, %rsp
movq %r9, %rbx
movq %r8, 0x10(%rsp)
movq %rcx, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rsi, 0x20(%rsp)
xorl %r14d, %r14d
pushq $0x2
popq %r12
leaq 0x30(%rsp), %r13
leaq 0x50(%rsp), %rbp
movq 0x20(%rsp), %rax
movl 0x40(%rax), %eax
cmpl %eax, %r14d
jge 0x5878
andq $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movl %r12d, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x31d0
cvttsd2si %xmm0, %eax
movslq %eax, %rsi
movq %r13, %rdi
callq 0x6488
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x40f6
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x31d0
cvttsd2si %xmm0, %eax
movslq %eax, %rsi
movq %rbp, %rdi
callq 0x6488
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x40f6
movq %rbp, %rdi
callq 0x4632
movq %r13, %rdi
callq 0x4632
addl $0x2, %r12d
incl %r14d
jmp 0x57d9
leaq 0x30(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x50(%rsp), %rcx
andl $0x0, (%rcx)
xorl %ecx, %ecx
movq %rbx, 0x28(%rsp)
cltq
cmpq %rax, %rcx
jge 0x59a9
leaq 0x1(%rcx), %rax
movq %rax, 0x70(%rsp)
addl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x18(%rsp)
leaq -0x1(%rcx), %rax
xorl %ebx, %ebx
movq %rcx, 0x90(%rsp)
imulq $0x18, %rcx, %rbp
imulq $0x18, %rax, %rax
movq %rax, 0x78(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x31d0
cvttsd2si %xmm0, %eax
cmpl %eax, %ebx
jge 0x5997
movq 0x90(%rsp), %rsi
testq %rsi, %rsi
movq 0x88(%rsp), %rdx
je 0x5925
movq 0x10(%rsp), %rax
movq (%rax), %r12
movq 0x78(%rsp), %rdi
movq (%r12,%rdi), %rax
movl %ebx, %ecx
andl $-0x4, %ecx
movl (%rax,%rcx), %eax
movl %eax, 0x30(%rsp)
movq 0x28(%rsp), %r15
movq (%r15), %rax
movq (%rax,%rdi), %rax
movl (%rax,%rcx), %eax
jmp 0x5944
andl $0x0, 0x30(%rsp)
movq 0x8(%rdx), %rax
subq (%rdx), %rax
shrq $0x2, %rax
decl %eax
movq 0x10(%rsp), %rcx
movq (%rcx), %r12
movq 0x28(%rsp), %r15
movl %ebx, %ecx
andb $0x3, %cl
addb $0x2, %cl
movl %eax, 0x50(%rsp)
movl %esi, (%rsp)
movzbl %cl, %r9d
movq 0x80(%rsp), %rsi
leaq 0x30(%rsp), %r13
movq %r13, %rcx
leaq 0x50(%rsp), %r14
movq %r14, %r8
callq 0x5e6a
addq %rbp, %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x651e
movq (%r15), %rdi
addq %rbp, %rdi
movq %r14, %rsi
callq 0x651e
incl %ebx
jmp 0x58cb
movq 0x20(%rsp), %rax
movl 0x40(%rax), %eax
movq 0x70(%rsp), %rcx
jmp 0x588f
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4632
jmp 0x59cd
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4632
movq %rbx, %rdi
callq 0x33a0
nop