// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/spec_visitor.c
// Function: spec_expect_matchdispatch
static int spec_expect_matchdispatch(lua_State *L)
{
  GtSpecVisitor *sv;
  bool success;
  const char *msg = "";

  /* get visitor */
  lua_pushlightuserdata(L, (void *) &spec_defuserdata);
  lua_gettable(L, LUA_REGISTRYINDEX);
  sv = lua_touserdata(L, -1);

  /* get correct matcher function from speclib */
  lua_getglobal(L, "matchers");
  lua_pushstring(L, sv->matcher_name);
  lua_gettable(L, -2);
  lua_insert(L, 1);

  /* get target */
  lua_rawgeti(L, LUA_REGISTRYINDEX, sv->target_ref);
  lua_insert(L, 2);
  luaL_unref(L, LUA_REGISTRYINDEX, sv->target_ref);

  /* call matcher */
  lua_pop(L, 2);
  if (!lua_isfunction(L, 1)) {
    luaL_where(L, 1);
    lua_pushstring(L, "matcher '");
    lua_pushstring(L, sv->matcher_name);
    lua_pushstring(L, "' is not a function");
    lua_concat(L, 4);
    return lua_error(L);
  }
  lua_pcall(L, lua_gettop(L)-1, 2, 0);

  /* handle results */
  if (!lua_isboolean(L, 1)) {
    lua_pushstring(L, "matcher '");
    lua_pushstring(L, sv->matcher_name);
    lua_pushstring(L, "' must return boolean");
    lua_concat(L, 3);
    return lua_error(L);
  }
  success = lua_toboolean(L, 1);
  if (!success) {
    gt_assert(lua_isstring(L, 2));
    msg = lua_tostring(L, 2);
    luaL_where(L, 1);
    lua_pushstring(L, msg);
    lua_concat(L, 2);
    msg = lua_tostring(L, -1);
  }
  gt_spec_results_add_result(sv->res, sv->current_aspect, sv->current_node,
                             success ? GT_SPEC_SUCCESS : GT_SPEC_FAILURE, msg);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x344465(%rip), %rsi    # 0x4c51f8
callq 0x22e58a
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x22e5c2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x22de0e
movq %rax, %r14
leaq 0x21c660(%rip), %rdx    # 0x39d41c
movq %rbx, %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x22e6f4
movq 0x58(%r14), %rsi
movq %rbx, %rdi
callq 0x22e0c4
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x22e5c2
movq %rbx, %rdi
movl $0x1, %esi
callq 0x22d562
movl 0x40(%r14), %edx
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x22e852
movq %rbx, %rdi
movl $0x2, %esi
callq 0x22d562
movl 0x40(%r14), %edx
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x23179e
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x22d42e
movq %rbx, %rdi
movl $0x1, %esi
callq 0x22d7b8
movq %rbx, %rdi
cmpl $0x6, %eax
jne 0x180e8c
callq 0x22d421
leal -0x1(%rax), %esi
movq %rbx, %rdi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x22f092
movq %rbx, %rdi
movl $0x1, %esi
callq 0x22d7b8
cmpl $0x1, %eax
jne 0x180eca
movq %rbx, %rdi
movl $0x1, %esi
callq 0x22db78
movl %eax, %ebp
testl %eax, %eax
je 0x180f13
leaq 0x252a09(%rip), %r8     # 0x3d3890
jmp 0x180f6d
movl $0x1, %esi
callq 0x230bcc
leaq 0x21c588(%rip), %rsi    # 0x39d425
movq %rbx, %rdi
callq 0x22e0c4
movq 0x58(%r14), %rsi
movq %rbx, %rdi
callq 0x22e0c4
leaq 0x260703(%rip), %rsi    # 0x3e15bb
movq %rbx, %rdi
callq 0x22e0c4
movq %rbx, %rdi
movl $0x4, %esi
jmp 0x180efc
leaq 0x21c554(%rip), %rsi    # 0x39d425
movq %rbx, %rdi
callq 0x22e0c4
movq 0x58(%r14), %rsi
movq %rbx, %rdi
callq 0x22e0c4
leaq 0x21a876(%rip), %rsi    # 0x39b762
movq %rbx, %rdi
callq 0x22e0c4
movq %rbx, %rdi
movl $0x3, %esi
callq 0x22f73e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x22f4f8
movq %rbx, %rdi
movl $0x2, %esi
callq 0x22d88c
testl %eax, %eax
je 0x180f92
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x22db9e
movq %rax, %r15
movq %rbx, %rdi
movl $0x1, %esi
callq 0x230bcc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22e0c4
movq %rbx, %rdi
movl $0x2, %esi
callq 0x22f73e
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x22db9e
movq %rax, %r8
xorl %ecx, %ecx
testl %ebp, %ebp
sete %cl
movq 0x68(%r14), %rdi
movq 0x48(%r14), %rdx
movq 0x50(%r14), %rsi
callq 0x17e342
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x5685b
nop