// File: /workspace/github_c_makefile_star2_O0/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lapi.c
// Function: lua_pcallk
LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
                        int ctx, lua_CFunction k) {
  struct CallS c;
  int status;
  ptrdiff_t func;
  lua_lock(L);
  api_check(L, k == NULL || !isLua(L->ci),
    "cannot use continuations inside hooks");
  api_checknelems(L, nargs+1);
  api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
  checkresults(L, nargs, nresults);
  if (errfunc == 0)
    func = 0;
  else {
    StkId o = index2addr(L, errfunc);
    api_checkstackindex(L, errfunc, o);
    func = savestack(L, o);
  }
  c.func = L->top - (nargs+1);  /* function to be called */
  if (k == NULL || L->nny > 0) {  /* no continuation or no yieldable? */
    c.nresults = nresults;  /* do a 'conventional' protected call */
    status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
  }
  else {  /* prepare continuation (call is already protected by 'resume') */
    CallInfo *ci = L->ci;
    ci->u.c.k = k;  /* save continuation */
    ci->u.c.ctx = ctx;  /* save context */
    /* save information for error recovery */
    ci->extra = savestack(L, c.func);
    ci->u.c.old_allowhook = L->allowhook;
    ci->u.c.old_errfunc = L->errfunc;
    L->errfunc = func;
    /* mark that function may do error recovery */
    ci->callstatus |= CIST_YPCALL;
    luaD_call(L, c.func, nresults, 1);  /* do the call */
    ci->callstatus &= ~CIST_YPCALL;
    L->errfunc = ci->u.c.old_errfunc;
    status = LUA_OK;  /* if it is here, there were no errors */
  }
  adjustresults(L, nresults);
  lua_unlock(L);
  return status;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movl %esi, 0x4c(%rsp)
movl %edx, 0x48(%rsp)
movl %ecx, 0x44(%rsp)
movl %r8d, 0x40(%rsp)
movq %r9, 0x38(%rsp)
cmpl $0x0, 0x44(%rsp)
jne 0xb1f1
movq $0x0, 0x18(%rsp)
jmp 0xb21a
movq 0x50(%rsp), %rdi
movl 0x44(%rsp), %esi
callq 0x8f90
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0x50(%rsp), %rcx
movq 0x38(%rcx), %rcx
subq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x4c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0xb254
movq 0x50(%rsp), %rax
movzwl 0x44(%rax), %eax
cmpl $0x0, %eax
jle 0xb291
movl 0x48(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x50(%rsp), %rdi
movq 0x28(%rsp), %rcx
movq 0x50(%rsp), %rax
movq 0x38(%rax), %rax
subq %rax, %rcx
movq 0x18(%rsp), %r8
leaq 0x122(%rip), %rsi       # 0xb3a0
leaq 0x28(%rsp), %rdx
callq 0x115f0
movl %eax, 0x24(%rsp)
jmp 0xb353
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x38(%rax)
movl 0x40(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x30(%rax)
movq 0x28(%rsp), %rcx
movq 0x50(%rsp), %rax
movq 0x38(%rax), %rax
subq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x50(%rsp), %rax
movb 0x49(%rax), %cl
movq 0x8(%rsp), %rax
movb %cl, 0x48(%rax)
movq 0x50(%rsp), %rax
movq 0x78(%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x18(%rsp), %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x78(%rax)
movq 0x8(%rsp), %rax
movzbl 0x22(%rax), %ecx
orl $0x10, %ecx
movb %cl, 0x22(%rax)
movq 0x50(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x48(%rsp), %edx
movl $0x1, %ecx
callq 0x10e90
movq 0x8(%rsp), %rax
movzbl 0x22(%rax), %ecx
andl $-0x11, %ecx
movb %cl, 0x22(%rax)
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x78(%rax)
movl $0x0, 0x24(%rsp)
cmpl $-0x1, 0x48(%rsp)
jne 0xb388
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq 0x50(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xb388
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x8(%rax)
movl 0x24(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)