// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/gtlua/genome_stream_lua.c
// Function: lua_custom_stream_next
static int lua_custom_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                                  GtError *err)
{
  GT_UNUSED GtNodeStream **s;
  GtGenomeNode **retnode;
  GtLuaCustomStream *lcs;
  int had_err = 0;
  gt_assert(ns);
  gt_error_check(err);
  lcs = lua_custom_stream_cast(ns);

  /* push correct Lua object for this stream */
  lua_rawgeti(lcs->L, LUA_REGISTRYINDEX, lcs->ref);
  s = check_genome_stream(lcs->L, -1);

  /* get overridden next_tree method */
  lua_pushstring(lcs->L, "next_tree");
  lua_gettable(lcs->L, -2);

  /* make sure there is one */
  gt_assert(!lua_isnil(lcs->L, -1));
  lua_pushvalue(lcs->L, -2);

  if (lua_pcall(lcs->L, 1, 1, 0)) {
    const char *error = lua_tostring(lcs->L, -1);
    gt_error_set(err, "%s", error);
    had_err = -1;
  }

  if (!had_err) {
    if (lua_isnil(lcs->L, -1)) {
      *gn = NULL;
    } else {
      retnode = gt_lua_try_checkudata(lcs->L, -1, GENOME_NODE_METATABLE);
      if (!retnode) {
        const char *type;
        type = lua_tostring(lcs->L, -1);
        gt_error_set(err, "custom 'next_tree' method must return a genome "
                          "node or nil, was %s", type);
        had_err = -1;
      } else {
        *gn = gt_genome_node_ref(*retnode);
      }
    }
  }
  return had_err;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movl $0x0, 0x14(%rsp)
cmpq $0x0, 0x40(%rsp)
jne 0xf9b2b
movq 0xba4de(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x64562(%rip), %rsi     # 0x15e066
leaq 0x82caa(%rip), %rdx     # 0x17c7b5
leaq 0x82b53(%rip), %rcx     # 0x17c665
leaq 0x82b2e(%rip), %r8      # 0x17c647
movl $0x94, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xf9b2d
jmp 0xf9b2f
cmpq $0x0, 0x30(%rsp)
je 0xf9b7f
movq 0x30(%rsp), %rdi
callq 0xc270
testb $0x1, %al
jne 0xf9b47
jmp 0xf9b7f
movq 0xba48a(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x6450e(%rip), %rsi     # 0x15e066
leaq 0x64ae9(%rip), %rdx     # 0x15e648
leaq 0x82aff(%rip), %rcx     # 0x17c665
leaq 0x82ada(%rip), %r8      # 0x17c647
movl $0x95, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xf9b81
callq 0xf9a90
movq %rax, %rdi
movq 0x40(%rsp), %rsi
callq 0x34af0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x18(%rsp), %rax
movl 0x20(%rax), %edx
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x51880
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x7a2e0(%rip), %rdx     # 0x173ea8
callq 0x559c0
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0x82a9a(%rip), %rsi     # 0x17c67c
callq 0x50970
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x51440
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4f800
cmpl $0x0, %eax
jne 0xf9c4a
movq 0xba3bf(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x64443(%rip), %rsi     # 0x15e066
leaq 0x82a5c(%rip), %rdx     # 0x17c686
leaq 0x82a34(%rip), %rcx     # 0x17c665
leaq 0x82a0f(%rip), %r8      # 0x17c647
movl $0xa1, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xf9c4c
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4f790
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
movl %edx, %esi
callq 0x527f0
cmpl $0x0, %eax
je 0xf9cb7
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x50180
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x72205(%rip), %rsi     # 0x16bead
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x14(%rsp)
jne 0xf9d67
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4f800
cmpl $0x0, %eax
jne 0xf9ce8
movq 0x38(%rsp), %rax
movq $0x0, (%rax)
jmp 0xf9d65
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x7993a(%rip), %rdx     # 0x173637
callq 0xe85e0
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0xf9d4b
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x50180
movq %rax, (%rsp)
movq 0x30(%rsp), %rdi
movq (%rsp), %rdx
leaq 0x82963(%rip), %rsi     # 0x17c69d
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
jmp 0xf9d63
movq 0x20(%rsp), %rax
movq (%rax), %rdi
callq 0x25140
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
jmp 0xf9d65
jmp 0xf9d67
movl 0x14(%rsp), %eax
addq $0x48, %rsp
retq