// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/rbtree.c
// Function: nrbt_mangle_tree
static bool nrbt_mangle_tree(GtRBTreeSearchOrder how, GtRBTreeDoAction what,
                             GtRBTree *tree, GtUword lag, GtError *err)
{
  GtUword i;
  bool nodecreated, haserr = false;

  if (how == GT_RBTREE_RANDOMORDER) {
    for (i = 0; i < (GtUword) GT_RBTREE_SIZE; ++i) {
      gt_rbtree_ytab[i] = i;
    }
    gt_rbtree_permuteintarray (gt_rbtree_ytab);
  }
  for (i = 0; i < GT_RBTREE_SIZE + lag; ++i) {
    void *elem;
    GtUword j, k;

    switch (how) {
      case GT_RBTREE_RANDOMORDER:
        if (i >= lag) {
          k = gt_rbtree_ytab[i - lag];
        } else {
          k = gt_rbtree_ytab[GT_RBTREE_SIZE - i - 1 + lag];
        }
        j = gt_rbtree_ytab[i];
        break;

      case GT_RBTREE_ASCENDING:
        k = i - lag;
        j = i;
        break;

      case GT_RBTREE_DESCENDING:
        k = GT_RBTREE_SIZE - i - 1 + lag;
        j = GT_RBTREE_SIZE - i - 1;
        break;

      default:
        abort ();
    }

    switch (what) {
      case GtRBTreeBuildDelete:
      case GtRBTreeBuild:
        if (i < (GtUword) GT_RBTREE_SIZE) {
          if (gt_rbtree_find (tree, gt_rbtree_xtab + j) != NULL) {
            gt_error_set(err,"Found element which is not in tree yet");
            haserr = true;
          }
          if (!haserr) {
            elem = gt_rbtree_search(tree, gt_rbtree_xtab + j, &nodecreated);
            if (elem == NULL || gt_rbtree_find(tree,
                                               gt_rbtree_xtab + j) == NULL) {
              gt_error_set(err,"Couldn't find element after it was added");
              haserr = true;
            }
          }
        }
        if (haserr || what ==GtRBTreeBuild || i < lag)
          break;
        j = k;
        /*@fallthrough@*/
      case GtRBTreeDelete:
        elem = gt_rbtree_find (tree, gt_rbtree_xtab + j);
        if (elem == NULL || gt_rbtree_erase (tree, gt_rbtree_xtab + j) != 0) {
          gt_error_set(err,"Error deleting element");
          haserr = true;
        }
        break;

      case GtRBTreeFind:
        if (gt_rbtree_find (tree, gt_rbtree_xtab + j) == NULL) {
          gt_error_set(err,"Couldn't find element after it was added");
          haserr = true;
        }
        break;
    }
  }
  return haserr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, 0x38(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movl %esi, 0x24(%rsp)
movl %edi, %r15d
cmpl $0x2, %edi
jne 0x108b8d
movq 0x334c73(%rip), %rbx    # 0x43d7c0
xorl %eax, %eax
cmpq $0x64, %rax
je 0x108b5e
movq %rax, (%rbx,%rax,8)
incq %rax
jmp 0x108b4f
xorl %r14d, %r14d
pushq $0x64
popq %rbp
cmpq $0x64, %r14
je 0x108b8d
callq 0xb3a58
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edx, %edx
divl %ebp
movq (%rbx,%r14,8), %rax
movq (%rbx,%rdx,8), %rcx
movq %rcx, (%rbx,%r14,8)
movq %rax, (%rbx,%rdx,8)
incq %r14
jmp 0x108b64
movq 0x18(%rsp), %rax
leaq 0x64(%rax), %rcx
movq %rcx, 0x40(%rsp)
leaq (,%rax,8), %rbp
leaq 0x318(,%rax,8), %r14
negq %rbp
pushq $0x63
popq %r13
movq $0x0, 0x28(%rsp)
xorl %r12d, %r12d
movl %r15d, 0x34(%rsp)
cmpq %r12, 0x40(%rsp)
je 0x108d3e
testl %r15d, %r15d
je 0x108be7
cmpl $0x1, %r15d
jne 0x108bf4
movq 0x18(%rsp), %rax
leaq (%rax,%r13), %r15
movq %r13, %rbx
jmp 0x108c0f
movq %r12, %r15
subq 0x18(%rsp), %r15
movq %r12, %rbx
jmp 0x108c0f
cmpq 0x18(%rsp), %r12
movq 0x334bc0(%rip), %rax    # 0x43d7c0
movq %rbp, %rcx
cmovbq %r14, %rcx
movq (%rax,%rcx), %r15
movq (%rax,%r12,8), %rbx
cmpl $0x2, 0x24(%rsp)
jae 0x108ca5
cmpq $0x63, %r12
ja 0x108c88
shlq $0x3, %rbx
movq 0x334b8d(%rip), %rsi    # 0x43d7b8
addq %rbx, %rsi
movq 0x10(%rsp), %rdi
callq 0x10679b
leaq 0x2262a0(%rip), %rsi    # 0x32eedf
testq %rax, %rax
jne 0x108ced
testb $0x1, 0x28(%rsp)
jne 0x108c88
movq 0x334b62(%rip), %rsi    # 0x43d7b8
addq %rbx, %rsi
movq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x106b2f
addq 0x334b49(%rip), %rbx    # 0x43d7b8
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x10679b
leaq 0x226283(%rip), %rsi    # 0x32ef06
testq %rax, %rax
je 0x108ced
cmpl $0x0, 0x24(%rsp)
sete %al
orb 0x28(%rsp), %al
cmpq 0x18(%rsp), %r12
setb %cl
orb %al, %cl
testb $0x1, %cl
je 0x108caa
jmp 0x108d00
jne 0x108d18
movq %rbx, %r15
shlq $0x3, %r15
movq 0x334b03(%rip), %rsi    # 0x43d7b8
addq %r15, %rsi
movq 0x10(%rsp), %rdi
callq 0x10679b
leaq 0x226266(%rip), %rsi    # 0x32ef2f
testq %rax, %rax
je 0x108ced
addq 0x334ae3(%rip), %r15    # 0x43d7b8
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x106ce5
leaq 0x226246(%rip), %rsi    # 0x32ef2f
testl %eax, %eax
je 0x108d00
movq 0x38(%rsp), %rdi
xorl %eax, %eax
callq 0x89dbb
movb $0x1, %al
movq %rax, 0x28(%rsp)
incq %r12
addq $-0x8, %r14
decq %r13
addq $0x8, %rbp
movl 0x34(%rsp), %r15d
jmp 0x108bc3
shlq $0x3, %rbx
addq 0x334a95(%rip), %rbx    # 0x43d7b8
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x10679b
leaq 0x2261cf(%rip), %rsi    # 0x32ef06
testq %rax, %rax
jne 0x108d00
jmp 0x108ced
movq 0x28(%rsp), %rax
andb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq