// File: /workspace/github_c_makefile_star2_O3/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
movq 0x38(%rbx), %r15
andl $0x3f, %eax
cmpl $0x6, %eax
je 0xb7cb
cmpl $0x16, %eax
je 0xb81e
cmpl $0x26, %eax
je 0xb815
movq %rbx, %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x18224
movq %rax, %r15
movl 0x8(%rax), %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0xba38
movq 0x38(%rbx), %r12
movq 0x10(%rbx), %rax
cmpq %r14, %rax
jbe 0xb78d
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 0xb770
movq 0x10(%rbx), %rax
addq $0x10, %rax
movq %rax, 0x10(%rbx)
movq 0x30(%rbx), %rcx
subq %rax, %rcx
cmpq $0xf, %rcx
jg 0xb7ac
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb58f
subq %r12, %r14
movq 0x38(%rbx), %rcx
movq (%r15), %rax
movq %rax, (%rcx,%r14)
movl 0x8(%r15), %eax
movl %eax, 0x8(%rcx,%r14)
addq %rcx, %r14
jmp 0xb71f
movq (%r14), %rax
movq 0x18(%rax), %rdi
movq 0x10(%rbx), %r12
movq 0x30(%rbx), %rax
subq %r12, %rax
subq %r14, %r12
shrq $0x4, %r12
sarq $0x4, %rax
movzbl 0x7a(%rdi), %esi
cmpq %rsi, %rax
jg 0xb7ff
movq %rdi, %r13
movq %rbx, %rdi
callq 0xb58f
movq %r13, %rdi
movzbl 0x78(%rdi), %r13d
cmpl %r13d, %r12d
jle 0xb8c6
decl %r12d
jmp 0xb8e8
movq (%r14), %rax
addq $0x18, %rax
jmp 0xb821
movq %r14, %rax
movq (%rax), %r12
movq 0x30(%rbx), %rax
subq 0x10(%rbx), %rax
cmpq $0x14f, %rax            # imm = 0x14F
jg 0xb841
movq %rbx, %rdi
movl $0x14, %esi
callq 0xb58f
subq %r15, %r14
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
jne 0xb859
movq %rbx, %rdi
callq 0x14430
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 0xb88c
movq %rbx, %rdi
callq 0xd766
testb $0x1, 0x48(%rbx)
je 0xb8a1
movq %rbx, %rdi
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xb655
movq %rbx, %rdi
callq *%r12
movq 0x10(%rbx), %rsi
cltq
shlq $0x4, %rax
subq %rax, %rsi
movq %rbx, %rdi
callq 0xba4a
movl $0x1, %ebp
jmp 0xba27
movq 0x10(%rbx), %rax
movl %r13d, %ecx
subl %r12d, %ecx
incl %ecx
movl $0x0, 0x8(%rax)
addq $0x10, %rax
decl %ecx
jne 0xb8d2
movq %rax, 0x10(%rbx)
movl %r13d, %r12d
movl %ebp, 0x4(%rsp)
subq %r15, %r14
cmpb $0x0, 0x79(%rdi)
je 0xb96b
movzbl 0x7a(%rdi), %esi
movq 0x10(%rbx), %rbp
movq 0x30(%rbx), %rax
subq %rbp, %rax
sarq $0x4, %rax
cmpq %rsi, %rax
jg 0xb91f
movq %rdi, %r15
movq %rbx, %rdi
callq 0xb58f
movq %r15, %rdi
movq 0x10(%rbx), %rbp
testl %r13d, %r13d
je 0xb965
movl %r12d, %ecx
shll $0x4, %r13d
shlq $0x4, %rcx
movq %rbp, %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, %r13
jne 0xb93b
addq 0x38(%rbx), %r14
jmp 0xb97a
movq 0x38(%rbx), %rax
leaq (%rax,%r14), %rbp
addq $0x10, %rbp
addq %rax, %r14
movq 0x20(%rbx), %rax
movq 0x18(%rax), %r15
testq %r15, %r15
jne 0xb998
movq %rdi, %r15
movq %rbx, %rdi
callq 0x14430
movq %r15, %rdi
movq %rax, %r15
movq %r15, 0x20(%rbx)
movl 0x4(%rsp), %eax
movw %ax, 0x20(%r15)
movq %r14, (%r15)
movq %rbp, 0x30(%r15)
movzbl 0x7a(%rdi), %eax
shll $0x4, %eax
addq %rbp, %rax
movq %rax, 0x8(%r15)
movq 0x18(%rdi), %rcx
movq %rcx, 0x38(%r15)
movb $0x1, 0x22(%r15)
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rax
cmpq $0x0, 0x18(%rax)
jle 0xb9de
movq %rbx, %rdi
callq 0xd766
xorl %ebp, %ebp
testb $0x1, 0x48(%rbx)
je 0xba27
addq $0x4, 0x38(%r15)
movq 0x10(%r15), %rax
xorl %ebp, %ebp
testb $0x1, 0x22(%rax)
movl $0x0, %esi
je 0xba15
movq 0x38(%rax), %rax
movl -0x4(%rax), %eax
andl $0x3f, %eax
cmpl $0x1e, %eax
jne 0xba15
orb $0x40, 0x22(%r15)
movl $0x4, %esi
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xb655
addq $-0x4, 0x38(%r15)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16bab(%rip), %rdx     # 0x225ea
movq %rbx, %rdi
movq %r14, %rsi
callq 0xac98