// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/tyr-mersplit.c
// Function: gt_constructmerbuckets
int gt_constructmerbuckets(const char *inputindex,
                           const Definedunsignedint *callprefixlength,
                           GtError *err)
{
  Tyrindex *tyrindex;
  Tyrbckinfo tyrbckinfo;
  FILE *bucketfp = NULL;
  bool haserr = false;

  gt_error_check(err);
  tyrbckinfo.bounds = NULL;
  tyrbckinfo.boundisdefined = NULL;
  tyrbckinfo.prefixlength = 0;
  tyrindex = gt_tyrindex_new(inputindex,err);
  if (tyrindex == NULL)
  {
    haserr = true;
  }
  if (!haserr && tyrindex != NULL && !gt_tyrindex_isempty(tyrindex))
  {
    if (gt_determinetyrbckpfxlen(&tyrbckinfo.prefixlength,
                              tyrindex,
                              callprefixlength,
                              err) != 0)
    {
      haserr = true;
    }
  }
  if (!haserr && tyrindex != NULL && !gt_tyrindex_isempty(tyrindex))
  {
    gt_assert(tyrbckinfo.prefixlength > 0);
    printf("# construct mer buckets for prefixlength %u\n",
            tyrbckinfo.prefixlength);
    tyrbckinfo.numofcodes
      = gt_power_for_small_exponents(gt_tyrindex_alphasize(tyrindex),
                                     tyrbckinfo.prefixlength);
    tyrbckinfo.mappedmbdfileptr = NULL;
    printf("# numofcodes = "GT_WU"\n",tyrbckinfo.numofcodes);
    gt_tyrindex_show(tyrindex);
    tyrbckinfo.bounds = gt_malloc(sizeof *tyrbckinfo.bounds
                                  * (tyrbckinfo.numofcodes+1));
    GT_INITBITTAB(tyrbckinfo.boundisdefined,tyrbckinfo.numofcodes+1);
    splitmerinterval(&tyrbckinfo,tyrindex);
    bucketfp = gt_fa_fopen_with_suffix(inputindex,BUCKETSUFFIX,"wb",err);
    if (bucketfp == NULL)
    {
      haserr = true;
    }
  }
  if (!haserr && tyrindex != NULL && !gt_tyrindex_isempty(tyrindex))
  {
    GtUword pl_long = (GtUword) tyrbckinfo.prefixlength;
    gt_assert(bucketfp != NULL);
    gt_xfwrite(&pl_long, sizeof (pl_long), (size_t) 1, bucketfp);
  }
  if (!haserr && tyrindex != NULL && !gt_tyrindex_isempty(tyrindex))
  {
    gt_assert(bucketfp != NULL);
    gt_xfwrite(tyrbckinfo.bounds, sizeof (*tyrbckinfo.bounds),
               (size_t) (tyrbckinfo.numofcodes+1), bucketfp);
  }
  if (!haserr && tyrindex != NULL && !gt_tyrindex_isempty(tyrindex))
  {
    gt_assert(bucketfp != NULL);
    gt_xfwrite(tyrbckinfo.boundisdefined, sizeof (*tyrbckinfo.boundisdefined),
               GT_NUMOFINTSFORBITS(tyrbckinfo.numofcodes+1), bucketfp);
  }
  gt_fa_xfclose(bucketfp);
  if (tyrindex != NULL)
  {
    gt_tyrindex_delete(&tyrindex);
  }
  gt_free(tyrbckinfo.bounds);
  gt_free(tyrbckinfo.boundisdefined);
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r13
testq %rdx, %rdx
je 0x1b5726
movq %r14, %rdi
callq 0x89eb7
testb %al, %al
jne 0x1b5b00
andl $0x0, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x2cd22e
movq %rax, %r12
movq %rax, 0x80(%rsp)
testq %rax, %rax
je 0x1b575f
movq %r12, %rdi
callq 0x2cd407
testb %al, %al
je 0x1b576a
xorl %r15d, %r15d
jmp 0x1b5783
movb $0x1, %r15b
xorl %r14d, %r14d
jmp 0x1b5aa3
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2cd7f0
testl %eax, %eax
setne %r15b
testq %r12, %r12
sete %al
orb %r15b, %al
jne 0x1b579d
movq %r12, %rdi
callq 0x2cd407
testb %al, %al
je 0x1b57a5
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0x1b59f6
movq %r13, 0x58(%rsp)
movq %r14, 0x60(%rsp)
movl 0x18(%rsp), %esi
testl %esi, %esi
je 0x1b5b38
leaq 0x1a7562(%rip), %rdi    # 0x35cd24
xorl %eax, %eax
callq 0x17070
movq %r12, %rdi
callq 0x2cd424
movl 0x18(%rsp), %esi
movl %eax, %edi
callq 0x95871
movq %rax, 0x20(%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x1a7563(%rip), %rdi    # 0x35cd51
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
movq %r12, %rdi
callq 0x2cd3a9
movq 0x20(%rsp), %rax
leaq 0x8(,%rax,8), %rdi
leaq 0x1a74c4(%rip), %rbx    # 0x35ccd8
movq %rbx, %rsi
movl $0x16b, %edx            # imm = 0x16B
callq 0x93160
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
leaq 0x1(%rax), %rcx
shrq $0x6, %rax
cmpq $0x40, %rcx
leaq 0x8(,%rax,8), %rax
pushq $0x8
popq %r14
cmovaeq %rax, %r14
xorl %edi, %edi
movq %r14, %rsi
movq %rbx, %rdx
movl $0x16c, %ecx            # imm = 0x16C
callq 0x93472
movq %rax, 0x28(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x17380
movq %r12, %rdi
callq 0x2cd410
movq %rax, %rbx
movq %r12, %rdi
callq 0x2cd415
movq %rax, %r14
movq %r12, 0x50(%rsp)
movq %r12, %rdi
callq 0x2cd41a
movq %rax, %rbp
movl 0x18(%rsp), %esi
movq %rax, %rdi
movl %esi, 0x4(%rsp)
movq %r14, 0x40(%rsp)
movq %r14, %rdx
callq 0x1b56b5
movq %rax, 0x68(%rsp)
leaq (,%rbp,2), %r14
movq 0x28(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbx, 0x48(%rsp)
movq %rbx, %r12
movq %rbp, %rdi
movl 0x4(%rsp), %esi
movq %r12, %rdx
callq 0x1b56b5
movq %rax, %rbx
movq %r12, %rax
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
movq %rsi, %rdx
movl %ebx, %ecx
shrq %cl, %rdx
subq 0x48(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
movq %rbx, %rax
shrq $0x6, %rax
movq 0x70(%rsp), %r8
orq %rdx, (%r8,%rax,8)
cmpq 0x68(%rsp), %rbx
je 0x1b5960
movq 0x40(%rsp), %r13
movq %r12, %r15
leaq (%r15,%rbp), %r12
cmpq %r13, %r12
jae 0x1b58d2
movq %r13, %rax
subq %r15, %rax
xorl %edx, %edx
divq %r14
movq %rax, %r12
imulq %rbp, %r12
addq %r15, %r12
movq %rbp, %rdi
movl 0x4(%rsp), %esi
movq %r12, %rdx
callq 0x1b56b5
cmpq %rbx, %rax
cmovaq %r12, %r13
cmovbeq %r12, %r15
jmp 0x1b5926
movq 0x40(%rsp), %rdx
addq %rbp, %rdx
subq 0x48(%rsp), %rdx
movq 0x20(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rdx, (%rcx,%rax,8)
movq 0x20(%rsp), %rcx
movq %rsi, %rax
shrq %cl, %rax
shrq $0x6, %rcx
orq %rax, (%r8,%rcx,8)
movq 0x20(%rsp), %rcx
decq %rcx
movq 0x50(%rsp), %r12
movq 0x60(%rsp), %r9
movq 0x58(%rsp), %rdi
movq %rsi, %rax
shrq %cl, %rax
movq %rcx, %rdx
shrq $0x6, %rdx
testq %rax, (%r8,%rdx,8)
jne 0x1b59c6
movq 0x8(%rsp), %rdx
movq 0x8(%rdx,%rcx,8), %rax
movq %rax, (%rdx,%rcx,8)
addq $-0x1, %rcx
jb 0x1b59a5
leaq 0x1a7392(%rip), %rsi    # 0x35cd65
leaq 0x140117(%rip), %rdx    # 0x2f5af1
leaq 0x1a72f7(%rip), %rcx    # 0x35ccd8
movl $0x16e, %r8d            # imm = 0x16E
callq 0x8a449
movq %rax, %r14
testq %rax, %rax
sete %r15b
testq %r12, %r12
sete %al
orb %r15b, %al
jne 0x1b5aa3
movq %r12, %rdi
callq 0x2cd407
testb %al, %al
jne 0x1b5a36
movl 0x18(%rsp), %eax
movq %rax, 0x78(%rsp)
testq %r14, %r14
je 0x1b5b66
leaq 0x78(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xb302c
movq %r12, %rdi
callq 0x2cd407
testb %al, %al
jne 0x1b5a63
testq %r14, %r14
je 0x1b5b94
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rdi
incq %rdx
pushq $0x8
popq %rsi
movq %r14, %rcx
callq 0xb302c
movq %r12, %rdi
callq 0x2cd407
testb %al, %al
jne 0x1b5aa3
testq %r14, %r14
je 0x1b5bc5
pushq $0x1
popq %rax
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rdi
leaq 0x1(%rdx), %rcx
shrq $0x6, %rdx
incq %rdx
cmpq $0x40, %rcx
cmovbq %rax, %rdx
pushq $0x8
popq %rsi
movq %r14, %rcx
callq 0xb302c
movq %r14, %rdi
callq 0x8a5e5
testq %r12, %r12
je 0x1b5abd
leaq 0x80(%rsp), %rdi
callq 0x2cd436
movq 0x30(%rsp), %rdi
leaq 0x1a720f(%rip), %rbx    # 0x35ccd8
movq %rbx, %rsi
movl $0x18b, %edx            # imm = 0x18B
callq 0x936f9
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl $0x18c, %edx            # imm = 0x18C
callq 0x936f9
movzbl %r15b, %eax
negl %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x282461(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x12f502(%rip), %rsi    # 0x2e5013
leaq 0x12f6a7(%rip), %rdx    # 0x2e51bf
leaq 0x1a71d2(%rip), %rcx    # 0x35ccf1
leaq 0x1a71b2(%rip), %r8     # 0x35ccd8
movl $0x14c, %r9d            # imm = 0x14C
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x282429(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x12f4ca(%rip), %rsi    # 0x2e5013
leaq 0x1a71b8(%rip), %rdx    # 0x35cd08
leaq 0x1a719a(%rip), %rcx    # 0x35ccf1
leaq 0x1a717a(%rip), %r8     # 0x35ccd8
movl $0x161, %r9d            # imm = 0x161
jmp 0x1b5b2c
movq 0x2823fb(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x12f49c(%rip), %rsi    # 0x2e5013
leaq 0x1a71ec(%rip), %rdx    # 0x35cd6a
leaq 0x1a716c(%rip), %rcx    # 0x35ccf1
leaq 0x1a714c(%rip), %r8     # 0x35ccd8
movl $0x177, %r9d            # imm = 0x177
jmp 0x1b5b2c
movq 0x2823cd(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x12f46e(%rip), %rsi    # 0x2e5013
leaq 0x1a71be(%rip), %rdx    # 0x35cd6a
leaq 0x1a713e(%rip), %rcx    # 0x35ccf1
leaq 0x1a711e(%rip), %r8     # 0x35ccd8
movl $0x17c, %r9d            # imm = 0x17C
jmp 0x1b5b2c
movq 0x28239c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x12f43d(%rip), %rsi    # 0x2e5013
leaq 0x1a718d(%rip), %rdx    # 0x35cd6a
leaq 0x1a710d(%rip), %rcx    # 0x35ccf1
leaq 0x1a70ed(%rip), %r8     # 0x35ccd8
movl $0x182, %r9d            # imm = 0x182
jmp 0x1b5b2c