// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/mapping.c
// Function: gt_mapping_new
GtMapping* gt_mapping_new(GtStr *mapping_file, const char *global_name,
                          GtMappingType type, GtError *err)
{
  GtMapping *m;
  int had_err = 0;
  gt_error_check(err);
  gt_assert(mapping_file && global_name);
  /* alloc */
  m = gt_malloc(sizeof (GtMapping));
  m->mapping_file = gt_str_ref(mapping_file);
  m->global = gt_cstr_dup(global_name);
  m->type = type;
  /* create new lua state (i.e., interpreter) */
  m->L = luaL_newstate();
  if (!m->L) {
    gt_error_set(err, "out of memory (cannot create new Lua state)");
    had_err = -1;
  }
  /* load the standard libs into the Lua interpreter */
  if (!had_err) {
    luaL_openlibs(m->L);
    gt_assert(!lua_gettop(m->L));
  }
  /* try to load & run mapping file */
  if (!had_err) {
    if (luaL_loadfile(m->L, gt_str_get(mapping_file)) ||
        lua_pcall(m->L, 0, 0, 0)) {
      gt_error_set(err, "cannot run file: %s", lua_tostring(m->L, -1));
      had_err = -1;
      lua_pop(m->L, 1);
    }
  }
  /* make sure a global variable with name <global_name> is defined */
  if (!had_err) {
    lua_getglobal(m->L, global_name);
    if (lua_isnil(m->L, -1)) {
      gt_error_set(err, "'%s' is not defined in \"%s\"", global_name,
                gt_str_get(mapping_file));
      had_err = -1;
      lua_pop(m->L, 1);
    }
  }
  /* make sure it is either a table or a function */
  if (!had_err) {
    if (!(lua_istable(m->L, -1) || lua_isfunction(m->L, -1))) {
      gt_error_set(err, "'%s' must be either a table or a function (defined "
                     "in \"%s\")", global_name, gt_str_get(mapping_file));
      had_err = -1;
      lua_pop(m->L, 1);
    }
  }
  /* remember if it is a table or a function */
  if (!had_err) {
    if (lua_istable(m->L, -1))
      m->is_table = true;
    else
      m->is_table = false;
    lua_pop(m->L, 1);
  }
  /* return */
  gt_assert(!lua_gettop(m->L));
  if (had_err) {
    gt_mapping_delete(m);
    return NULL;
  }
  return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r12
testq %rcx, %rcx
je 0x48e73
movq %r14, %rdi
callq 0x3566a
testb %al, %al
jne 0x49050
testq %r12, %r12
je 0x49046
testq %r15, %r15
je 0x49046
leaq 0x9fc14(%rip), %rsi     # 0xe8aa0
movl $0x28, %edi
movl $0x2a, %edx
callq 0x35ee2
movq %rax, %rbx
movq %r12, %rdi
callq 0x3c561
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x722dc
movq %rax, 0x8(%rbx)
movl %ebp, 0x10(%rbx)
callq 0x5bfe8
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x48f4c
movq %rax, %rdi
callq 0x5c416
movq 0x18(%rbx), %rdi
callq 0x578c5
testl %eax, %eax
jne 0x49055
movq 0x18(%rbx), %r13
movq %r12, %rdi
callq 0x3c40b
movq %r13, %rdi
movq %rax, %rsi
callq 0x5bcaf
testl %eax, %eax
jne 0x48f15
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x59536
testl %eax, %eax
je 0x48fba
movq 0x18(%rbx), %rdi
xorl %r13d, %r13d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x58042
leaq 0x9fbe2(%rip), %rsi     # 0xe8b11
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3559f
movq 0x18(%rbx), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x578d2
jmp 0x48f60
leaq 0x9fb80(%rip), %rsi     # 0xe8ad3
xorl %r13d, %r13d
movq %r14, %rdi
xorl %eax, %eax
callq 0x3559f
testb %r13b, %r13b
je 0x48f88
movq 0x18(%rbx), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x57c5c
cmpl $0x5, %eax
sete 0x20(%rbx)
movq 0x18(%rbx), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x578d2
movq 0x18(%rbx), %rdi
callq 0x578c5
testl %eax, %eax
jne 0x4904b
testb %r13b, %r13b
jne 0x48fa8
movq %rbx, %rdi
callq 0x4905a
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
movq %r15, %rdx
callq 0x58b98
movq 0x18(%rbx), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x57c5c
testl %eax, %eax
je 0x4901f
movq 0x18(%rbx), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x57c5c
movb $0x1, %r13b
cmpl $0x5, %eax
je 0x48f60
movq 0x18(%rbx), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x57c5c
cmpl $0x6, %eax
je 0x48f60
movq %r12, %rdi
callq 0x3c40b
leaq 0x9fb24(%rip), %rsi     # 0xe8b41
jmp 0x4902e
movq %r12, %rdi
callq 0x3c40b
leaq 0x9faf7(%rip), %rsi     # 0xe8b25
xorl %r13d, %r13d
movq %r14, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x3559f
jmp 0x48f3c
callq 0x135c3
callq 0x13631
callq 0x1358c
callq 0x135fa