// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/feature_index.c
// Function: gt_feature_index_unit_test_query
static void* gt_feature_index_unit_test_query(void *data)
{
  GtFeatureIndexTestShared *shm = (GtFeatureIndexTestShared*) data;
  GtRange rng;
  GtError *err = shm->err;
  GtUword i;
  int had_err = 0;
  GtArray *arr, *arr_ref;

  gt_mutex_lock(shm->mutex);
  if (gt_error_is_set(shm->err)) {
    gt_mutex_unlock(shm->mutex);
    return NULL;
  }
  gt_mutex_unlock(shm->mutex);

  arr = gt_array_new(sizeof (GtFeatureNode*));
  arr_ref = gt_array_new(sizeof (GtFeatureNode*));
  rng.start = random() % (GT_FI_TEST_END - GT_FI_TEST_QUERY_WIDTH);
  rng.end = rng.start + random() % (GT_FI_TEST_QUERY_WIDTH);

  /* get reference set by linear search */
  gt_mutex_lock(shm->mutex);
  for (i=0; i<GT_FI_TEST_FEATURES_PER_THREAD * gt_jobs; i++) {
    GtRange rng2;
    GtFeatureNode *fn;
    fn = *(GtFeatureNode**) gt_array_get(shm->nodes, i);
    rng2 = gt_genome_node_get_range((GtGenomeNode*) fn);
    if (gt_range_overlap(&rng, &rng2)) {
      gt_array_add(arr_ref, fn);
    }
  }
  gt_mutex_unlock(shm->mutex);

  /* query feature index */
  gt_feature_index_get_features_for_range(shm->fi, arr, GT_FI_TEST_SEQID, &rng,
                                          err);

  /* result size must be equal */
  if (gt_array_size(arr) != gt_array_size(arr_ref))
    had_err = -1;

  /* nodes must be the same (note that we should not rely on ptr equality) */
  if (!had_err) {
    gt_array_sort(arr_ref, cmp_range_start);
    gt_array_sort(arr    , cmp_range_start);

    for (i=0;i<gt_array_size(arr);i++) {
      if (had_err)
        break;
      if (!gt_feature_node_is_similar(*(GtFeatureNode**) gt_array_get(arr, i),
                                      *(GtFeatureNode**)
                                      gt_array_get(arr_ref, i))) {
        had_err = -1;
      }
    }
  }

  if (had_err) {
    gt_mutex_lock(shm->mutex);
    shm->error_count++;
    gt_mutex_unlock(shm->mutex);
  }

  gt_array_delete(arr);
  gt_array_delete(arr_ref);
  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movq 0x18(%rdi), %rdi
callq 0x16028
movq 0x8(%rbx), %rdi
callq 0xc103
movl %eax, %ebp
movq 0x18(%rbx), %rdi
callq 0x1609f
testb %bpl, %bpl
jne 0x17ab0
movq %r14, 0x8(%rsp)
pushq $0x8
popq %r15
movq %r15, %rdi
callq 0x4b380
movq %rax, %r14
movq %r15, %rdi
callq 0x4b380
movq %rax, (%rsp)
callq 0x166a8
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
andl %r15d, %eax
xorl %ebp, %ebp
movl $0x97d330, %ecx         # imm = 0x97D330
xorl %edx, %edx
divl %ecx
movl %edx, %r13d
leaq 0x28(%rsp), %r12
movq %r13, (%r12)
callq 0x166a8
andl %r15d, %eax
movl $0xc350, %ecx           # imm = 0xC350
xorl %edx, %edx
divl %ecx
addl %r13d, %edx
movq %rdx, 0x8(%r12)
movq 0x18(%rbx), %rdi
callq 0x16028
leaq 0x116d4e(%rip), %r15    # 0x12e6d4
leaq 0x18(%rsp), %r13
imull $0x3e8, (%r15), %eax    # imm = 0x3E8
cmpq %rax, %rbp
jae 0x179df
movq 0x10(%rbx), %rdi
movq %rbp, %rsi
callq 0x4b48e
movq (%rax), %rdi
movq %rdi, 0x10(%rsp)
callq 0x1c3c4
movq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x5d0a4
testb %al, %al
je 0x179da
movq (%rsp), %rdi
leaq 0x10(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x4b801
incq %rbp
jmp 0x1798b
movq 0x18(%rbx), %rdi
callq 0x1609f
movq (%rbx), %rdi
leaq 0xb5c4e(%rip), %rdx     # 0xcd640
leaq 0x28(%rsp), %rcx
movq %r14, %rsi
movq 0x8(%rsp), %r8
callq 0x16e42
movq %r14, %rdi
callq 0x4b988
movq %rax, %r12
movq (%rsp), %rbp
movq %rbp, %rdi
callq 0x4b988
cmpq %rax, %r12
jne 0x17a8a
leaq 0x9a(%rip), %r12        # 0x17ac1
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4ba94
movq %r14, %rdi
movq %r12, %rsi
callq 0x4ba94
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x4b988
testl %r15d, %r15d
jne 0x17a85
cmpq %rax, %r12
jae 0x17a85
movq %r14, %rdi
movq %r12, %rsi
callq 0x4b48e
movq (%rax), %r13
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4b48e
movq (%rax), %rsi
movq %r13, %rdi
callq 0x1aa25
movzbl %al, %r15d
decl %r15d
incq %r12
jmp 0x17a43
testl %r15d, %r15d
je 0x17aa0
movq 0x18(%rbx), %rdi
callq 0x16028
incq 0x28(%rbx)
movq 0x18(%rbx), %rdi
callq 0x1609f
movq %r14, %rdi
callq 0x4c19d
movq %rbp, %rdi
callq 0x4c19d
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq