// File: /workspace/github_c_makefile_star2_O3/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 0x3d043
movq 0x8(%rbx), %rdi
callq 0x34fea
movl %eax, %ebp
movq 0x18(%rbx), %rdi
callq 0x3d05e
testb %bpl, %bpl
jne 0x3e4ba
movq %r14, 0x8(%rsp)
movl $0x8, %edi
callq 0x6ef7c
movq %rax, %r14
movl $0x8, %edi
callq 0x6ef7c
movq %rax, (%rsp)
callq 0x3d424
movl %eax, %r12d
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
andl %ebp, %r12d
imulq $0x6be9eb99, %r12, %rax # imm = 0x6BE9EB99
shrq $0x36, %rax
imull $0x97d330, %eax, %eax   # imm = 0x97D330
subl %eax, %r12d
movq %r12, 0x18(%rsp)
callq 0x3d424
andl %ebp, %eax
imulq $0x14f8b589, %rax, %rcx # imm = 0x14F8B589
shrq $0x2c, %rcx
imull $0xc350, %ecx, %ecx     # imm = 0xC350
subl %ecx, %eax
addl %r12d, %eax
movq %rax, 0x20(%rsp)
movq 0x18(%rbx), %rdi
callq 0x3d043
leaq 0x113371(%rip), %r15    # 0x1516e4
imull $0x3e8, (%r15), %eax    # imm = 0x3E8
testl %eax, %eax
je 0x3e3df
xorl %r13d, %r13d
leaq 0x18(%rsp), %rbp
leaq 0x28(%rsp), %r12
movq 0x10(%rbx), %rdi
movq %r13, %rsi
callq 0x6f037
movq (%rax), %rdi
movq %rdi, 0x10(%rsp)
callq 0x415e5
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x7e1b2
testb %al, %al
je 0x3e3d0
movl $0x8, %edx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x6f240
incq %r13
imull $0x3e8, (%r15), %eax    # imm = 0x3E8
cmpq %rax, %r13
jb 0x3e38b
movq 0x18(%rbx), %rdi
callq 0x3d05e
movq (%rbx), %rdi
leaq 0xa624e(%rip), %rdx     # 0xe4640
leaq 0x18(%rsp), %rcx
movq %r14, %rsi
movq 0x8(%rsp), %r8
callq 0x3da20
movq %r14, %rdi
callq 0x6f310
movq %rax, %r12
movq (%rsp), %rdi
callq 0x6f310
cmpq %rax, %r12
jne 0x3e493
leaq 0xa7(%rip), %r12        # 0x3e4cb
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x6f35d
movq %r14, %rdi
movq %r12, %rsi
callq 0x6f35d
movq %r14, %rdi
callq 0x6f310
testq %rax, %rax
je 0x3e4a9
movl $0x1, %r15d
leaq -0x1(%r15), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x6f037
movq (%rax), %r13
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x6f037
movq (%rax), %rsi
movq %r13, %rdi
callq 0x40562
movl %eax, %ebp
movq %r14, %rdi
callq 0x6f310
cmpq %rax, %r15
jae 0x3e48e
incq %r15
testb %bpl, %bpl
jne 0x3e44e
testb %bpl, %bpl
jne 0x3e4a9
movq 0x18(%rbx), %rdi
callq 0x3d043
incq 0x28(%rbx)
movq 0x18(%rbx), %rdi
callq 0x3d05e
movq %r14, %rdi
callq 0x6f768
movq (%rsp), %rdi
callq 0x6f768
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq