// File: /workspace/github_c_makefile_star2_O0/fukunagatsu[P]RIblast/seed_search.cpp
// Function: SeedSearch::GetSeqIdAndStart(std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, int*, int*, int, int)
void SeedSearch::GetSeqIdAndStart(vector<int> &db_seq_length, vector<int> &db_seq_start_position, int* seq_id, int* start, int sp, int length){
  int s = 0;
  int e = db_seq_start_position.size()-1;
  int m = (s+e)/2;

  while(true){
    if(e-s == 0){
      *seq_id  = s; *start = db_seq_length[s] - (sp - db_seq_start_position[s]) - length;
      break;
    }else if(e-s==1){
      if(sp >= db_seq_start_position[s] && sp < db_seq_start_position[s+1]){
	*seq_id  = s; *start = db_seq_length[s] - (sp - db_seq_start_position[s]) - length;
	break;
      }else{
	*seq_id  = e; *start = db_seq_length[e] - (sp - db_seq_start_position[e]) - length;
	break;
      }
    }else{    
      if(sp >= db_seq_start_position[m] && sp < db_seq_start_position[m+1]){
	*seq_id  = m;
	*start = db_seq_length[m] - (sp - db_seq_start_position[m]) - length;
	break;
      }else{
	if(sp >= db_seq_start_position[m]){
	  s = m;
	  m = (s+e)/2;
	}else{
	  e = m;
	  m = (s+e)/2;
	}
      }
    }
  }
  
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x55a0
subq $0x1, %rax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
subl -0x30(%rbp), %eax
cmpl $0x0, %eax
jne 0x2abef
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xbac0
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xbac0
movl -0x40(%rbp), %ecx
movq %rax, %rdx
movl -0x3c(%rbp), %eax
subl (%rdx), %eax
subl %eax, %ecx
subl 0x10(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2adac
movl -0x34(%rbp), %eax
subl -0x30(%rbp), %eax
cmpl $0x1, %eax
jne 0x2accf
movl -0x2c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xbac0
movq %rax, %rcx
movl -0x44(%rbp), %eax
cmpl (%rcx), %eax
jl 0x2ac86
movl -0x2c(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xbac0
movq %rax, %rcx
movl -0x48(%rbp), %eax
cmpl (%rcx), %eax
jge 0x2ac86
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xbac0
movl (%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xbac0
movl -0x50(%rbp), %ecx
movq %rax, %rdx
movl -0x4c(%rbp), %eax
subl (%rdx), %eax
subl %eax, %ecx
subl 0x10(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2adac
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xbac0
movl (%rax), %eax
movl %eax, -0x58(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xbac0
movl -0x58(%rbp), %ecx
movq %rax, %rdx
movl -0x54(%rbp), %eax
subl (%rdx), %eax
subl %eax, %ecx
subl 0x10(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2adac
movl -0x2c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0xbac0
movq %rax, %rcx
movl -0x5c(%rbp), %eax
cmpl (%rcx), %eax
jl 0x2ad54
movl -0x2c(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movl -0x38(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xbac0
movq %rax, %rcx
movl -0x60(%rbp), %eax
cmpl (%rcx), %eax
jge 0x2ad54
movl -0x38(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0xbac0
movl (%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0xbac0
movl -0x68(%rbp), %ecx
movq %rax, %rdx
movl -0x64(%rbp), %eax
subl (%rdx), %eax
subl %eax, %ecx
subl 0x10(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2adac
movl -0x2c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0xbac0
movq %rax, %rcx
movl -0x6c(%rbp), %eax
cmpl (%rcx), %eax
jl 0x2ad8a
movl -0x38(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x38(%rbp)
jmp 0x2ada1
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x38(%rbp)
jmp 0x2ada3
jmp 0x2ada5
jmp 0x2ada7
jmp 0x2ab9b
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)