// File: /workspace/github_c_makefile_star2_O1/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 0xb14c2
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0xb139a
movq %rbx, %rdi
callq 0x3566a
testb %al, %al
jne 0xb14cc
callq 0xb1334
movq %rax, %rdi
movq %r15, %rsi
callq 0x49b60
movq %rax, %r15
movq 0x18(%rax), %rdi
movl 0x20(%rax), %edx
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x58cf6
movq 0x18(%r15), %rdi
leaq 0x4492f(%rip), %rdx     # 0xf5cf8
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5b252
movq 0x18(%r15), %rdi
leaq 0x4ce3e(%rip), %rsi     # 0xfe21c
callq 0x58568
movq 0x18(%r15), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x58a66
movq 0x18(%r15), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x57c5c
testl %eax, %eax
je 0xb14c7
movq 0x18(%r15), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x57c3c
movq 0x18(%r15), %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x59536
movq 0x18(%r15), %rdi
testl %eax, %eax
je 0xb1459
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x58042
leaq 0x3d6ff(%rip), %rsi     # 0xeeb49
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3559f
jmp 0xb149c
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x57c5c
testl %eax, %eax
je 0xb1493
movq 0x18(%r15), %rdi
leaq 0x44015(%rip), %rdx     # 0xf5487
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xa8774
testq %rax, %rax
je 0xb14a9
movq (%rax), %rdi
callq 0x41ca0
movq %rax, (%r14)
jmp 0xb149a
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 0x58042
leaq 0x4cd7d(%rip), %rsi     # 0xfe23d
jmp 0xb144a
callq 0x272af
callq 0x27276
callq 0x2723d