// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4(%rsp), %r15
movq %r15, %rsi
callq 0x1a58f
movq %rax, %r14
movl (%r15), %r15d
leal 0x1(%r15), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x608f
testl %eax, %eax
movl %ebp, (%rsp)
jle 0x1a2b0
leal 0x2(%r15), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x14fff
movq %rax, %r12
movq %rbx, %rdi
movl %ebp, %esi
movl $0x6, %edx
callq 0x15039
addl $0x3, %r15d
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x1518f
movq %rax, %rbp
movq %r12, %rdi
movl $0x63, %esi
callq 0x5160
xorl %r13d, %r13d
testq %rax, %rax
setne %r13b
movq %r12, %rdi
movl $0x72, %esi
callq 0x5160
leal 0x2(%r13), %r15d
testq %rax, %rax
cmovel %r13d, %r15d
movq %r12, %rdi
movl $0x6c, %esi
callq 0x5160
leal 0x4(%r15), %ecx
testq %rax, %rax
cmovel %r15d, %ecx
leal 0x8(%rcx), %r12d
testl %ebp, %ebp
cmovlel %ecx, %r12d
leaq 0x327(%rip), %r13       # 0x1a5d5
jmp 0x1a2c2
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5d4d
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r12d, %r12d
leaq 0x9bd7(%rip), %rdx      # 0x23ea0
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x69ae
testl %eax, %eax
jne 0x1a347
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x69fb
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x606b
leaq 0x9ba3(%rip), %rdx      # 0x23ea0
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x6e10
leaq 0x880f(%rip), %rsi      # 0x22b20
movq %rbx, %rdi
callq 0x656b
leaq 0x8a39(%rip), %rdx      # 0x22d59
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6c66
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x606b
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6e85
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x1a65e
movq %r14, %rdi
callq 0x6753
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x5ca7
movq %rbx, %rdi
movl (%rsp), %esi
callq 0x606b
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x6d43
movq %r14, %rdi
movq %r13, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x769c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq