// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4068, %rsp           # imm = 0x4068
testq %rdi, %rdi
je 0x1672e5
movq %rsi, %r13
testq %rsi, %rsi
je 0x1672e5
movq %rdx, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0x166b16
movq %r14, %rdi
callq 0x101a9a
testb %al, %al
jne 0x1672ef
callq 0x166a98
movq %rax, %rdi
movq %r15, %rsi
callq 0x165b75
movq %rax, %r15
movq 0x8(%rax), %rax
cmpq $0x0, 0x48(%rax)
jne 0x166b9a
movq 0x40(%rax), %rdi
callq 0x120e13
movq %rax, %r12
leaq 0x229ad8(%rip), %rsi    # 0x39061f
movq %rax, %rdi
callq 0x12097f
movq %r12, %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x10415c
testb %al, %al
jne 0x166b82
movq %r12, %rdi
callq 0x120d23
movq 0x8(%r15), %rcx
movq 0x8(%rcx), %rsi
movq 0x68(%rcx), %rdx
movq %rax, %rdi
movq %r14, %rcx
callq 0x1673bf
movq %r12, %rdi
callq 0x120e79
movq 0x8(%r15), %rcx
movq %rax, 0x48(%rcx)
movq %r12, %rdi
callq 0x121b03
movq 0x8(%r15), %rax
cmpq $0x0, 0x60(%rax)
je 0x166baf
movb $0x1, %bl
xorl %r12d, %r12d
jmp 0x167073
movq %r13, 0x20(%rsp)
movq 0x40(%rax), %rdi
testq %rdi, %rdi
je 0x1672ea
callq 0x120d4c
testq %rax, %rax
je 0x1672ea
callq 0x1208f8
movq %rax, %r13
callq 0x1208f8
movq %rax, %rbp
callq 0x1208f8
movq %rax, %r12
movq 0x8(%r15), %rax
movq 0x40(%rax), %rdi
callq 0x120d23
movq %rax, 0x8(%rsp)
movq 0x8(%r15), %rax
movq 0x48(%rax), %rdi
callq 0x120d23
testq %r15, %r15
je 0x1672fe
movq %rax, %rbx
testq %r14, %r14
je 0x166c27
movq %r14, %rdi
callq 0x101a9a
testb %al, %al
jne 0x167308
movq %rbx, 0x18(%rsp)
movq %r13, %rdi
callq 0x120db4
movq %rbp, %rdi
callq 0x120db4
leaq 0x229913(%rip), %rdi    # 0x390556
callq 0x17950
testq %rax, %rax
je 0x166c9d
movq %r13, %rdi
movq %rax, %rsi
callq 0x12097f
leaq 0x229a69(%rip), %rsi    # 0x3906c8
movq %r13, %rdi
callq 0x12097f
movq %r13, %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x10415c
movb $0x1, %bl
testb %al, %al
jne 0x166cae
movq %r13, %rdi
callq 0x120d23
leaq 0x229a44(%rip), %rsi    # 0x3906d0
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1019cf
jmp 0x166cae
leaq 0x229a25(%rip), %rsi    # 0x3906c9
movq %r13, %rdi
callq 0x12097f
movb $0x1, %bl
movq %rbp, %rdi
movq %r13, %rsi
callq 0x120a43
testb %bl, %bl
je 0x166fca
movq %rbp, 0x10(%rsp)
movq 0x8(%r15), %rax
xorl %ebp, %ebp
cmpl 0x10(%rax), %ebp
jo 0x166cef
leaq 0x21a3d3(%rip), %rsi    # 0x3810ab
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x10(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
cmpl 0x14(%rax), %ebp
jo 0x166d16
leaq 0x21a36d(%rip), %rsi    # 0x38106c
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x14(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
xorl %ebp, %ebp
cmpl 0x18(%rax), %ebp
jo 0x166d3f
leaq 0x21a3cb(%rip), %rsi    # 0x3810f3
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x18(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
cmpl 0x1c(%rax), %ebp
jo 0x166d66
leaq 0x2299a3(%rip), %rsi    # 0x3906f2
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x1c(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
xorl %ebp, %ebp
cmpl 0x20(%rax), %ebp
jo 0x166d8f
leaq 0x22997f(%rip), %rsi    # 0x3906f7
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x20(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
cmpl 0x24(%rax), %ebp
jo 0x166db6
leaq 0x22995d(%rip), %rsi    # 0x3906fc
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x24(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
xorl %ebp, %ebp
cmpl 0x28(%rax), %ebp
jo 0x166ddf
leaq 0x229939(%rip), %rsi    # 0x390701
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x28(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
cmpl 0x34(%rax), %ebp
jo 0x166e06
leaq 0x229917(%rip), %rsi    # 0x390706
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x34(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
xorl %ebp, %ebp
cmpl 0x2c(%rax), %ebp
jo 0x166e2f
leaq 0x21a13b(%rip), %rsi    # 0x380f53
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x2c(%rax), %esi
movq %r13, %rdi
callq 0x120c89
movq 0x8(%r15), %rax
cmpl 0x30(%rax), %ebp
jo 0x166e56
leaq 0x21a0da(%rip), %rsi    # 0x380f19
movq %r13, %rdi
callq 0x12097f
movq 0x8(%r15), %rax
movl 0x30(%rax), %esi
movq %r13, %rdi
callq 0x120c89
leaq 0x2298ae(%rip), %rsi    # 0x39070b
movq %r13, %rdi
callq 0x12097f
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x12097f
leaq 0x2649cf(%rip), %rsi    # 0x3cb848
movq %r13, %rdi
callq 0x12097f
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq 0x12097f
testb %bl, %bl
movq 0x10(%rsp), %rbp
je 0x167002
movq %r13, %rdi
callq 0x120d4c
testq %rax, %rax
je 0x167312
movq %r13, %rdi
callq 0x120d23
movq %rax, %rbx
movq %r13, %rdi
callq 0x120d4c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x10b95c
testq %rax, %rax
je 0x16730d
movq %rax, %rbp
cmpb $0x0, (%rax)
je 0x16730d
movq 0x8(%r15), %rax
movq 0x38(%rax), %rsi
movq %r12, %rdi
callq 0x12097f
leaq 0x1fd0b5(%rip), %rsi    # 0x363fab
movq %r12, %rdi
callq 0x12097f
movq %r12, %rdi
movq %rbp, %rsi
callq 0x12097f
leaq 0x229798(%rip), %rsi    # 0x3906a8
movq %r12, %rdi
callq 0x12097f
movq %r12, %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x10415c
testb %al, %al
jne 0x16702b
movq %r13, %rdi
callq 0x120d23
movq %rax, %rdi
movl $0x20, %esi
callq 0xe8650
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x120d23
xorl %ebx, %ebx
movq %rax, %rdi
movl $0x41, %esi
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x17d60
movl %eax, 0x18(%rsp)
callq 0x171d0
cmpl $-0x1, %eax
je 0x167006
movl %eax, %ebp
testl %eax, %eax
jne 0x166fae
movl 0x18(%rsp), %ebx
movl %ebx, %edi
movl $0x1, %esi
callq 0x17750
movl %ebx, %edi
callq 0x17fc0
movq 0x10(%rsp), %rdi
callq 0x120d23
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x175b0
leaq 0x60(%rsp), %rbx
movl %ebp, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x175f0
cmpl $-0x1, %eax
je 0x166fb3
movb $0x1, %bl
xorl %eax, %eax
jmp 0x167008
leaq 0x22973a(%rip), %rsi    # 0x39070b
movq %r13, %rdi
callq 0x12097f
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x12097f
leaq 0x26485b(%rip), %rsi    # 0x3cb848
movq %r13, %rdi
callq 0x12097f
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq 0x12097f
xorl %ebx, %ebx
jmp 0x16705e
movb $0x1, %al
testb %al, %al
je 0x16701d
leaq 0x22957d(%rip), %rsi    # 0x390590
movq %r14, %rdi
xorl %eax, %eax
callq 0x1019cf
movq 0x8(%rsp), %rdi
callq 0xe8d46
testb %bl, %bl
je 0x167057
movq %r12, %rdi
callq 0x120d23
leaq 0x1fce8f(%rip), %rdx    # 0x363ec9
xorl %edi, %edi
movq %rax, %rsi
movq %r14, %rcx
callq 0x1039a2
movq 0x8(%r15), %rcx
movq %rax, 0x60(%rcx)
testq %rax, %rax
setne %bl
jmp 0x167059
xorl %ebx, %ebx
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x121b03
movq %r13, %rdi
callq 0x121b03
movq 0x20(%rsp), %r13
movq %r12, %rdi
callq 0x121b03
movl $0x2, %eax
testb %bl, %bl
je 0x1672c6
movq 0x8(%r15), %rax
cmpq $0x0, 0x60(%rax)
je 0x1672f4
testq %r15, %r15
je 0x1672e0
movq 0x8(%r15), %rax
movq 0x60(%rax), %rdi
testq %rdi, %rdi
je 0x1672e0
callq 0x103ca0
movzbl %al, %ebp
cmpl $0x23, %ebp
jne 0x1670d2
movq 0x8(%r15), %rax
movq 0x60(%rax), %rdi
callq 0x103ca0
cmpl $0xa, %eax
jne 0x1670be
jmp 0x1670e2
movq 0x8(%r15), %rcx
movq 0x60(%rcx), %rdi
movsbl %al, %esi
callq 0x103cf4
cmpl $0x23, %ebp
je 0x1670a0
movq $-0x1, %rax
movq %rax, 0x48(%rsp)
movq %rax, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movq %rax, 0x58(%rsp)
movq %rax, 0x50(%rsp)
movb $0x7f, %al
movb %al, 0x7(%rsp)
movb %al, 0x6(%rsp)
movq 0x8(%r15), %rax
cmpq $0x0, 0x60(%rax)
je 0x1672f9
testq %r14, %r14
je 0x16713f
movq %r14, %rdi
callq 0x101a9a
testb %al, %al
jne 0x167303
movq 0x8(%r15), %rax
movq 0x58(%rax), %rdi
callq 0x120db4
movq 0x8(%r15), %rax
movq 0x58(%rax), %rdi
movq 0x60(%rax), %rsi
callq 0x121005
testl %eax, %eax
jne 0x1672b2
movq %r13, 0x20(%rsp)
movq 0x8(%r15), %rax
movq 0x58(%rax), %rdi
callq 0x120d23
subq $0x8, %rsp
leaq 0x58(%rsp), %r10
leaq 0xe(%rsp), %r11
leaq 0x30(%rsp), %r12
leaq 0x40(%rsp), %r13
leaq 0x2068(%rsp), %rbp
leaq 0x2295b8(%rip), %rsi    # 0x390756
leaq 0x50(%rsp), %rdx
leaq 0x68(%rsp), %rcx
leaq 0x48(%rsp), %r8
leaq 0x38(%rsp), %r9
movq %rax, %rdi
movl $0x0, %eax
pushq %r10
pushq %r11
pushq %r12
pushq %r13
pushq %rbp
leaq 0x88(%rsp), %r10
pushq %r10
leaq 0x3f(%rsp), %r10
pushq %r10
callq 0x177f0
addq $0x40, %rsp
movq 0x8(%r15), %rcx
cmpl $0xb, %eax
jne 0x16728b
movq 0x68(%rcx), %rdi
leaq 0x60(%rsp), %rsi
callq 0x105a11
cmpq $-0x1, %rax
je 0x167317
movq %rax, %r14
movq 0x8(%r15), %rax
movq 0x68(%rax), %rdi
leaq 0x2060(%rsp), %rsi
callq 0x105a11
cmpq $-0x1, %rax
movq 0x20(%rsp), %r13
je 0x16731c
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %r9
movq 0x38(%rsp), %r10
movq 0x30(%rsp), %rcx
leaq (%r9,%rcx), %r11
decq %r11
movq 0x28(%rsp), %rcx
leaq (%r10,%rcx), %r15
decq %r15
movb 0x7(%rsp), %cl
xorl %r12d, %r12d
cmpb 0x6(%rsp), %cl
setne %r12b
leaq 0x60(%rsp), %rdi
leaq 0x2060(%rsp), %rsi
movq %r14, %rcx
movq %rax, %r8
pushq %r12
pushq %r15
pushq %r11
pushq %r10
callq 0x167f1f
addq $0x20, %rsp
movq %rax, (%r13)
xorl %eax, %eax
jmp 0x1672b2
movq 0x58(%rcx), %rdi
callq 0x120d23
leaq 0x2294e3(%rip), %rsi    # 0x39077e
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x20(%rsp), %r13
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %dl
xorl %eax, %eax
testb %bl, %dl
jne 0x1672ce
movb %dl, %cl
incl %ecx
movl %ecx, %eax
movq $0x0, (%r13)
addq $0x4068, %rsp           # imm = 0x4068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4d289
callq 0x4d0fc
callq 0x4d3a4
callq 0x4d135
callq 0x4d2c2
callq 0x4d250
callq 0x4d36d
callq 0x4d1a5
callq 0x4d16e
callq 0x4d2fb
callq 0x4d334
callq 0x4d217
callq 0x4d1de