// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/core/interval_tree.c
// Function: gt_interval_tree_unit_test
int gt_interval_tree_unit_test(GT_UNUSED GtError *err)
{
  GtIntervalTree *it = NULL;
  GtIntervalTreeNode *res = NULL;
  GtUword i = 0;
  int had_err = 0, num_testranges = 3000,
      num_samples = 300000, num_find_all_samples = 10000,
      gt_range_max_basepos = 90000, width = 700,
      query_width = 5000;
  GtRange *res_rng = NULL, qrange;
  GtArray *arr = NULL, *narr = NULL;

  arr = gt_array_new(sizeof (GtRange*));

  /* generate test ranges */
  for (i = 0;i<num_testranges;i++)
  {
    GtUword start;
    GtRange *rng;
    rng  = gt_calloc(1, sizeof (GtRange));
    start = gt_rand_max(gt_range_max_basepos);
    rng->start = start;
    rng->end = start + gt_rand_max(width);
    gt_array_add(arr, rng);
  }

  it = gt_interval_tree_new(gt_free_func);

  /* insert ranges */
  for (i = 0; i < num_testranges && !had_err; i++)
  {
    GtIntervalTreeNode *new_node;
    GtRange *rng;
    rng = *(GtRange**) gt_array_get(arr, i);
    new_node = gt_interval_tree_node_new(rng, rng->start, rng->end);
    gt_interval_tree_insert(it, new_node);
  }
  gt_ensure(gt_interval_tree_size(it) == num_testranges);

  /* perform test queries */
  for (i = 0; i < num_samples && !had_err; i++)
  {
    GtUword start = gt_rand_max(gt_range_max_basepos);
    qrange.start = start;
    qrange.end = start + gt_rand_max(width);
    res = gt_interval_tree_find_first_overlapping(it, qrange.start, qrange.end);
    if (res)
    {
      /* we have a hit, check if really overlapping */
      res_rng = (GtRange*) gt_interval_tree_node_get_data(res);
      gt_ensure(gt_range_overlap(&qrange, res_rng));
    } else {
      /* no hit, check whether there really is no overlapping
         interval in tree */
      GtRange *this_rng;
      GtUword j;
      bool found = false;
      for (j = 0; j < gt_array_size(arr); j++)
      {
        this_rng = *(GtRange**) gt_array_get(arr, j);
        if (gt_range_overlap(this_rng, &qrange))
        {
          found = true;
          break;
        }
      }
      gt_ensure(!found);
    }
  }

  /* test searching for all overlapping intervals */
  for (i = 0; i < num_find_all_samples && !had_err; i++)
  {
    GtUword start = gt_rand_max(gt_range_max_basepos);
    qrange.start = start;
    qrange.end = start + gt_rand_max(query_width);
    GtArray *res = gt_array_new(sizeof (GtRange*));
    gt_interval_tree_find_all_overlapping(it, qrange.start, qrange.end, res);
    if (res)
    {
      /* generate reference overlapping interval list by linear search */
      GtArray *ref;
      GtUword j;
      ref = gt_array_new(sizeof (GtRange*));
      for (j = 0; j < gt_array_size(arr); j++)
      {
        GtRange *this_rng;
        this_rng = *(GtRange**) gt_array_get(arr, j);
        if (gt_range_overlap(this_rng, &qrange))
        {
          gt_array_add(ref, this_rng);
        }
      }
      /* compare reference with interval tree query result */
      gt_array_sort_stable(ref, range_ptr_compare);
      gt_array_sort_stable(res, range_ptr_compare);
      /* must be equal */
      gt_ensure(gt_array_cmp(ref, res)==0);
      gt_array_delete(ref);
    }
    gt_array_delete(res);
  }
  gt_interval_tree_delete(it);

  it = gt_interval_tree_new(NULL);
  gt_array_reset(arr);

  /* generate test ranges */
  for (i = 0;i<num_testranges && !had_err;i++)
  {
    GtUword start;
    GtIntervalTreeNode *new_node;
    start = gt_rand_max(gt_range_max_basepos);
    new_node = gt_interval_tree_node_new((void*) i, start,
                                          start + gt_rand_max(width));
    gt_interval_tree_insert(it, new_node);
  }
  gt_ensure(gt_interval_tree_size(it) == num_testranges);

  narr = gt_array_new(sizeof (GtIntervalTreeNode*));
  for (i = 0; i < num_testranges && !had_err; i++) {
    GtUword idx, n, val;
    GtIntervalTreeNode *node = NULL;

    /* get all nodes referenced by the interval tree */
    interval_tree_find_all_internal(it, it->root, itree_test_get_node, 0,
                                    gt_range_max_basepos+width, narr);

    /* remove a random node */
    idx = gt_rand_max(gt_array_size(narr)-1);
    node = *(GtIntervalTreeNode**) gt_array_get(narr, idx);
    gt_ensure(node != NULL);
    val = (GtUword) gt_interval_tree_node_get_data(node);
    gt_interval_tree_remove(it, node);
    gt_array_reset(narr);

    /* make sure that the node has disappeared */
    gt_ensure(gt_interval_tree_size(it) == num_testranges - (i+1));
    interval_tree_find_all_internal(it, it->root, itree_test_get_node, 0,
                                    gt_range_max_basepos+width, narr);
    gt_ensure(gt_array_size(narr) == num_testranges - (i+1));
    for (n = 0; !had_err && n < gt_array_size(narr); n++) {
      GtIntervalTreeNode *onode = *(GtIntervalTreeNode**) gt_array_get(narr, n);
      gt_ensure((GtUword) gt_interval_tree_node_get_data(onode)
                           != val);
    }
  }

  gt_array_delete(arr);
  gt_array_delete(narr);
  gt_interval_tree_delete(it);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, 0x8(%rsp)
movl $0x8, %edi
callq 0x6e93c
movq %rax, %rbx
movl $0xbb8, %r13d           # imm = 0xBB8
leaq 0x780ee(%rip), %r14     # 0xf16bd
leaq 0x10(%rsp), %r15
movl $0x1, %edi
movl $0x10, %esi
movq %r14, %rdx
movl $0x234, %ecx            # imm = 0x234
callq 0x3601f
movq %rax, 0x10(%rsp)
movl $0x15f90, %edi          # imm = 0x15F90
callq 0x7a188
movq %rax, %r12
movq 0x10(%rsp), %rax
movq %r12, (%rax)
movl $0x2bc, %edi            # imm = 0x2BC
callq 0x7a188
addq %r12, %rax
movq 0x10(%rsp), %rcx
movq %rax, 0x8(%rcx)
movl $0x8, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6ec0e
decq %r13
jne 0x795d4
leaq 0x78086(%rip), %r14     # 0xf16bd
movl $0x1, %edi
movl $0x60, %esi
movq %r14, %rdx
movl $0x3e, %ecx
callq 0x3601f
movq %rax, %r13
leaq -0x432f9(%rip), %rax    # 0x3635f
movq %rax, 0x58(%r13)
leaq 0x8(%r13), %rax
movq %rax, 0x48(%r13)
movq %rax, (%r13)
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6e9fa
movq (%rax), %r12
movups (%r12), %xmm0
movaps %xmm0, 0x20(%rsp)
movl $0x1, %edi
movl $0x40, %esi
movq %r14, %rdx
movl $0x34, %ecx
callq 0x3601f
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0x28(%rax)
movq %r12, 0x18(%rax)
movq %r13, %rdi
movq %rax, %rsi
callq 0x7904d
incq %r15
cmpq $0xbb8, %r15            # imm = 0xBB8
jne 0x7966b
movq %r13, %rdi
callq 0x78e53
movq %rax, %r14
xorl %r15d, %r15d
cmpq $0xbb8, %rax            # imm = 0xBB8
je 0x79708
leaq 0x69a9e(%rip), %rsi     # 0xe3179
leaq 0x78131(%rip), %rdx     # 0xf1813
leaq 0x78156(%rip), %rcx     # 0xf183f
leaq 0x77fcd(%rip), %r8      # 0xf16bd
movq 0x8(%rsp), %rdi
movl $0x246, %r9d            # imm = 0x246
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq $0xbb8, %r14            # imm = 0xBB8
movq %r13, 0x20(%rsp)
jne 0x79882
xorl %r12d, %r12d
leaq 0x10(%rsp), %r14
movl $0x15f90, %edi          # imm = 0x15F90
callq 0x7a188
movq %rax, %r15
movq %rax, 0x10(%rsp)
movl $0x2bc, %edi            # imm = 0x2BC
callq 0x7a188
addq %rax, %r15
movq %r15, 0x18(%rsp)
movq 0x10(%rsp), %rsi
movq %r13, %rdi
movq %r15, %rdx
callq 0x78eaa
testq %rax, %rax
je 0x7977a
movq 0x18(%rax), %rsi
movq %r14, %rdi
callq 0x7e06e
testb %al, %al
je 0x79821
xorl %r15d, %r15d
movb $0x1, %bpl
jmp 0x79868
movq %rbx, %rdi
callq 0x6ecda
xorl %r15d, %r15d
movb $0x1, %bpl
testq %rax, %rax
setne %r13b
je 0x79859
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6e9fa
movq (%rax), %rdi
movq %r14, %rsi
callq 0x7e06e
testb %al, %al
jne 0x797e6
movl $0x1, %r15d
movq %rbx, %rdi
callq 0x6ecda
cmpq %rax, %r15
setb %r13b
jae 0x79860
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6e9fa
movq (%rax), %rdi
movq %r14, %rsi
callq 0x7e06e
incq %r15
testb %al, %al
je 0x797b4
testb %r13b, %r13b
movq 0x20(%rsp), %r13
movl $0x0, %r15d
je 0x79868
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
leaq 0x69975(%rip), %rsi     # 0xe3179
leaq 0x78072(%rip), %rdx     # 0xf187d
leaq 0x7802d(%rip), %rcx     # 0xf183f
leaq 0x77ea4(%rip), %r8      # 0xf16bd
movl $0x263, %r9d            # imm = 0x263
jmp 0x7984a
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
leaq 0x6994a(%rip), %rsi     # 0xe3179
leaq 0x78024(%rip), %rdx     # 0xf185a
leaq 0x78002(%rip), %rcx     # 0xf183f
leaq 0x77e79(%rip), %r8      # 0xf16bd
movl $0x253, %r9d            # imm = 0x253
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x79868
movq 0x20(%rsp), %r13
jmp 0x79868
movq 0x20(%rsp), %r13
xorl %r15d, %r15d
testb %bpl, %bpl
je 0x79882
leaq 0x1(%r12), %rax
cmpq $0x493df, %r12          # imm = 0x493DF
movq %rax, %r12
jb 0x79722
testl %r15d, %r15d
sete %r14b
jne 0x799d6
leaq 0x10(%rsp), %r13
xorl %ebp, %ebp
movl $0x15f90, %edi          # imm = 0x15F90
callq 0x7a188
movq %rax, %r14
movq %rax, 0x10(%rsp)
movl $0x1388, %edi           # imm = 0x1388
callq 0x7a188
addq %r14, %rax
movq %rax, 0x18(%rsp)
movl $0x8, %edi
callq 0x6e93c
movq %rax, %r12
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rdi
movq %rax, %rcx
callq 0x78f5f
testq %r12, %r12
je 0x799b2
movl $0x8, %edi
callq 0x6e93c
movq %rax, %r14
movq %rbx, %rdi
callq 0x6ecda
testq %rax, %rax
je 0x79945
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6e9fa
movq (%rax), %rdi
movq %rdi, 0x40(%rsp)
movq %r13, %rsi
callq 0x7e06e
testb %al, %al
je 0x79935
movl $0x8, %edx
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq 0x6ec0e
incq %r15
movq %rbx, %rdi
callq 0x6ecda
cmpq %rax, %r15
jb 0x79904
movq %r14, %rdi
leaq 0x3e6(%rip), %r15       # 0x79d35
movq %r15, %rsi
callq 0x6ed4d
movq %r12, %rdi
movq %r15, %rsi
callq 0x6ed4d
movq %r14, %rdi
movq %r12, %rsi
callq 0x6edc5
testl %eax, %eax
je 0x799a7
movq 0x8(%rsp), %rdi
leaq 0x697fc(%rip), %rsi     # 0xe3179
leaq 0x77f00(%rip), %rdx     # 0xf1884
leaq 0x77eb4(%rip), %rcx     # 0xf183f
leaq 0x77d2b(%rip), %r8      # 0xf16bd
movl $0x282, %r9d            # imm = 0x282
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x799aa
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x6f134
movq %r12, %rdi
callq 0x6f134
testl %r15d, %r15d
sete %r14b
cmpq $0x270e, %rbp           # imm = 0x270E
ja 0x799d6
incq %rbp
testl %r15d, %r15d
je 0x79896
movq 0x20(%rsp), %rdi
callq 0x791e5
leaq 0x77cd6(%rip), %rdx     # 0xf16bd
movl $0x1, %edi
movl $0x60, %esi
movl $0x3e, %ecx
callq 0x3601f
movq $0x0, 0x58(%rax)
leaq 0x8(%rax), %rcx
movq %rcx, 0x48(%rax)
movq %rax, 0x38(%rsp)
movq %rcx, (%rax)
movq %rbx, %rdi
callq 0x6ed13
testb %r14b, %r14b
je 0x79adc
xorl %ebp, %ebp
movq 0x38(%rsp), %r13
movl $0x15f90, %edi          # imm = 0x15F90
callq 0x7a188
movq %rax, %r15
movl $0x2bc, %edi            # imm = 0x2BC
callq 0x7a188
movq %rax, %r12
addq %r15, %r12
movl $0x1, %edi
movl $0x40, %esi
leaq 0x77c64(%rip), %rdx     # 0xf16bd
movl $0x34, %ecx
callq 0x3601f
movq %r15, 0x28(%rax)
movq %r12, 0x30(%rax)
movq %rbp, 0x18(%rax)
movq %r13, %rdi
movq %rax, %rsi
callq 0x7904d
cmpq $0xbb7, %rbp            # imm = 0xBB7
leaq 0x1(%rbp), %rbp
setb %al
testb %r14b, %al
jne 0x79a2b
xorl %r13d, %r13d
testb %r14b, %r14b
je 0x79adc
movq 0x38(%rsp), %rdi
callq 0x78e53
movb $0x1, %bpl
cmpq $0xbb8, %rax            # imm = 0xBB8
je 0x79ae4
leaq 0x696c8(%rip), %rsi     # 0xe3179
leaq 0x77d5b(%rip), %rdx     # 0xf1813
leaq 0x77d80(%rip), %rcx     # 0xf183f
leaq 0x77bf7(%rip), %r8      # 0xf16bd
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
movl $0x296, %r9d            # imm = 0x296
xorl %eax, %eax
callq 0x3559f
jmp 0x79ade
xorl %ebp, %ebp
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x8, %edi
callq 0x6e93c
movq %rax, %r12
testb %bpl, %bpl
je 0x79d09
movq $0x0, 0x20(%rsp)
movq 0x38(%rsp), %r13
movq (%r13), %rsi
movl $0x1624c, %r8d          # imm = 0x1624C
movq %r13, %rdi
leaq 0x25e(%rip), %rdx       # 0x79d7a
xorl %ecx, %ecx
movq %r12, %r9
callq 0x78f90
movq %r12, %rdi
callq 0x6ecda
leaq -0x1(%rax), %rdi
callq 0x7a188
movq %r12, %rdi
movq %rax, %rsi
callq 0x6e9fa
movq (%rax), %r14
testq %r14, %r14
jne 0x79b78
movq 0x8(%rsp), %rdi
leaq 0x69623(%rip), %rsi     # 0xe3179
leaq 0x77d41(%rip), %rdx     # 0xf189e
leaq 0x77cdb(%rip), %rcx     # 0xf183f
leaq 0x77b52(%rip), %r8      # 0xf16bd
movl $0x2a4, %r9d            # imm = 0x2A4
xorl %eax, %eax
callq 0x3559f
movq %r14, %rdi
callq 0x78e63
movq %rax, %rbp
movq %r13, %rdi
movq %r14, %rsi
callq 0x79271
movq %r12, %rdi
callq 0x6ed13
testq %r14, %r14
je 0x79c46
movl $0xbb7, %r15d           # imm = 0xBB7
subq 0x20(%rsp), %r15
cmpq %r15, 0x50(%r13)
jne 0x79c18
movq (%r13), %rsi
movq %r13, %rdi
xorl %r13d, %r13d
movl $0x1624c, %r8d          # imm = 0x1624C
leaq 0x1b3(%rip), %rdx       # 0x79d7a
xorl %ecx, %ecx
movq %r12, %r9
callq 0x78f90
movq %r12, %rdi
callq 0x6ecda
movb $0x1, %r14b
cmpq %r15, %rax
je 0x79c6d
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
leaq 0x69585(%rip), %rsi     # 0xe3179
leaq 0x77ce4(%rip), %rdx     # 0xf18df
leaq 0x77c3d(%rip), %rcx     # 0xf183f
leaq 0x77ab4(%rip), %r8      # 0xf16bd
movl $0x2ad, %r9d            # imm = 0x2AD
xorl %eax, %eax
callq 0x3559f
jmp 0x79c67
movq 0x8(%rsp), %rdi
leaq 0x69555(%rip), %rsi     # 0xe3179
leaq 0x77c80(%rip), %rdx     # 0xf18ab
leaq 0x77c0d(%rip), %rcx     # 0xf183f
leaq 0x77a84(%rip), %r8      # 0xf16bd
movl $0x2aa, %r9d            # imm = 0x2AA
xorl %eax, %eax
callq 0x3559f
movq (%r13), %rsi
xorl %r14d, %r14d
movl $0x1624c, %r8d          # imm = 0x1624C
movq %r13, %rdi
leaq 0x11d(%rip), %rdx       # 0x79d7a
xorl %ecx, %ecx
movq %r12, %r9
callq 0x78f90
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %r14b, %r14b
je 0x79ce9
movq %r12, %rdi
callq 0x6ecda
testq %rax, %rax
je 0x79ce9
xorl %r14d, %r14d
movq %r12, %rdi
movq %r14, %rsi
callq 0x6e9fa
movq (%rax), %rdi
callq 0x78e63
movq %rax, %r15
xorl %r13d, %r13d
cmpq %rbp, %rax
jne 0x79cd4
movq 0x8(%rsp), %rdi
leaq 0x694cd(%rip), %rsi     # 0xe3179
leaq 0x77c5a(%rip), %rdx     # 0xf190d
leaq 0x77b85(%rip), %rcx     # 0xf183f
leaq 0x779fc(%rip), %r8      # 0xf16bd
movl $0x2b1, %r9d            # imm = 0x2B1
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpq %rbp, %r15
je 0x79ce9
incq %r14
movq %r12, %rdi
callq 0x6ecda
cmpq %rax, %r14
jb 0x79c82
testl %r13d, %r13d
jne 0x79d09
movq 0x20(%rsp), %rcx
leaq 0x1(%rcx), %rax
cmpq $0xbb7, %rcx            # imm = 0xBB7
movq %rax, 0x20(%rsp)
jb 0x79b03
movq %rbx, %rdi
callq 0x6f134
movq %r12, %rdi
callq 0x6f134
movq 0x38(%rsp), %rdi
callq 0x791e5
movl %r13d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq