// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %r8, %r15
movq %rcx, %rbx
movq %rdx, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
movb $0x0, 0x7(%rsp)
testq %r8, %r8
je 0xbc42f
movq %r15, %rdi
callq 0x3566a
testb %al, %al
jne 0xbc6d5
cmpq $0x0, 0x10(%rsp)
je 0xbc6d0
cmpq $0x0, 0x8(%rsp)
je 0xbc6d0
cmpq $0x0, 0x18(%r13)
jne 0xbc457
callq 0xd7c78
movq %rax, 0x18(%r13)
movq 0x18(%r13), %r14
movq %rbx, %rdi
callq 0x3c40b
movq %r14, %rdi
movq %rax, %rsi
callq 0xd7cd5
testq %rax, %rax
movq %r15, 0x28(%rsp)
je 0xbc4d4
movq %rax, %r14
movq 0x20(%r13), %r15
testq %r15, %r15
je 0xbc4b5
movq %rbx, %rdi
callq 0x3c40b
movq %r15, %rdi
movq %rax, %rsi
callq 0x77109
testq %rax, %rax
je 0xbc4b5
movq %rbx, %rdi
callq 0x3c40b
leaq 0x457ff(%rip), %rsi     # 0x101caa
movq 0x28(%rsp), %rdi
jmp 0xbc6ae
movq (%r14), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
xorl %r12d, %r12d
jmp 0xbc6be
callq 0x3bfe0
movq %rax, %rbp
callq 0x3bfe0
movq %rax, %r12
movq %rbx, %rdi
callq 0x3c40b
movq %rax, %r14
movq %rbx, %rdi
callq 0x3c434
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x762f0
cmpb $0x1, 0x28(%r13)
jne 0xbc51b
leaq 0x457d7(%rip), %rsi     # 0x101cea
movq %rbp, %rdi
callq 0x3c067
movq %rbx, 0x18(%rsp)
movq %rbp, %rdi
movq %r12, 0x40(%rsp)
movq %r12, %rsi
callq 0x3c12b
cmpb $0x1, 0x28(%r13)
jne 0xbc546
leaq 0x457ae(%rip), %rsi     # 0x101cec
movq %rbp, %rdi
callq 0x3c067
xorl %ecx, %ecx
movq $0x0, 0x20(%rsp)
movq %r13, 0x30(%rsp)
cmpq 0x10(%r13), %rcx
jae 0xbc678
movq 0x8(%r13), %rax
movq %rcx, 0x38(%rsp)
movq (%rax,%rcx,8), %r14
xorl %r13d, %r13d
movq %r14, %rdi
callq 0xbb2b2
cmpq %rax, %r13
jae 0xbc656
movq %r14, %rdi
movq %r13, %rsi
callq 0xbaea2
movq %rax, %r12
movq %rbp, %rdi
callq 0x3c40b
leaq 0x7(%rsp), %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x76504
movl %eax, %r12d
movb $0x1, %bl
testl %eax, %eax
jne 0xbc644
cmpb $0x1, 0x7(%rsp)
jne 0xbc644
movq 0x20(%rsp), %rcx
incq %rcx
movq %rcx, 0x20(%rsp)
cmpq $0x2, %rcx
jb 0xbc5fd
movq 0x18(%rsp), %rdi
callq 0x3c40b
xorl %ebx, %ebx
movq %r15, %rdi
leaq 0x456bf(%rip), %rsi     # 0x101caa
movq %rax, %rdx
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0xbc644
movq 0x10(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, (%rax)
movq 0x8(%rsp), %rax
movq %r13, (%rax)
movq %rcx, 0x48(%rsp)
movq %r13, 0x50(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %r15
movq 0x18(%rsp), %rdi
callq 0x3c40b
movq %r15, %rdi
movq 0x28(%rsp), %r15
movq %rax, %rsi
leaq 0x48(%rsp), %rdx
callq 0xd7ce8
testb %bl, %bl
je 0xbc659
incq %r13
testl %r12d, %r12d
je 0xbc570
jmp 0xbc659
xorl %r12d, %r12d
testl %r12d, %r12d
jne 0xbc67b
movq 0x38(%rsp), %rcx
incq %rcx
cmpb $0x0, 0x7(%rsp)
movq 0x30(%rsp), %r13
je 0xbc556
jmp 0xbc67b
xorl %r12d, %r12d
movq %rbp, %rdi
callq 0x3d1eb
movq 0x40(%rsp), %rdi
callq 0x3d1eb
testl %r12d, %r12d
jne 0xbc6be
cmpq $0x0, 0x20(%rsp)
jne 0xbc6be
movq 0x18(%rsp), %rdi
callq 0x3c40b
leaq 0x45651(%rip), %rsi     # 0x101cfc
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2984f
callq 0x29818
nop