// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/match_iterator_last.c
// Function: gt_match_iterator_last_next
static GtMatchIteratorStatus gt_match_iterator_last_next(GT_UNUSED
                                                         GtMatchIterator *gmpi,
                                                         GT_UNUSED
                                                         GtMatch **match,
                                                         GtError *err)
{
#ifndef _WIN32
  int had_err = 0, rval;
  GtMatchIteratorLast *mil;
  GtStr *tmp = NULL,
        *lastbinary = NULL,
        *matchfilename = NULL;
  gt_assert(gmpi && match);
  gt_error_check(err);
  mil = gt_match_iterator_last_cast(gmpi);

  if (!mil->pvt->queryfilename) {
    GtStr *fn = gt_str_clone(mil->pvt->idxfilename);
    gt_str_append_cstr(fn, ".qry");
    if (!gt_file_exists(gt_str_get(fn))) {
      last_prepare_fasta_seqs(gt_str_get(fn), mil->pvt->es2,
                              mil->pvt->desc_to_seqno, err);
    }
    mil->pvt->queryfilename = gt_str_ref(fn);
    gt_str_delete(fn);
  }

  if (!mil->pvt->matchfile) {
    int fdout;
    pid_t pid;
    gt_assert(mil->pvt->idxfilename
                && gt_str_length(mil->pvt->idxfilename) > 0);

    tmp = gt_str_new();
    lastbinary = gt_str_new();
    matchfilename = gt_str_new();
    had_err = get_run_parameterization(mil, tmp, lastbinary,
                                       gt_str_get(mil->pvt->idxfilename),
                                       gt_str_get(mil->pvt->queryfilename),
                                       err);
    if (!had_err) {
      char *matchfilehash;
      gt_assert(gt_str_length(tmp) > 0);
      matchfilehash = gt_md5_fingerprint(gt_str_get(tmp), gt_str_length(tmp));
      gt_assert(matchfilehash && strlen(matchfilehash) > 0);
      gt_str_append_cstr(matchfilename, mil->pvt->tmpdir);
      gt_str_append_cstr(matchfilename, "/");
      gt_str_append_cstr(matchfilename, matchfilehash);
      gt_str_append_cstr(matchfilename, ".match");
    }

    if (!had_err && !gt_file_exists(gt_str_get(matchfilename))) {
      char **args = NULL;
      args = gt_cstr_split(gt_str_get(tmp), ' ');
      fdout = open(gt_str_get(matchfilename), O_WRONLY | O_CREAT, 0600);
      switch ((pid = fork())) {
        case -1:
               had_err = -1;
               break;
        case 0:
          dup2(fdout, STDOUT_FILENO);
          close(fdout);
          execvp(gt_str_get(lastbinary), args);
        default:
        {
          int status;
          while (-1 == waitpid(pid, &status, 0));
        }
      }
      if (had_err == -1)
        gt_error_set(err, "error forking the LAST process");
      gt_cstr_array_delete(args);
    }
    if (!had_err) {
      mil->pvt->matchfile = gt_file_open(GT_FILE_MODE_UNCOMPRESSED,
                                         gt_str_get(matchfilename), "r", err);
      if (!mil->pvt->matchfile) {
        had_err = -1;
      }
    }
    gt_str_delete(lastbinary);
    gt_str_delete(tmp);

  }
  gt_str_delete(matchfilename);

  if (!had_err) {
    /* result file should now be open */
    gt_assert(mil->pvt->matchfile);
    /* skip all comment lines */
    while (last_parse_comment_line(mil));
    /* parse next match */
    if ((rval = last_parse_match(mil, match, err)) == EOF) {
      *match = NULL;
      return GT_MATCHER_STATUS_END;
    }
  }
  /* return error if required */
  if (had_err) {
    *match = NULL;
    return GT_MATCHER_STATUS_ERROR;
  }
  return GT_MATCHER_STATUS_OK;
#else
  /* XXX */
  gt_error_set(err, "gt_match_iterator_last_next() not implemented");
  return GT_MATCHER_STATUS_ERROR;
#endif
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movl $0x0, 0x84(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
cmpq $0x0, 0x98(%rsp)
je 0x1a94eb
cmpq $0x0, 0x90(%rsp)
jne 0x1a9523
movq 0x492aae(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x36cb17(%rip), %rsi    # 0x516013
leaq 0x3b0492(%rip), %rdx    # 0x559995
leaq 0x3b0499(%rip), %rcx    # 0x5599a3
leaq 0x3b038d(%rip), %r8     # 0x55989e
movl $0x120, %r9d            # imm = 0x120
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1a9525
jmp 0x1a9527
cmpq $0x0, 0x88(%rsp)
je 0x1a957d
movq 0x88(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x1a9545
jmp 0x1a957d
movq 0x492a54(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x36cabd(%rip), %rsi    # 0x516013
leaq 0x36cc62(%rip), %rdx    # 0x5161bf
leaq 0x3b043f(%rip), %rcx    # 0x5599a3
leaq 0x3b0333(%rip), %r8     # 0x55989e
movl $0x121, %r9d            # imm = 0x121
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1a957f
callq 0x1a9050
movq %rax, %rdi
movq 0x98(%rsp), %rsi
callq 0x1a79f0
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x48(%rax)
jne 0x1a9643
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rdi
callq 0x11e280
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x3b03ef(%rip), %rsi    # 0x5599bf
callq 0x11d550
movq 0x58(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
callq 0xde820
testb $0x1, %al
jne 0x1a961f
movq 0x58(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x68(%rax), %rdx
movq 0x88(%rsp), %rcx
callq 0x1a9cf0
movq 0x58(%rsp), %rdi
callq 0x11e360
movq %rax, %rcx
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x48(%rax)
movq 0x58(%rsp), %rdi
callq 0x11f560
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x60(%rax)
jne 0x1a99ed
jmp 0x1a9659
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x40(%rax)
je 0x1a9681
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rdi
callq 0x11dfa0
cmpq $0x0, %rax
ja 0x1a96b9
movq 0x492918(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x36c981(%rip), %rsi    # 0x516013
leaq 0x3b032b(%rip), %rdx    # 0x5599c4
leaq 0x3b0303(%rip), %rcx    # 0x5599a3
leaq 0x3b01f7(%rip), %r8     # 0x55989e
movl $0x133, %r9d            # imm = 0x133
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1a96bb
callq 0x11d4a0
movq %rax, 0x70(%rsp)
callq 0x11d4a0
movq %rax, 0x68(%rsp)
callq 0x11d4a0
movq %rax, 0x60(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rdi
callq 0x11dee0
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x48(%rax), %rdi
callq 0x11dee0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %rax, %r8
movq 0x88(%rsp), %r9
callq 0x1a9fa0
movl %eax, 0x84(%rsp)
cmpl $0x0, 0x84(%rsp)
jne 0x1a986a
jmp 0x1a975b
movq 0x70(%rsp), %rdi
callq 0x11dfa0
cmpq $0x0, %rax
ja 0x1a97a3
movq 0x49282e(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x36c897(%rip), %rsi    # 0x516013
leaq 0x3b0283(%rip), %rdx    # 0x559a06
leaq 0x3b0219(%rip), %rcx    # 0x5599a3
leaq 0x3b010d(%rip), %r8     # 0x55989e
movl $0x13e, %r9d            # imm = 0x13E
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1a97a5
movq 0x70(%rsp), %rdi
callq 0x11dee0
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rdi
callq 0x11dfa0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0xeeef0
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x1a97e8
movq 0x48(%rsp), %rdi
callq 0x192b0
cmpq $0x0, %rax
ja 0x1a9820
movq 0x4927b1(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x36c81a(%rip), %rsi    # 0x516013
leaq 0x3b021d(%rip), %rdx    # 0x559a1d
leaq 0x3b019c(%rip), %rcx    # 0x5599a3
leaq 0x3b0090(%rip), %r8     # 0x55989e
movl $0x140, %r9d            # imm = 0x140
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1a9822
movq 0x60(%rsp), %rdi
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rax), %rsi
callq 0x11d550
movq 0x60(%rsp), %rdi
leaq 0x3828a1(%rip), %rsi    # 0x52c0e6
callq 0x11d550
movq 0x60(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x11d550
movq 0x60(%rsp), %rdi
leaq 0x3b01e3(%rip), %rsi    # 0x559a48
callq 0x11d550
cmpl $0x0, 0x84(%rsp)
jne 0x1a997f
movq 0x60(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
callq 0xde820
testb $0x1, %al
jne 0x1a997f
movq $0x0, 0x40(%rsp)
movq 0x70(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
movl $0x20, %esi
callq 0xa2b40
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
xorl %eax, %eax
movl $0x41, %esi
movl $0x180, %edx            # imm = 0x180
callq 0x19c80
movl %eax, 0x54(%rsp)
callq 0x19190
movl %eax, 0x50(%rsp)
movl %eax, %ecx
movl %ecx, 0xc(%rsp)
subl $-0x1, %eax
je 0x1a98f9
jmp 0x1a98ef
movl 0xc(%rsp), %eax
testl %eax, %eax
je 0x1a9906
jmp 0x1a9934
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x1a9955
movl 0x54(%rsp), %edi
movl $0x1, %esi
callq 0x196f0
movl 0x54(%rsp), %edi
callq 0x19ec0
movq 0x68(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
movq 0x40(%rsp), %rsi
callq 0x19560
jmp 0x1a9936
movl 0x50(%rsp), %edi
leaq 0x3c(%rsp), %rsi
xorl %edx, %edx
callq 0x195a0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x1a9953
jmp 0x1a9936
jmp 0x1a9955
cmpl $-0x1, 0x84(%rsp)
jne 0x1a9975
movq 0x88(%rsp), %rdi
leaq 0x3affc2(%rip), %rsi    # 0x559930
movb $0x0, %al
callq 0xd88c0
movq 0x40(%rsp), %rdi
callq 0xa3950
cmpl $0x0, 0x84(%rsp)
jne 0x1a99d9
movq 0x60(%rsp), %rdi
callq 0x11dee0
movq %rax, %rsi
movq 0x88(%rsp), %rcx
xorl %edi, %edi
leaq 0x382633(%rip), %rdx    # 0x52bfda
callq 0xdd3f0
movq %rax, %rcx
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x60(%rax)
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x60(%rax)
jne 0x1a99d7
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x1a99d9
movq 0x68(%rsp), %rdi
callq 0x11f560
movq 0x70(%rsp), %rdi
callq 0x11f560
movq 0x60(%rsp), %rdi
callq 0x11f560
cmpl $0x0, 0x84(%rsp)
jne 0x1a9aa9
jmp 0x1a9a07
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x60(%rax)
jne 0x1a9a4f
movq 0x492582(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x36c5eb(%rip), %rsi    # 0x516013
leaq 0x3b008a(%rip), %rdx    # 0x559ab9
leaq 0x3aff6d(%rip), %rcx    # 0x5599a3
leaq 0x3afe61(%rip), %r8     # 0x55989e
movl $0x16c, %r9d            # imm = 0x16C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1a9a51
jmp 0x1a9a53
movq 0x78(%rsp), %rdi
callq 0x1aa3b0
testb $0x1, %al
jne 0x1a9a63
jmp 0x1a9a65
jmp 0x1a9a53
movq 0x78(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
callq 0x1aa480
movl %eax, 0x80(%rsp)
cmpl $-0x1, %eax
jne 0x1a9aa7
movq 0x90(%rsp), %rax
movq $0x0, (%rax)
movl $0x1, 0xa4(%rsp)
jmp 0x1a9ada
jmp 0x1a9aa9
cmpl $0x0, 0x84(%rsp)
je 0x1a9acf
movq 0x90(%rsp), %rax
movq $0x0, (%rax)
movl $0x2, 0xa4(%rsp)
jmp 0x1a9ada
movl $0x0, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
nopl (%rax)