// File: /workspace/github_c_makefile_star2_O1/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 0x21c2bb(%rip), %rdx    # 0x39ce87
movl $0x1, %esi
callq 0x230dae
movq (%rax), %rdi
callq 0x14aefc
testq %rax, %rax
jne 0x180bf7
leaq 0x21c32d(%rip), %rdx    # 0x39cf17
movq %rbx, %rdi
movl $0x1, %esi
callq 0x230a08
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x230d0f
movq %rax, %rdi
callq 0x12234f
movq %rax, %r14
leaq 0x3445e0(%rip), %rsi    # 0x4c51f8
movq %rbx, %rdi
callq 0x22e58a
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x22e5c2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x22de0e
movq %rax, %r15
testb %bpl, %bpl
je 0x180c6f
movq 0x28(%r15), %rdi
testq %rdi, %rdi
je 0x180d3e
movq %r14, %rsi
callq 0x18b801
testb %al, %al
jne 0x180c6f
leaq 0x21c31c(%rip), %rdx    # 0x39cf7e
movq %rbx, %rdi
movl $0x2, %esi
callq 0x230a08
testq %r15, %r15
je 0x180d7d
movq 0x60(%r15), %rdi
testq %rdi, %rdi
je 0x180d7d
callq 0xd4a9a
xorl %r13d, %r13d
testq %rax, %rax
je 0x180d1f
movq 0x60(%r15), %rdi
callq 0xd4a9a
testq %rax, %rax
je 0x180d1f
movq %rax, %r12
decq %r12
xorl %r13d, %r13d
movq 0x60(%r15), %rdi
movq %r12, %rsi
callq 0xd47ba
movq (%rax), %rdi
testq %rdi, %rdi
je 0x180d0a
testb %bpl, %bpl
je 0x180cf9
cmpq $0x0, 0x28(%r15)
je 0x180cf9
callq 0x149bb2
movq %rax, %r13
movq 0x28(%r15), %rdi
movq %rax, %rsi
callq 0x18b801
testb %al, %al
je 0x180d12
movq 0x28(%r15), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x18b865
movl %eax, %r13d
jmp 0x180d05
callq 0x149bb2
cmpq %r14, %rax
sete %r13b
testb %r13b, %r13b
jne 0x180d17
addq $-0x1, %r12
jb 0x180cad
jmp 0x180d17
xorl %r13d, %r13d
jmp 0x180d05
andb $0x1, %r13b
movzbl %r13b, %r13d
movq %rbx, %rdi
movl %r13d, %esi
callq 0x22e570
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x1, %esi
callq 0x230bcc
leaq 0x21c1d8(%rip), %rsi    # 0x39cf2a
movq %rbx, %rdi
callq 0x22e0c4
movq %rbx, %rdi
movl $0x2, %esi
callq 0x22f73e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22f4f8
callq 0x56822