// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xb0982
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0xb085a
movq %rbx, %rdi
callq 0x34fea
testb %al, %al
jne 0xb098c
callq 0xb07f4
movq %rax, %rdi
movq %r15, %rsi
callq 0x48f0b
movq %rax, %r15
movq 0x18(%rax), %rdi
movl 0x20(%rax), %edx
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x58086
movq 0x18(%r15), %rdi
leaq 0x4540f(%rip), %rdx     # 0xf5c98
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5a67c
movq 0x18(%r15), %rdi
leaq 0x4d91e(%rip), %rsi     # 0xfe1bc
callq 0x5790a
movq 0x18(%r15), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x57e45
movq 0x18(%r15), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x56f9b
testl %eax, %eax
je 0xb0987
movq 0x18(%r15), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x56f7b
movq 0x18(%r15), %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x588cb
movq 0x18(%r15), %rdi
testl %eax, %eax
je 0xb0919
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x573f8
leaq 0x3e1f7(%rip), %rsi     # 0xeeb01
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x34f1f
jmp 0xb095c
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x56f9b
testl %eax, %eax
je 0xb0953
movq 0x18(%r15), %rdi
leaq 0x44af5(%rip), %rdx     # 0xf5427
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xa7db8
testq %rax, %rax
je 0xb0969
movq (%rax), %rdi
callq 0x4130c
movq %rax, (%r14)
jmp 0xb095a
movq $0x0, (%r14)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%r15), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x573f8
leaq 0x4d85d(%rip), %rsi     # 0xfe1dd
jmp 0xb090a
callq 0x2715f
callq 0x27126
callq 0x270ed