// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/sfx-maprange.c
// Function: gt_Sfxmappedrange_map
void *gt_Sfxmappedrange_map(GtSfxmappedrange *sfxmappedrange,
                            GtUword minindex,
                            GtUword maxindex)
{
  gt_assert(sfxmappedrange != NULL);
  if (sfxmappedrange->ptr != NULL)
  {
    gt_fa_xmunmap(sfxmappedrange->ptr);
  }
  if (sfxmappedrange->transformfunc != NULL)
  {
    sfxmappedrange->transformfunc(&minindex,&maxindex,
                                  sfxmappedrange->transformfunc_data);
  }
  if (minindex <= maxindex)
  {
    GtMappedrange lbrange;
    GtUword unitoffset;
    size_t sizeoftable;

    gt_Sfxmapped_offset_end(&lbrange,
                            sfxmappedrange->sizeofunit,
                            sfxmappedrange->pagesize,
                            minindex,
                            maxindex);
    sizeoftable = gt_Sfxmappedrange_size_entire(sfxmappedrange);
    gt_log_log("mapped %s["GT_WU".."GT_WU"] for %s (%.1f%% of all)",
               gt_str_get(sfxmappedrange->tablename),
               lbrange.mapoffset,
               lbrange.mapend,
               sfxmappedrange->writable ? "writing" : "reading",
               (lbrange.mapend - lbrange.mapoffset + 1
                 >= (GtUword) sizeoftable)
                    ? 100.0
                    : 100.0 * (lbrange.mapend - lbrange.mapoffset + 1)/
                               sizeoftable);
    gt_assert(lbrange.mapoffset <= lbrange.mapend);
    gt_assert(lbrange.mapoffset <= minindex * sfxmappedrange->sizeofunit);
    gt_assert(maxindex * sfxmappedrange->sizeofunit <= lbrange.mapend);
    gt_assert(lbrange.mapoffset % sfxmappedrange->pagesize == 0);
    if (sfxmappedrange->writable)
    {
      sfxmappedrange->ptr
        = gt_fa_xmmap_write_range(gt_str_get(sfxmappedrange->filename),
                                  (size_t) (lbrange.mapend-lbrange.mapoffset+1),
                                  (size_t) lbrange.mapoffset);
    } else
    {
      sfxmappedrange->ptr
        = gt_fa_xmmap_read_range (gt_str_get(sfxmappedrange->filename),
                                  (size_t) (lbrange.mapend-lbrange.mapoffset+1),
                                  (size_t) lbrange.mapoffset);
    }
    sfxmappedrange->indexrange_defined = true;
    sfxmappedrange->currentmaxindex = maxindex;
    sfxmappedrange->currentminindex = minindex;
    unitoffset = lbrange.mapoffset / sfxmappedrange->sizeofunit;
    switch (sfxmappedrange->type)
    {
      case GtSfxGtBitsequence:
        return ((GtBitsequence *) sfxmappedrange->ptr) - unitoffset;
      case GtSfxuint32_t:
        return ((uint32_t *) sfxmappedrange->ptr) - unitoffset;
      case GtSfxunsignedlong:
        return ((GtUword *) sfxmappedrange->ptr) - unitoffset;
      default:
        gt_assert(false);
        break;
    }
    gt_assert(false);
  }
  sfxmappedrange->ptr = NULL;
  sfxmappedrange->indexrange_defined = true;
  sfxmappedrange->currentmaxindex = maxindex;
  sfxmappedrange->currentminindex = minindex;
  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
testq %rdi, %rdi
je 0x1f8b7d
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x1f899b
callq 0x102b12
movq 0x60(%rbx), %rax
testq %rax, %rax
je 0x1f89b4
movq 0x68(%rbx), %rdx
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq *%rax
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rcx
cmpq %rcx, %r14
jbe 0x1f89dd
movq $0x0, (%rbx)
movb $0x1, 0x58(%rbx)
movq %rcx, 0x50(%rbx)
movq %r14, 0x48(%rbx)
xorl %ecx, %ecx
jmp 0x1f8b6b
movq 0x38(%rbx), %r13
movq 0x20(%rbx), %rdi
movq 0x28(%rbx), %r15
imulq %r13, %r14
movq %r14, %rax
xorl %edx, %edx
divq %r15
subq %rdx, %r14
imulq %r13, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq %r15
addq %rcx, %r15
subq %rdx, %r15
testq %rdx, %rdx
cmoveq %rcx, %r15
imulq 0x30(%rbx), %r13
callq 0x120d23
leaq 0x1f81e7(%rip), %rcx    # 0x3f0c09
cmpb $0x0, 0x70(%rbx)
leaq 0x1f81b5(%rip), %r8     # 0x3f0be2
cmovneq %rcx, %r8
movq %r15, %rcx
subq %r14, %rcx
leaq 0x1(%rcx), %r12
movsd 0x159dad(%rip), %xmm0   # 0x3527f0
cmpq %r13, %r12
jae 0x1f8a96
movq %r12, %xmm1
movq 0x157e8b(%rip), %xmm2   # 0x3508e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x157e8f(%rip), %xmm3   # 0x3508f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm4
unpckhpd %xmm1, %xmm4            # xmm4 = xmm4[1],xmm1[1]
addsd %xmm1, %xmm4
mulsd %xmm0, %xmm4
movq %r13, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm4
movapd %xmm4, %xmm0
leaq 0x1c91bd(%rip), %rdi    # 0x3c1c5a
movq %rax, %rsi
movq %r14, %rdx
movq %r15, %rcx
movb $0x1, %al
callq 0x108e02
cmpq %r14, %r15
jb 0x1f8b82
movq 0x38(%rbx), %rax
movq 0x10(%rsp), %rcx
imulq %rax, %rcx
cmpq %rcx, %r14
ja 0x1f8b87
imulq 0x8(%rsp), %rax
cmpq %r15, %rax
ja 0x1f8b8c
movq %r14, %rax
xorl %edx, %edx
divq 0x28(%rbx)
testq %rdx, %rdx
jne 0x1f8b91
movb 0x70(%rbx), %bpl
movq 0x18(%rbx), %rdi
callq 0x120d23
leaq 0x1c8f9a(%rip), %rcx    # 0x3c1a9b
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
cmpb $0x1, %bpl
jne 0x1f8b1d
movl $0x159, %r8d            # imm = 0x159
callq 0x102ad9
jmp 0x1f8b28
movl $0x15f, %r8d            # imm = 0x15F
callq 0x102a6a
movq %rax, %rcx
movq %rax, (%rbx)
movb $0x1, 0x58(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rbx)
movq %r14, %rax
xorl %edx, %edx
divq 0x38(%rbx)
movl 0x40(%rbx), %edx
cmpl $0x2, %edx
je 0x1f8b64
cmpl $0x1, %edx
je 0x1f8b5e
testl %edx, %edx
jne 0x1f8b96
shlq $0x3, %rax
jmp 0x1f8b68
shlq $0x2, %rax
subq %rax, %rcx
movq %rcx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7b52d
callq 0x7b4f4
callq 0x7b4bb
callq 0x7b482
callq 0x7b410
callq 0x7b449