// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/spec_visitor.c
// Function: spec_feature_node_lua_appears_as_child_of_type_g
static int spec_feature_node_lua_appears_as_child_of_type_g(lua_State *L,
                                                            bool supertype)
{
  GtGenomeNode **gn;
  GtFeatureNode *fn, *fn2;
  bool found = false;
  GtSpecVisitor *sv;
  const char *type;
  GtUword i;
  gn = check_genome_node(L, 1);
  /* make sure we get a feature node */
  fn = gt_feature_node_try_cast(*gn);
  luaL_argcheck(L, fn, 1, "not a feature node");
  type = gt_symbol(luaL_checkstring(L, 2));

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

  if (supertype) {
    if (!sv->type_checker) {
      luaL_where(L, 1);
      lua_pushstring(L, "'feature_node.appears_as_child_of_supertype()' "
                        "requires a type checker (-typecheck)");
      lua_concat(L, 2);
      return lua_error(L);
    }
    luaL_argcheck(L, gt_type_checker_is_valid(sv->type_checker, type),
                  2, "not a valid SO type");
  }

  gt_assert(sv && sv->graph_context);
  if (gt_array_size(sv->graph_context) > 0) {
    for (i = gt_array_size(sv->graph_context) - 1; i + 1 > 0; i--) {
      fn2 = *(GtFeatureNode**) gt_array_get(sv->graph_context, i);
      if (!fn2) continue;
      if (supertype && sv->type_checker) {
        const char *fn2t = gt_feature_node_get_type(fn2);
        if (gt_type_checker_is_valid(sv->type_checker, fn2t))
          found = gt_type_checker_is_a(sv->type_checker, type, fn2t);
        else
          found = false;
      } else
        found = (gt_feature_node_get_type(fn2) == type);
      if (found)
        break;
    }
  }
  lua_pushboolean(L, found);
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x21b2f5(%rip), %rdx    # 0x3939f9
movl $0x1, %esi
callq 0x22712c
movq (%rax), %rdi
callq 0x143cab
testq %rax, %rax
jne 0x17872f
leaq 0x21b367(%rip), %rdx    # 0x393a89
movq %rbx, %rdi
movl $0x1, %esi
callq 0x226d91
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x22708d
movq %rax, %rdi
callq 0x11c5ff
movq %rax, %r14
leaq 0x341aa8(%rip), %rsi    # 0x4ba1f8
movq %rbx, %rdi
callq 0x2248bd
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x2248f5
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x224118
movq %rax, %r15
testb %bpl, %bpl
je 0x1787a9
movq 0x28(%r15), %rdi
testq %rdi, %rdi
je 0x17884a
movq %r14, %rsi
callq 0x1830f1
testb %al, %al
jne 0x1787b2
leaq 0x21b356(%rip), %rdx    # 0x393af0
movq %rbx, %rdi
movl $0x2, %esi
callq 0x226d91
jmp 0x1787b2
testq %r15, %r15
je 0x1788ae
movq 0x60(%r15), %rdi
testq %rdi, %rdi
je 0x1788ae
callq 0xd24e0
xorl %r12d, %r12d
testq %rax, %rax
je 0x17888f
movq 0x60(%r15), %rdi
callq 0xd24e0
testq %rax, %rax
je 0x17888f
movq %rax, %r13
decq %r13
movq 0x60(%r15), %rdi
movq %r13, %rsi
callq 0xd2207
movq (%rax), %rdi
testq %rdi, %rdi
je 0x17883f
testb %bpl, %bpl
je 0x178835
cmpq $0x0, 0x28(%r15)
je 0x178835
callq 0x142988
movq %rax, %r12
movq 0x28(%r15), %rdi
movq %rax, %rsi
callq 0x1830f1
testb %al, %al
je 0x17883f
movq 0x28(%r15), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x183155
testb %al, %al
je 0x17883f
jmp 0x178889
callq 0x142988
cmpq %r14, %rax
je 0x178889
addq $-0x1, %r13
jb 0x1787e8
xorl %r12d, %r12d
jmp 0x17888f
movq %rbx, %rdi
movl $0x1, %esi
callq 0x226f4a
leaq 0x21b23e(%rip), %rsi    # 0x393a9c
movq %rbx, %rdi
callq 0x2243ba
movq %rbx, %rdi
movl $0x2, %esi
callq 0x225a4f
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x225800
movl $0x1, %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2248a3
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5568b