// File: /workspace/github_c_makefile_star2_O1/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
movq %r14, %r15
subq 0x38(%rbx), %r15
movl 0x8(%r14), %eax
andl $0x3f, %eax
cmpl $0x6, %eax
je 0xb6bf
cmpl $0x16, %eax
je 0xb710
cmpl $0x26, %eax
je 0xb709
movq %rbx, %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x18170
movq %rax, %r15
movl 0x8(%rax), %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0xb913
movq 0x38(%rbx), %r12
movq 0x10(%rbx), %rax
cmpq %r14, %rax
jbe 0xb67d
movq -0x10(%rax), %rcx
movq %rcx, (%rax)
movl -0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
leaq -0x10(%rax), %rcx
movq %rcx, %rax
cmpq %r14, %rcx
ja 0xb664
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
addq $0x10, %rax
movq %rax, 0x10(%rbx)
subq %rax, %rcx
cmpq $0xf, %rcx
jg 0xb6a0
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb483
subq %r12, %r14
movq 0x38(%rbx), %rax
movq (%r15), %rcx
movq %rcx, (%rax,%r14)
movl 0x8(%r15), %ecx
movl %ecx, 0x8(%rax,%r14)
addq %rax, %r14
jmp 0xb60c
movl %ebp, 0x4(%rsp)
movq (%r14), %rax
movq 0x18(%rax), %r12
movq 0x10(%rbx), %rbp
movq 0x30(%rbx), %rax
subq %rbp, %rax
subq %r14, %rbp
shrq $0x4, %rbp
sarq $0x4, %rax
movzbl 0x7a(%r12), %esi
cmpq %rsi, %rax
jg 0xb6f3
movq %rbx, %rdi
callq 0xb483
movzbl 0x78(%r12), %r14d
cmpl %r14d, %ebp
jle 0xb7b2
decl %ebp
jmp 0xb7d3
movq (%r14), %r14
addq $0x18, %r14
movq (%r14), %r14
movq 0x30(%rbx), %rax
subq 0x10(%rbx), %rax
cmpq $0x14f, %rax            # imm = 0x14F
jg 0xb730
movq %rbx, %rdi
movl $0x14, %esi
callq 0xb483
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
jne 0xb745
movq %rbx, %rdi
callq 0x14328
movq %rax, 0x20(%rbx)
movw %bp, 0x20(%rax)
addq 0x38(%rbx), %r15
movq %r15, (%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 0xb778
movq %rbx, %rdi
callq 0xd66d
testb $0x1, 0x48(%rbx)
je 0xb78d
movq %rbx, %rdi
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xb549
movq %rbx, %rdi
callq *%r14
movq 0x10(%rbx), %rsi
cltq
shlq $0x4, %rax
subq %rax, %rsi
movq %rbx, %rdi
callq 0xb925
movl $0x1, %ebp
jmp 0xb902
movq 0x10(%rbx), %rax
movl %r14d, %ecx
subl %ebp, %ecx
incl %ecx
movl $0x0, 0x8(%rax)
addq $0x10, %rax
decl %ecx
jne 0xb7bd
movq %rax, 0x10(%rbx)
movl %r14d, %ebp
cmpb $0x0, 0x79(%r12)
je 0xb849
movq 0x30(%rbx), %rax
subq 0x10(%rbx), %rax
sarq $0x4, %rax
movzbl 0x7a(%r12), %esi
cmpq %rsi, %rax
jg 0xb7fa
movq %rbx, %rdi
callq 0xb483
movq 0x10(%rbx), %r13
testl %r14d, %r14d
je 0xb843
movl %ebp, %ecx
shll $0x4, %r14d
shlq $0x4, %rcx
movq %r13, %rax
subq %rcx, %rax
addq $0x8, %rax
xorl %ecx, %ecx
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)
movl $0x0, (%rax,%rcx)
addq $0x10, %rcx
cmpq %rcx, %r14
jne 0xb819
addq 0x38(%rbx), %r15
jmp 0xb858
movq 0x38(%rbx), %rax
leaq (%rax,%r15), %r13
addq $0x10, %r13
addq %rax, %r15
movq 0x20(%rbx), %rax
movq 0x18(%rax), %r14
testq %r14, %r14
movl 0x4(%rsp), %ebp
jne 0xb874
movq %rbx, %rdi
callq 0x14328
movq %rax, %r14
movq %r14, 0x20(%rbx)
movw %bp, 0x20(%r14)
movq %r15, (%r14)
movq %r13, 0x30(%r14)
movzbl 0x7a(%r12), %eax
shll $0x4, %eax
addq %r13, %rax
movq %rax, 0x8(%r14)
movq 0x18(%r12), %rcx
movq %rcx, 0x38(%r14)
movb $0x1, 0x22(%r14)
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rax
cmpq $0x0, 0x18(%rax)
jle 0xb8b9
movq %rbx, %rdi
callq 0xd66d
xorl %ebp, %ebp
testb $0x1, 0x48(%rbx)
je 0xb902
addq $0x4, 0x38(%r14)
movq 0x10(%r14), %rax
xorl %ebp, %ebp
testb $0x1, 0x22(%rax)
movl $0x0, %esi
je 0xb8f0
movq 0x38(%rax), %rax
movl -0x4(%rax), %eax
andl $0x3f, %eax
cmpl $0x1e, %eax
jne 0xb8f0
orb $0x40, 0x22(%r14)
movl $0x4, %esi
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xb549
addq $-0x4, 0x38(%r14)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16cd0(%rip), %rdx     # 0x225ea
movq %rbx, %rdi
movq %r14, %rsi
callq 0xab63