// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/bioseq_col.c
// Function: grep_desc
static int grep_desc(GtBioseqCol *bsc, GtUword *filenum,
                     GtUword *seqnum, GtStr *seqid, GtError *err)
{
  GtUword i, j, num_matches = 0;
  const GtSeqInfo *seq_info_ptr;
  GtSeqInfo seq_info;
  GtStr *pattern, *escaped;
  bool match = false;
  int had_err = 0;
  gt_error_check(err);
  gt_assert(bsc && filenum && seqnum && seqid);
  /* create cache */
  if (!bsc->grep_cache)
    bsc->grep_cache = gt_seq_info_cache_new();
  /* try to read from cache */
  seq_info_ptr = gt_seq_info_cache_get(bsc->grep_cache, gt_str_get(seqid));
  if (seq_info_ptr) {
    if (bsc->duplicates && gt_hashmap_get(bsc->duplicates, gt_str_get(seqid))) {
      gt_error_set(err, "query seqid '%s' could match more than one "
                        "sequence description", gt_str_get(seqid));
      return -1;
    }
    *filenum = seq_info_ptr->filenum;
    *seqnum = seq_info_ptr->seqnum;
    return 0;
  }
  pattern = gt_str_new();
  escaped = gt_str_new();
  gt_grep_escape_extended(escaped, gt_str_get(seqid), gt_str_length(seqid));
  if (bsc->matchdescstart)
    gt_str_append_cstr(pattern, "^");
  gt_str_append_str(pattern, escaped);
  if (bsc->matchdescstart)
    gt_str_append_cstr(pattern, "([[:space:]]|$)");
  for (i = 0; !had_err && i < bsc->num_of_seqfiles; i++) {
    GtBioseq *bioseq = bsc->bioseqs[i];
    for (j = 0; !had_err && j < gt_bioseq_number_of_sequences(bioseq); j++) {
      const char *desc = gt_bioseq_get_description(bioseq, j);
      had_err = gt_grep(&match, gt_str_get(pattern), desc, err);
      if (!had_err && match) {
        num_matches++;
        if (num_matches > 1) {
          gt_error_set(err, "query seqid '%s' could match more than one "
                            "sequence description", gt_str_get(seqid));
          had_err = -1;
          break;
        }
        *filenum = i;
        *seqnum = j;
        /* cache results */
        seq_info.filenum = i;
        seq_info.seqnum = j;
        gt_seq_info_cache_add(bsc->grep_cache, gt_str_get(seqid), &seq_info);
      }
    }
    if (match)
      break;
  }
  gt_str_delete(pattern);
  gt_str_delete(escaped);
  if (!had_err && num_matches == 0) {
    gt_error_set(err, "no description matched sequence ID '%s'",
                 gt_str_get(seqid));
    had_err = -1;
  }
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %rbp
movq %rcx, %rbx
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r12
movb $0x0, 0x7(%rsp)
testq %r8, %r8
je 0xbd4b0
movq %rbp, %rdi
callq 0x34fea
testb %al, %al
jne 0xbd743
cmpq $0x0, 0x10(%rsp)
je 0xbd73e
cmpq $0x0, 0x18(%rsp)
je 0xbd73e
movq 0x18(%r12), %r14
testq %r14, %r14
jne 0xbd4df
callq 0xd8380
movq %rax, %r14
movq %rax, 0x18(%r12)
movq %rbx, %rdi
callq 0x3bb5d
movq %r14, %rdi
movq %rax, %rsi
callq 0xd83dd
testq %rax, %rax
je 0xbd54e
movq %rax, %r14
movq 0x20(%r12), %r15
testq %r15, %r15
je 0xbd530
movq %rbx, %rdi
callq 0x3bb5d
movq %r15, %rdi
movq %rax, %rsi
callq 0x775ed
testq %rax, %rax
je 0xbd530
movq %rbx, %rdi
callq 0x3bb5d
leaq 0x446f3(%rip), %rsi     # 0x101c1e
jmp 0xbd71d
movq (%r14), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
xorl %eax, %eax
jmp 0xbd72f
callq 0x3b728
movq %rax, %r15
callq 0x3b728
movq %rax, %r13
movq %rbx, %rdi
callq 0x3bb5d
movq %rax, %r14
movq %rbx, %rdi
callq 0x3bb86
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x76800
cmpb $0x1, 0x28(%r12)
jne 0xbd596
leaq 0x446d0(%rip), %rsi     # 0x101c5e
movq %r15, %rdi
callq 0x3b7af
movq %rbx, 0x8(%rsp)
movq %rbp, 0x20(%rsp)
movq %r15, %rdi
movq %r13, 0x30(%rsp)
movq %r13, %rsi
callq 0x3b87d
cmpb $0x1, 0x28(%r12)
jne 0xbd5c7
leaq 0x446a1(%rip), %rsi     # 0x101c60
movq %r15, %rdi
callq 0x3b7af
movq %r15, 0x28(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq 0x10(%r12), %r13
jae 0xbd6d9
movq %r12, %rbp
movq 0x8(%r12), %rax
movq (%rax,%r13,8), %r12
movq %r12, %rdi
callq 0xbc370
xorl %ecx, %ecx
testq %rax, %rax
je 0xbd692
xorl %r14d, %r14d
movq %r12, %rdi
movq %r14, %rsi
callq 0xbbf5f
movq %rax, %rbx
movq 0x28(%rsp), %rdi
callq 0x3bb5d
leaq 0x7(%rsp), %rdi
movq %rax, %rsi
movq %rbx, %rdx
movq 0x20(%rsp), %rcx
callq 0x76a19
testl %eax, %eax
jne 0xbd690
cmpb $0x1, 0x7(%rsp)
jne 0xbd678
incq %r15
cmpq $0x1, %r15
ja 0xbd6a9
movq 0x10(%rsp), %rax
movq %r13, (%rax)
movq 0x18(%rsp), %rax
movq %r14, (%rax)
movq %r13, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movq 0x18(%rbp), %rbx
movq 0x8(%rsp), %rdi
callq 0x3bb5d
movq %rbx, %rdi
movq %rax, %rsi
leaq 0x38(%rsp), %rdx
callq 0xd83f0
incq %r14
movq %r12, %rdi
callq 0xbc370
cmpq %rax, %r14
jb 0xbd5ff
xorl %ecx, %ecx
jmp 0xbd692
movl %eax, %ecx
testl %ecx, %ecx
jne 0xbd6db
movq %rbp, %r12
incq %r13
cmpb $0x0, 0x7(%rsp)
je 0xbd5d2
jmp 0xbd6db
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x3bb5d
leaq 0x44561(%rip), %rsi     # 0x101c1e
xorl %ebx, %ebx
movq 0x20(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x34f1f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0xbd6ee
xorl %ecx, %ecx
testq %r15, %r15
sete %bl
movq 0x20(%rsp), %rbp
movq 0x8(%rsp), %r14
movl %ecx, %r15d
movq 0x28(%rsp), %rdi
callq 0x3c87b
movq 0x30(%rsp), %rdi
callq 0x3c87b
testl %r15d, %r15d
movl %r15d, %eax
jne 0xbd72f
testb %bl, %bl
je 0xbd72f
movq %r14, %rdi
callq 0x3bb5d
leaq 0x44553(%rip), %rsi     # 0x101c70
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x34f1f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2968d
callq 0x29656