// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x31ba86(%rip), %rsi    # 0x4391a8
callq 0x1dc4ec
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x1dc524
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0x1dbd9e
movq %rax, %r14
leaq 0x216bb4(%rip), %rdx    # 0x3342fd
movq %rbx, %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x1dc63b
movq 0x58(%r14), %rsi
movq %rbx, %rdi
callq 0x1dc009
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x1dc524
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1db4fe
movl 0x40(%r14), %edx
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x1dc73a
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x1db4fe
movl 0x40(%r14), %edx
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x1df29e
pushq $-0x3
popq %rsi
movq %rbx, %rdi
callq 0x1db3d2
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1db731
cmpl $0x6, %eax
jne 0x11d80a
movq %rbx, %rdi
callq 0x1db3c5
leal -0x1(%rax), %esi
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x1dcedd
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1db731
cmpl $0x1, %eax
jne 0x11d843
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1dbb4f
movl %eax, %ebp
testl %eax, %eax
je 0x11d888
leaq 0x24cd6b(%rip), %r8     # 0x36a570
jmp 0x11d8dc
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1de895
leaq 0x216aea(%rip), %rsi    # 0x334306
movq %rbx, %rdi
callq 0x1dc009
movq 0x58(%r14), %rsi
movq %rbx, %rdi
callq 0x1dc009
leaq 0x25aa4f(%rip), %rsi    # 0x378286
movq %rbx, %rdi
callq 0x1dc009
pushq $0x4
jmp 0x11d86f
leaq 0x216abc(%rip), %rsi    # 0x334306
movq %rbx, %rdi
callq 0x1dc009
movq 0x58(%r14), %rsi
movq %rbx, %rdi
callq 0x1dc009
leaq 0x214e1d(%rip), %rsi    # 0x332682
movq %rbx, %rdi
callq 0x1dc009
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x1dd50a
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1dd306
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x1db803
testl %eax, %eax
je 0x11d8ff
pushq $0x2
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x1dbb73
movq %rax, %r12
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1de895
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1dc009
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1dd50a
pushq $-0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1dbb73
movq %rax, %r8
xorl %ecx, %ecx
testl %ebp, %ebp
sete %cl
movq 0x68(%r14), %rdi
movq 0x48(%r14), %rdx
movq 0x50(%r14), %rsi
callq 0x11a7c0
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x31a662(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1c7703(%rip), %rsi    # 0x2e5013
leaq 0x2169f9(%rip), %rdx    # 0x334310
leaq 0x216a05(%rip), %rcx    # 0x334323
leaq 0x2162c1(%rip), %r8     # 0x333be6
movl $0x1fb, %r9d            # imm = 0x1FB
xorl %eax, %eax
callq 0x17a50
callq 0x17390
nop