// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/interval_tree.c
// Function: gt_interval_tree_remove
void gt_interval_tree_remove(GtIntervalTree *it, GtIntervalTreeNode *z)
{
  GtIntervalTreeNode *y, *x;
  gt_assert(it && it->size > 0);
  y = (z->left == it->nil || z->right == it->nil)
    ? z
    : gt_interval_tree_get_successor(it, z);
  x = (y->left != it->nil) ? y->left : y->right;
  gt_assert(y);

  x->parent = y->parent;

  if (y->parent == it->nil) {
    it->root = x;
  } else {
    if (y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if (y != z) {
    z->max = y->max;
    z->low = y->low;
    z->high = y->high;
    z->data = y->data;
  }
  interval_tree_max_fixup(it, it->root, z->parent);
  if (y->color == BLACK) {
    y->color = z->color;
    interval_tree_delete_fixup(it, x);
  }
  if (y != it->nil)
    gt_interval_tree_node_delete(it, y);
  it->size--;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x583ae
movq %rdi, %rbx
cmpq $0x0, 0x50(%rdi)
je 0x583ae
movq %rsi, %r15
movq 0x8(%rsi), %r12
movq 0x48(%rbx), %r13
movq %rsi, %r14
cmpq %r13, %r12
je 0x581a9
cmpq %r13, 0x10(%r15)
je 0x581a9
movq %rbx, %rdi
movq %r15, %rsi
callq 0x58131
movq %rax, %r14
movq 0x8(%rax), %r12
cmpq %r13, %r12
jne 0x581b2
movq 0x10(%r14), %r12
movq (%r14), %rcx
movq %rcx, (%r12)
movq %rbx, %rax
cmpq %r13, %rcx
je 0x581d1
leaq 0x8(%rcx), %rdx
leaq 0x10(%rcx), %rax
cmpq 0x8(%rcx), %r14
cmoveq %rdx, %rax
movq %r12, (%rax)
cmpq %r15, %r14
je 0x581f3
movq 0x38(%r14), %rax
movq %rax, 0x38(%r15)
movups 0x28(%r14), %xmm0
movups %xmm0, 0x28(%r15)
movq 0x18(%r14), %rax
movq %rax, 0x18(%r15)
movq (%rbx), %rax
movq %r15, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0x58238
cmpq %r13, %rcx
je 0x58238
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %rsi
cmpq %r13, %rdx
je 0x58229
movq 0x38(%rdx), %rdx
cmpq %r13, %rsi
je 0x58232
movq 0x38(%rsi), %rsi
cmpq %rsi, %rdx
cmovbeq %rsi, %rdx
jmp 0x58232
cmpq %r13, %rsi
je 0x581f9
movq 0x38(%rsi), %rdx
movq %rdx, 0x38(%rcx)
jmp 0x581f9
cmpl $0x0, 0x20(%r14)
jne 0x58390
movl 0x20(%r15), %eax
movl %eax, 0x20(%r14)
cmpl $0x0, 0x20(%r12)
jne 0x58386
cmpq %r12, (%rbx)
je 0x58386
movq (%r12), %rdx
movq 0x8(%rdx), %rax
cmpq %rax, %r12
je 0x582d8
cmpl $0x1, 0x20(%rax)
jne 0x58291
andl $0x0, 0x20(%rax)
movl $0x1, 0x20(%rdx)
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x58bf6
movq (%r12), %rdx
movq 0x8(%rdx), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rsi
cmpl $0x0, 0x20(%rsi)
movl 0x20(%rcx), %edi
je 0x58354
testl %edi, %edi
jne 0x58358
andl $0x0, 0x20(%rsi)
movl $0x1, 0x20(%rax)
movq %rbx, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x58b48
movq (%r12), %rdx
movq 0x8(%rdx), %rax
movq 0x8(%rax), %rcx
jmp 0x58358
movq 0x10(%rdx), %rax
cmpl $0x1, 0x20(%rax)
jne 0x58300
andl $0x0, 0x20(%rax)
movl $0x1, 0x20(%rdx)
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x58b48
movq (%r12), %rdx
movq 0x10(%rdx), %rax
movq 0x10(%rax), %rcx
cmpl $0x0, 0x20(%rcx)
jne 0x58339
movq 0x8(%rax), %rcx
cmpl $0x0, 0x20(%rcx)
je 0x5837d
andl $0x0, 0x20(%rcx)
movl $0x1, 0x20(%rax)
movq %rbx, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x58bf6
movq (%r12), %rdx
movq 0x10(%rdx), %rax
movq 0x10(%rax), %rcx
movl 0x20(%rdx), %esi
movl %esi, 0x20(%rax)
andl $0x0, 0x20(%rdx)
andl $0x0, 0x20(%rcx)
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x58b48
jmp 0x58371
testl %edi, %edi
je 0x5837d
movl 0x20(%rdx), %esi
movl %esi, 0x20(%rax)
andl $0x0, 0x20(%rdx)
andl $0x0, 0x20(%rcx)
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x58bf6
movq %rbx, %r12
movq (%r12), %r12
jmp 0x5824b
movl $0x1, 0x20(%rax)
jmp 0x58374
andl $0x0, 0x20(%r12)
movq 0x48(%rbx), %r13
cmpq %r13, %r14
je 0x583a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x57ca1
decq 0x50(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0xd5c03(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x71ca7(%rip), %rsi     # 0xca066
leaq 0x8236b(%rip), %rdx     # 0xda731
leaq 0x82377(%rip), %rcx     # 0xda744
leaq 0x82249(%rip), %r8      # 0xda61d
movl $0x1d5, %r9d            # imm = 0x1D5
xorl %eax, %eax
callq 0xb8c0
callq 0xb300