// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movl %edi, 0x54(%rsp)
movl %esi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movq %r8, 0x38(%rsp)
movb $0x0, 0x2e(%rsp)
cmpl $0x2, 0x54(%rsp)
jne 0x1bbbb9
movq $0x0, 0x30(%rsp)
cmpq $0x64, 0x30(%rsp)
jae 0x1bbbad
movq 0x30(%rsp), %rdx
movq 0x4872dc(%rip), %rax    # 0x642e70
movq 0x30(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x1bbb80
movq 0x4872bc(%rip), %rdi    # 0x642e70
callq 0x1bc0e0
movq $0x0, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
addq $0x64, %rcx
cmpq %rcx, %rax
jae 0x1bbe85
movl 0x54(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0x1bbc6b
jmp 0x1bbbeb
movl 0xc(%rsp), %eax
subl $0x1, %eax
je 0x1bbc86
jmp 0x1bbbfa
movl 0xc(%rsp), %eax
subl $0x2, %eax
jne 0x1bbcb3
jmp 0x1bbc09
movq 0x30(%rsp), %rax
cmpq 0x40(%rsp), %rax
jb 0x1bbc31
movq 0x487254(%rip), %rax    # 0x642e70
movq 0x30(%rsp), %rcx
subq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
jmp 0x1bbc54
movq 0x487238(%rip), %rax    # 0x642e70
movl $0x64, %ecx
subq 0x30(%rsp), %rcx
subq $0x1, %rcx
addq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movq 0x487215(%rip), %rax    # 0x642e70
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
jmp 0x1bbcb8
movq 0x30(%rsp), %rax
subq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x1bbcb8
movl $0x64, %eax
subq 0x30(%rsp), %rax
subq $0x1, %rax
addq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movl $0x64, %eax
subq 0x30(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x1bbcb8
callq 0x19370
movl 0x50(%rsp), %eax
movl %eax, 0x8(%rsp)
subl $0x2, %eax
jb 0x1bbce8
jmp 0x1bbcc7
movl 0x8(%rsp), %eax
subl $0x2, %eax
je 0x1bbdcd
jmp 0x1bbcd6
movl 0x8(%rsp), %eax
subl $0x3, %eax
je 0x1bbe33
jmp 0x1bbe70
cmpq $0x64, 0x30(%rsp)
jae 0x1bbda4
movq 0x48(%rsp), %rdi
movq 0x487168(%rip), %rsi    # 0x642e68
movq 0x18(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x1b8210
cmpq $0x0, %rax
je 0x1bbd2f
movq 0x38(%rsp), %rdi
leaq 0x3a562c(%rip), %rsi    # 0x56134f
movb $0x0, %al
callq 0xd88c0
movb $0x1, 0x2e(%rsp)
testb $0x1, 0x2e(%rsp)
jne 0x1bbda2
movq 0x48(%rsp), %rdi
movq 0x487126(%rip), %rsi    # 0x642e68
movq 0x18(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
leaq 0x2f(%rsp), %rdx
callq 0x1b8790
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x1bbd88
movq 0x48(%rsp), %rdi
movq 0x4870f7(%rip), %rsi    # 0x642e68
movq 0x18(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x1b8210
cmpq $0x0, %rax
jne 0x1bbda0
movq 0x38(%rsp), %rdi
leaq 0x3a55e2(%rip), %rsi    # 0x561376
movb $0x0, %al
callq 0xd88c0
movb $0x1, 0x2e(%rsp)
jmp 0x1bbda2
jmp 0x1bbda4
testb $0x1, 0x2e(%rsp)
jne 0x1bbdbe
cmpl $0x0, 0x50(%rsp)
je 0x1bbdbe
movq 0x30(%rsp), %rax
cmpq 0x40(%rsp), %rax
jae 0x1bbdc3
jmp 0x1bbe70
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rdi
movq 0x48708f(%rip), %rsi    # 0x642e68
movq 0x18(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x1b8210
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x1bbe19
movq 0x48(%rsp), %rdi
movq 0x487065(%rip), %rsi    # 0x642e68
movq 0x18(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x1b89f0
cmpl $0x0, %eax
je 0x1bbe31
movq 0x38(%rsp), %rdi
leaq 0x3a557a(%rip), %rsi    # 0x56139f
movb $0x0, %al
callq 0xd88c0
movb $0x1, 0x2e(%rsp)
jmp 0x1bbe70
movq 0x48(%rsp), %rdi
movq 0x487029(%rip), %rsi    # 0x642e68
movq 0x18(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x1b8210
cmpq $0x0, %rax
jne 0x1bbe6e
movq 0x38(%rsp), %rdi
leaq 0x3a5514(%rip), %rsi    # 0x561376
movb $0x0, %al
callq 0xd88c0
movb $0x1, 0x2e(%rsp)
jmp 0x1bbe70
jmp 0x1bbe72
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x1bbbc2
movb 0x2e(%rsp), %al
andb $0x1, %al
addq $0x58, %rsp
retq