// File: /workspace/github_c_makefile_star2_O0/tylerneylon[P]APIsWithLua/lua/ldblib.c
// Function: db_sethook
static int db_sethook (lua_State *L) {
  int arg, mask, count;
  lua_Hook func;
  lua_State *L1 = getthread(L, &arg);
  if (lua_isnoneornil(L, arg+1)) {  /* no hook? */
    lua_settop(L, arg+1);
    func = NULL; mask = 0; count = 0;  /* turn off hooks */
  }
  else {
    const char *smask = luaL_checkstring(L, arg+2);
    luaL_checktype(L, arg+1, LUA_TFUNCTION);
    count = (int)luaL_optinteger(L, arg + 3, 0);
    func = hookf; mask = makemask(smask, count);
  }
  if (lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY) == LUA_TNIL) {
    lua_createtable(L, 0, 2);  /* create a hook table */
    lua_pushvalue(L, -1);
    lua_rawsetp(L, LUA_REGISTRYINDEX, &HOOKKEY);  /* set it in position */
    lua_pushstring(L, "k");
    lua_setfield(L, -2, "__mode");  /** hooktable.__mode = "k" */
    lua_pushvalue(L, -1);
    lua_setmetatable(L, -2);  /* setmetatable(hooktable) = hooktable */
  }
  checkstack(L, L1, 1);
  lua_pushthread(L1); lua_xmove(L1, L, 1);  /* key (thread) */
  lua_pushvalue(L, arg + 1);  /* value (hook function) */
  lua_rawset(L, -3);  /* hooktable[L1] = new Lua hook */
  lua_sethook(L1, func, mask, count);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0x28a70
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x1, %esi
callq 0x61f0
cmpl $0x0, %eax
jg 0x28698
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x1, %esi
callq 0x5dc0
movq $0x0, -0x20(%rbp)
movl $0x0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
jmp 0x286f3
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x20390
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x1, %esi
movl $0x6, %edx
callq 0x203e0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x205e0
movl %eax, -0x14(%rbp)
leaq 0x3f0(%rip), %rax       # 0x28ad0
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x28eb0
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
leaq 0xde8d(%rip), %rdx      # 0x36590
callq 0x7540
cmpl $0x0, %eax
jne 0x28781
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x75e0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x6190
movq -0x8(%rbp), %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
leaq 0xde55(%rip), %rdx      # 0x36590
callq 0x7e10
movq -0x8(%rbp), %rdi
leaq 0xc711(%rip), %rsi      # 0x34e5c
callq 0x6ce0
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xca01(%rip), %rdx      # 0x35161
callq 0x7ae0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x6190
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7ef0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0x28b70
movq -0x28(%rbp), %rdi
callq 0x7050
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl $0x1, %edx
callq 0x5c20
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x1, %esi
callq 0x6190
movq -0x8(%rbp), %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x7c90
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
callq 0x8f70
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)