// File: /workspace/github_c_makefile_star2_O2/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/ldo.c
// Function: luaD_precall
int luaD_precall (lua_State *L, StkId func, int nresults) {
  lua_CFunction f;
  CallInfo *ci;
  int n;  /* number of arguments (Lua) or returns (C) */
  ptrdiff_t funcr = savestack(L, func);
  switch (ttype(func)) {
    case LUA_TLCF:  /* light C function */
      f = fvalue(func);
      goto Cfunc;
    case LUA_TCCL: {  /* C closure */
      f = clCvalue(func)->f;
     Cfunc:
      luaD_checkstack(L, LUA_MINSTACK);  /* ensure minimum stack size */
      ci = next_ci(L);  /* now 'enter' new function */
      ci->nresults = nresults;
      ci->func = restorestack(L, funcr);
      ci->top = L->top + LUA_MINSTACK;
      lua_assert(ci->top <= L->stack_last);
      ci->callstatus = 0;
      luaC_checkGC(L);  /* stack grow uses memory */
      if (L->hookmask & LUA_MASKCALL)
        luaD_hook(L, LUA_HOOKCALL, -1);
      lua_unlock(L);
      n = (*f)(L);  /* do the actual call */
      lua_lock(L);
      api_checknelems(L, n);
      luaD_poscall(L, L->top - n);
      return 1;
    }
    case LUA_TLCL: {  /* Lua function: prepare its call */
      StkId base;
      Proto *p = clLvalue(func)->p;
      n = cast_int(L->top - func) - 1;  /* number of real arguments */
      luaD_checkstack(L, p->maxstacksize);
      for (; n < p->numparams; n++)
        setnilvalue(L->top++);  /* complete missing arguments */
      if (!p->is_vararg) {
        func = restorestack(L, funcr);
        base = func + 1;
      }
      else {
        base = adjust_varargs(L, p, n);
        func = restorestack(L, funcr);  /* previous call can change stack */
      }
      ci = next_ci(L);  /* now 'enter' new function */
      ci->nresults = nresults;
      ci->func = func;
      ci->u.l.base = base;
      ci->top = base + p->maxstacksize;
      lua_assert(ci->top <= L->stack_last);
      ci->u.l.savedpc = p->code;  /* starting point */
      ci->callstatus = CIST_LUA;
      L->top = ci->top;
      luaC_checkGC(L);  /* stack grow uses memory */
      if (L->hookmask & LUA_MASKCALL)
        callhook(L, ci);
      return 0;
    }
    default: {  /* not a function */
      func = tryfuncTM(L, func);  /* retry with 'function' tag method */
      return luaD_precall(L, func, nresults);  /* now it must be a function */
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x8(%rsi), %eax
pushq $0x10
popq %r15
movq 0x38(%rbx), %r12
andl $0x3f, %eax
cmpl $0x6, %eax
je 0xb126
cmpl $0x16, %eax
je 0xb205
cmpl $0x26, %eax
je 0xb1fc
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x16978
movq %rax, %r12
movl 0x8(%rax), %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0xb375
movq 0x38(%rbx), %r13
movq 0x10(%rbx), %rax
cmpq %r14, %rax
jbe 0xb0e2
movq -0x10(%rax), %rcx
movq %rcx, (%rax)
movl -0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
addq $-0x10, %rax
jmp 0xb0ca
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
addq $0x10, %rax
movq %rax, 0x10(%rbx)
subq %rax, %rcx
cmpq $0xf, %rcx
jg 0xb105
movq %rbx, %rdi
xorl %esi, %esi
callq 0xaef2
subq %r13, %r14
movq 0x38(%rbx), %rcx
movq (%r12), %rax
movq %rax, (%rcx,%r14)
movl 0x8(%r12), %eax
movl %eax, 0x8(%rcx,%r14)
addq %rcx, %r14
jmp 0xb080
movl %ebp, 0x4(%rsp)
movq (%r14), %rax
movq 0x18(%rax), %r15
movq 0x10(%rbx), %rbp
movq 0x30(%rbx), %rax
subq %rbp, %rax
subq %r14, %rbp
shrq $0x4, %rbp
sarq $0x4, %rax
movzbl 0x7a(%r15), %esi
cmpq %rsi, %rax
jg 0xb159
movq %rbx, %rdi
callq 0xaef2
subq %r12, %r14
decl %ebp
movzbl 0x78(%r15), %r13d
movl %ebp, %eax
cmpl %r13d, %eax
jge 0xb17e
movq 0x10(%rbx), %rcx
leaq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rbx)
andl $0x0, 0x8(%rcx)
incl %eax
jmp 0xb165
cmpl %r13d, %ebp
cmovlel %r13d, %ebp
cmpb $0x0, 0x79(%r15)
je 0xb2b0
movq 0x10(%rbx), %r12
movq 0x30(%rbx), %rax
subq %r12, %rax
sarq $0x4, %rax
movzbl 0x7a(%r15), %esi
cmpq %rsi, %rax
jg 0xb1b5
movq %rbx, %rdi
callq 0xaef2
movq 0x10(%rbx), %r12
movl %ebp, %ecx
shlq $0x4, %rcx
movq %r12, %rax
subq %rcx, %rax
addq $0x8, %rax
shll $0x4, %r13d
xorl %ecx, %ecx
movl 0x4(%rsp), %ebp
cmpq %rcx, %r13
je 0xb2a7
movq 0x10(%rbx), %rdx
leaq 0x10(%rdx), %rsi
movq %rsi, 0x10(%rbx)
movq -0x8(%rax,%rcx), %rsi
movq %rsi, (%rdx)
movl (%rax,%rcx), %esi
movl %esi, 0x8(%rdx)
andl $0x0, (%rax,%rcx)
addq $0x10, %rcx
jmp 0xb1cf
movq (%r14), %rax
addq $0x18, %rax
jmp 0xb208
movq %r14, %rax
movq (%rax), %r15
movq 0x30(%rbx), %rax
subq 0x10(%rbx), %rax
cmpq $0x14f, %rax            # imm = 0x14F
jg 0xb226
pushq $0x14
popq %rsi
movq %rbx, %rdi
callq 0xaef2
subq %r12, %r14
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
jne 0xb23e
movq %rbx, %rdi
callq 0x130c0
movq %rax, 0x20(%rbx)
movw %bp, 0x20(%rax)
addq 0x38(%rbx), %r14
movq %r14, (%rax)
movl $0x140, %ecx            # imm = 0x140
addq 0x10(%rbx), %rcx
movq %rcx, 0x8(%rax)
movb $0x0, 0x22(%rax)
movq 0x18(%rbx), %rax
cmpq $0x0, 0x18(%rax)
jle 0xb271
movq %rbx, %rdi
callq 0xcd44
testb $0x1, 0x48(%rbx)
je 0xb284
pushq $-0x1
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xafb4
movq %rbx, %rdi
callq *%r15
movq 0x10(%rbx), %rsi
cltq
shlq $0x4, %rax
subq %rax, %rsi
movq %rbx, %rdi
callq 0xb387
pushq $0x1
popq %rbp
jmp 0xb364
addq 0x38(%rbx), %r14
movq %r14, %r13
jmp 0xb2c4
movq 0x38(%rbx), %rax
leaq (%rax,%r14), %r13
leaq (%rax,%r14), %r12
addq $0x10, %r12
movl 0x4(%rsp), %ebp
movq 0x20(%rbx), %rax
movq 0x18(%rax), %r14
testq %r14, %r14
jne 0xb2dc
movq %rbx, %rdi
callq 0x130c0
movq %rax, %r14
movq %r14, 0x20(%rbx)
movw %bp, 0x20(%r14)
movq %r13, (%r14)
movq %r12, 0x30(%r14)
movzbl 0x7a(%r15), %eax
shll $0x4, %eax
addq %r12, %rax
movq %rax, 0x8(%r14)
movq 0x18(%r15), %rcx
movq %rcx, 0x38(%r14)
movb $0x1, 0x22(%r14)
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rax
cmpq $0x0, 0x18(%rax)
jle 0xb31f
movq %rbx, %rdi
callq 0xcd44
xorl %ebp, %ebp
testb $0x1, 0x48(%rbx)
je 0xb364
addq $0x4, 0x38(%r14)
movq 0x10(%r14), %rax
xorl %ebp, %ebp
testb $0x1, 0x22(%rax)
movl $0x0, %esi
je 0xb354
movq 0x38(%rax), %rax
movl -0x4(%rax), %eax
andl $0x3f, %eax
cmpl $0x1e, %eax
jne 0xb354
orb $0x40, 0x22(%r14)
pushq $0x4
popq %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0xafb4
addq $-0x4, 0x38(%r14)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1525e(%rip), %rdx     # 0x205da
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa6bd