// File: /workspace/github_c_makefile_star2_O2/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 0x21681c(%rip), %rdx    # 0x333d68
pushq $0x1
popq %rsi
callq 0x1dea4f
movq (%rax), %rdi
callq 0xdc2f0
testq %rax, %rax
jne 0x11d573
leaq 0x216890(%rip), %rdx    # 0x333df8
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1de6f4
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1de9c6
movq %rax, %rdi
callq 0xaed4b
movq %rax, %r15
leaq 0x31bc16(%rip), %rsi    # 0x4391a8
movq %rbx, %rdi
callq 0x1dc4ec
movq %rbx, %rdi
movl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
callq 0x1dc524
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0x1dbd9e
movq %rax, %r12
testb %bpl, %bpl
je 0x11d5e8
movq 0x28(%r12), %rdi
testq %rdi, %rdi
je 0x11d69d
movq %r15, %rsi
callq 0x12a6ec
testb %al, %al
jne 0x11d5f1
leaq 0x216884(%rip), %rdx    # 0x333e5f
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x1de6f4
jmp 0x11d5f1
testq %r12, %r12
je 0x11d6d8
movq 0x60(%r12), %rdi
testq %rdi, %rdi
je 0x11d6d8
callq 0x586a4
xorl %esi, %esi
testq %rax, %rax
je 0x11d683
movq 0x60(%r12), %rdi
callq 0x586a4
movq %rax, %r14
decq %r14
cmpq $-0x1, %r14
je 0x11d681
movq 0x60(%r12), %rdi
movq %r14, %rsi
callq 0x581aa
movq (%rax), %rdi
testq %rdi, %rdi
je 0x11d618
testb %bpl, %bpl
je 0x11d672
cmpq $0x0, 0x28(%r12)
je 0x11d672
callq 0xda338
movq %rax, %r13
movq 0x28(%r12), %rdi
movq %rax, %rsi
callq 0x12a6ec
testb %al, %al
je 0x11d618
movq 0x28(%r12), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x12a7e3
testb %al, %al
je 0x11d618
jmp 0x11d67c
callq 0xda338
cmpq %r15, %rax
jne 0x11d618
pushq $0x1
popq %rsi
jmp 0x11d683
xorl %esi, %esi
movq %rbx, %rdi
callq 0x1dc4d2
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1de895
leaq 0x21675c(%rip), %rsi    # 0x333e0b
movq %rbx, %rdi
callq 0x1dc009
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x1dd50a
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1dd306
movq 0x31a889(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1c792a(%rip), %rsi    # 0x2e5013
leaq 0x216783(%rip), %rdx    # 0x333e73
leaq 0x216794(%rip), %rcx    # 0x333e8b
leaq 0x2164e8(%rip), %r8     # 0x333be6
movl $0x282, %r9d            # imm = 0x282
xorl %eax, %eax
callq 0x17a50
callq 0x17390