// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/core/encseq.c
// Function: gt_encseq_sep2seqnum
GtUword gt_encseq_sep2seqnum(const GtUword *recordseps,
                                   GtUword numofrecords,
                                   GtUword totalwidth,
                                   GtUword position)
{
  GtUword left, mid, right, len;

  gt_assert(numofrecords > 0);
  if (numofrecords == 1UL || position <= recordseps[0])
    return 0;
  if (position > recordseps[numofrecords-2]) {
    if (position < totalwidth)
      return numofrecords - 1;
    fprintf(stderr,
            "gt_encseq_sep2seqnum: cannot find position "GT_WU"\n", position);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  left = 0;
  right = numofrecords - 2;
  while (left<=right) {
    len = right-left;
    mid = left + GT_DIV2(len);
    if (recordseps[mid] < position) {
      if (position <= recordseps[mid+1])
        return mid + 1;
      left = mid + 1;
    }
    else {
      if (recordseps[mid-1] < position)
        return mid;
      right = mid-1;
    }
  }
  fprintf(stderr, "gt_encseq_sep2seqnum: cannot find position "GT_WU"\n",
          position);
  exit(GT_EXIT_PROGRAMMING_ERROR);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
cmpq $0x0, 0x30(%rsp)
ja 0x119ee8
movq 0x9a121(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x441a5(%rip), %rsi     # 0x15e066
leaq 0x6c0ed(%rip), %rdx     # 0x185fb5
leaq 0x6c0f7(%rip), %rcx     # 0x185fc6
leaq 0x6b788(%rip), %r8      # 0x18565e
movl $0xf26, %r9d            # imm = 0xF26
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x119eea
cmpq $0x1, 0x30(%rsp)
je 0x119f01
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq (%rcx), %rax
ja 0x119f0f
movq $0x0, 0x40(%rsp)
jmp 0x11a061
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rdx
subq $0x2, %rdx
cmpq (%rcx,%rdx,8), %rax
jbe 0x119f6e
movq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
jae 0x119f47
movq 0x30(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x11a061
movq 0x9a08a(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x6c07e(%rip), %rsi     # 0x185fdb
movb $0x0, %al
callq 0xb890
movl $0x2, %edi
callq 0xb780
movq $0x0, 0x18(%rsp)
movq 0x30(%rsp), %rax
subq $0x2, %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
ja 0x11a03a
movq 0x8(%rsp), %rax
subq 0x18(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rax
movq (%rsp), %rcx
shrq %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x20(%rsp), %rax
jae 0x11a002
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
movq 0x10(%rsp), %rdx
cmpq 0x8(%rcx,%rdx,8), %rax
ja 0x119ff2
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x11a061
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x11a035
movq 0x38(%rsp), %rax
movq 0x10(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x20(%rsp), %rax
jae 0x11a027
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x11a061
movq 0x10(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x119f85
movq 0x99f97(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x6bf8b(%rip), %rsi     # 0x185fdb
movb $0x0, %al
callq 0xb890
movl $0x2, %edi
callq 0xb780
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopl (%rax,%rax)