// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/encseq_col.c
// Function: gt_encseq_col_do_grep_desc
static int gt_encseq_col_do_grep_desc(GtEncseqCol *esc, GtUword *filenum,
                                      GtUword *seqnum, GtStr *seqid,
                                      GtError *err)
{
  GtUword 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(esc && filenum && seqnum && seqid);
  gt_assert(esc->encseq && gt_encseq_has_description_support(esc->encseq));

  /* create cache */
  if (!esc->grep_cache)
    esc->grep_cache = gt_seq_info_cache_new();
  /* try to read from cache */
  seq_info_ptr = gt_seq_info_cache_get(esc->grep_cache, gt_str_get(seqid));
  if (seq_info_ptr) {
    if (esc->duplicates && gt_hashmap_get(esc->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 (esc->matchstart)
    gt_str_append_cstr(pattern, "^");
  gt_str_append_str(pattern, escaped);
  if (esc->matchstart)
    gt_str_append_cstr(pattern, "([[:space:]]|$)");
  for (j = 0; !had_err && j < gt_encseq_num_of_sequences(esc->encseq); j++) {
    const char *desc;
    GtUword desc_len;
    desc = gt_encseq_description(esc->encseq, &desc_len, j);
    gt_assert(desc);
    had_err = gt_grep_nt(&match, gt_str_get(pattern), desc, desc_len, 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 = seq_info.filenum =
                       gt_encseq_filenum(esc->encseq,
                                         gt_encseq_seqstartpos(esc->encseq, j));
      *seqnum = seq_info.seqnum =
                      j - gt_encseq_filenum_first_seqnum(esc->encseq, *filenum);
      gt_seq_info_cache_add(esc->grep_cache, gt_str_get(seqid), &seq_info);
    }
  }
  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, %rbx
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %r15
movq %rdi, %r13
movb $0x0, 0x7(%rsp)
testq %r8, %r8
je 0xbac83
movq %rbx, %rdi
callq 0xc103
testb %al, %al
jne 0xbafa6
testq %r15, %r15
je 0xbaf7c
testq %rbp, %rbp
je 0xbaf7c
movq %rbx, 0x10(%rsp)
movq 0x8(%r13), %rdi
testq %rdi, %rdi
je 0xbaf52
callq 0xa7a86
testb %al, %al
je 0xbaf52
movq 0x18(%r13), %r14
testq %r14, %r14
jne 0xbacc9
callq 0xbffc4
movq %rax, %r14
movq %rax, 0x18(%r13)
movq %r12, %rdi
callq 0x143d2
movq %r14, %rdi
movq %rax, %rsi
callq 0xc0019
testq %rax, %rax
je 0xbad37
movq %rax, %r14
movq %r15, %rbx
movq 0x20(%r13), %r15
testq %r15, %r15
je 0xbad21
movq %r12, %rdi
callq 0x143d2
movq %r15, %rdi
movq %rax, %rsi
callq 0x55ef6
testq %rax, %rax
je 0xbad21
movq %r12, %rdi
callq 0x143d2
leaq 0x30183(%rip), %rsi     # 0xeae9a
movq 0x10(%rsp), %rdi
jmp 0xbaedf
movq (%r14), %rax
movq %rax, (%rbx)
movq 0x8(%r14), %rax
movq %rax, (%rbp)
xorl %r15d, %r15d
jmp 0xbaeed
movq %rbp, 0x28(%rsp)
callq 0x13d5c
movq %rax, %rbp
callq 0x13d5c
movq %rax, %rbx
movq %r12, %rdi
callq 0x143d2
movq %rax, %r14
movq %r12, %rdi
callq 0x14461
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x551fc
cmpb $0x1, 0x28(%r13)
jne 0xbad83
leaq 0x3015f(%rip), %rsi     # 0xeaeda
movq %rbp, %rdi
callq 0x13dd3
movq %r15, 0x20(%rsp)
movq %r12, 0x8(%rsp)
movq %rbp, %rdi
movq %rbx, 0x18(%rsp)
movq %rbx, %rsi
callq 0x13eeb
cmpb $0x1, 0x28(%r13)
movq 0x10(%rsp), %r14
jne 0xbadb8
leaq 0x3012c(%rip), %rsi     # 0xeaedc
movq %rbp, %rdi
callq 0x13dd3
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %r15d, %r15d
testl %r15d, %r15d
jne 0xbaea4
movq 0x8(%r13), %rdi
callq 0xa1f8d
cmpq %rax, %r12
jae 0xbaea4
movq 0x8(%r13), %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
callq 0xa7510
testq %rax, %rax
je 0xbaf28
movq %rax, %r15
movq %rbp, %rdi
callq 0x143d2
movq 0x30(%rsp), %rcx
leaq 0x7(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %r8
callq 0x552bb
movl %eax, %r15d
testl %eax, %eax
jne 0xbae9c
cmpb $0x1, 0x7(%rsp)
jne 0xbae9c
incq %rbx
cmpq $0x1, %rbx
ja 0xbaeff
movq 0x8(%r13), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0xa6788
movq %r14, %rdi
movq %rax, %rsi
callq 0xb3583
movq %rax, 0x38(%rsp)
movq 0x20(%rsp), %rcx
movq %rax, (%rcx)
movq 0x8(%r13), %rdi
movq %rax, %rsi
callq 0xb3692
movq %r12, %rcx
subq %rax, %rcx
movq %rcx, 0x40(%rsp)
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%r13), %r14
movq 0x8(%rsp), %rdi
callq 0x143d2
movq %r14, %rdi
movq 0x10(%rsp), %r14
movq %rax, %rsi
leaq 0x38(%rsp), %rdx
callq 0xc005d
incq %r12
jmp 0xbadc0
testq %rbx, %rbx
sete %bl
movq 0x8(%rsp), %r12
movq %rbp, %rdi
callq 0x152db
movq 0x18(%rsp), %rdi
callq 0x152db
testl %r15d, %r15d
sete %al
andb %bl, %al
cmpb $0x1, %al
jne 0xbaeed
movq %r12, %rdi
callq 0x143d2
leaq 0x30010(%rip), %rsi     # 0xeaeec
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %r15
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x143d2
leaq 0x2ff87(%rip), %rsi     # 0xeae9a
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %r15
jmp 0xbaeaf
movq 0x73089(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xf12d(%rip), %rsi      # 0xca066
leaq 0x28ede(%rip), %rdx     # 0xe3e1e
leaq 0x36335(%rip), %rcx     # 0xf127c
leaq 0x36264(%rip), %r8      # 0xf11b2
pushq $0x61
jmp 0xbafce
movq 0x7305f(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xf103(%rip), %rsi      # 0xca066
leaq 0x3634f(%rip), %rdx     # 0xf12b9
leaq 0x3630b(%rip), %rcx     # 0xf127c
leaq 0x3623a(%rip), %r8      # 0xf11b2
pushq $0x44
jmp 0xbafce
movq 0x73035(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xf0d9(%rip), %rsi      # 0xca066
leaq 0x36303(%rip), %rdx     # 0xf1297
leaq 0x362e1(%rip), %rcx     # 0xf127c
leaq 0x36210(%rip), %r8      # 0xf11b2
pushq $0x43
jmp 0xbafce
movq 0x7300b(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xf0af(%rip), %rsi      # 0xca066
leaq 0xf69b(%rip), %rdx      # 0xca659
leaq 0x362b7(%rip), %rcx     # 0xf127c
leaq 0x361e6(%rip), %r8      # 0xf11b2
pushq $0x41
popq %r9
xorl %eax, %eax
callq 0xb8c0
callq 0xb300