// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movl %edx, 0x4c(%rsp)
movq %rcx, 0x40(%rsp)
movl $0x0, 0x34(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0x32e9f
movq 0x40(%rsp), %rdi
callq 0xc270
testb $0x1, %al
jne 0x32e67
jmp 0x32e9f
movq 0x18116a(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0x12b1ee(%rip), %rsi    # 0x15e066
leaq 0x12b7c9(%rip), %rdx    # 0x15e648
leaq 0x132d45(%rip), %rcx    # 0x165bcb
leaq 0x132d4d(%rip), %r8     # 0x165bda
movl $0x27, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x32ea1
jmp 0x32ea3
cmpq $0x0, 0x58(%rsp)
je 0x32eb3
cmpq $0x0, 0x50(%rsp)
jne 0x32eeb
movq 0x18111e(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0x12b1a2(%rip), %rsi    # 0x15e066
leaq 0x132d26(%rip), %rdx    # 0x165bf1
leaq 0x132cf9(%rip), %rcx    # 0x165bcb
leaq 0x132d01(%rip), %r8     # 0x165bda
movl $0x28, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x32eed
movl $0x28, %edi
leaq 0x132ce1(%rip), %rsi    # 0x165bda
movl $0x2a, %edx
callq 0xd2e0
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rdi
callq 0x19dc0
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movq 0x50(%rsp), %rdi
callq 0x7c400
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x8(%rax)
movl 0x4c(%rsp), %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x10(%rax)
callq 0x56d80
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x32f77
movq 0x40(%rsp), %rdi
leaq 0x132ca5(%rip), %rsi    # 0x165c0d
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x34(%rsp)
jne 0x32fdb
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x57330
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x4f0e0
cmpl $0x0, %eax
je 0x32fd7
movq 0x181032(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0x12b0b6(%rip), %rsi    # 0x15e066
leaq 0x132c82(%rip), %rdx    # 0x165c39
leaq 0x132c0d(%rip), %rcx    # 0x165bcb
leaq 0x132c15(%rip), %r8     # 0x165bda
movl $0x37, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x32fd9
jmp 0x32fdb
cmpl $0x0, 0x34(%rsp)
jne 0x3307d
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %rdi
callq 0x19940
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x56860
cmpl $0x0, %eax
jne 0x33029
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x527f0
cmpl $0x0, %eax
je 0x3307b
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x50180
movq 0x20(%rsp), %rdi
movq %rax, %rdx
leaq 0x132bf2(%rip), %rsi    # 0x165c4b
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4f100
jmp 0x3307d
cmpl $0x0, 0x34(%rsp)
jne 0x3310e
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x50(%rsp), %rdx
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x51640
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4f800
cmpl $0x0, %eax
jne 0x3310c
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rdi
callq 0x19940
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
leaq 0x132b75(%rip), %rsi    # 0x165c5f
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4f100
jmp 0x3310e
cmpl $0x0, 0x34(%rsp)
jne 0x3319d
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4f800
cmpl $0x5, %eax
je 0x3319b
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4f800
cmpl $0x6, %eax
je 0x3319b
movq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rdi
callq 0x19940
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
movq %rax, %rcx
leaq 0x132b02(%rip), %rsi    # 0x165c7b
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4f100
jmp 0x3319d
cmpl $0x0, 0x34(%rsp)
jne 0x331e3
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4f800
cmpl $0x5, %eax
jne 0x331c7
movq 0x38(%rsp), %rax
movb $0x1, 0x20(%rax)
jmp 0x331d0
movq 0x38(%rsp), %rax
movb $0x0, 0x20(%rax)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4f100
jmp 0x331e5
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x4f0e0
cmpl $0x0, %eax
je 0x33230
movq 0x180dd9(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0x12ae5d(%rip), %rsi    # 0x15e066
leaq 0x132a29(%rip), %rdx    # 0x165c39
leaq 0x1329b4(%rip), %rcx    # 0x165bcb
leaq 0x1329bc(%rip), %r8     # 0x165bda
movl $0x5e, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x33232
cmpl $0x0, 0x34(%rsp)
je 0x3324e
movq 0x38(%rsp), %rdi
callq 0x33270
movq $0x0, 0x60(%rsp)
jmp 0x33258
movq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)