// File: /workspace/github_c_makefile_star2_O2/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lapi.c
// Function: lua_gc
LUA_API int lua_gc (lua_State *L, int what, int data) {
  int res = 0;
  global_State *g;
  lua_lock(L);
  g = G(L);
  switch (what) {
    case LUA_GCSTOP: {
      g->gcrunning = 0;
      break;
    }
    case LUA_GCRESTART: {
      luaE_setdebt(g, 0);
      g->gcrunning = 1;
      break;
    }
    case LUA_GCCOLLECT: {
      luaC_fullgc(L, 0);
      break;
    }
    case LUA_GCCOUNT: {
      /* GC values are expressed in Kbytes: #bytes/2^10 */
      res = cast_int(gettotalbytes(g) >> 10);
      break;
    }
    case LUA_GCCOUNTB: {
      res = cast_int(gettotalbytes(g) & 0x3ff);
      break;
    }
    case LUA_GCSTEP: {
      if (g->gckind == KGC_GEN) {  /* generational mode? */
        res = (g->GCestimate == 0);  /* true if it will do major collection */
        luaC_forcestep(L);  /* do a single step */
      }
      else {
       lu_mem debt = cast(lu_mem, data) * 1024 - GCSTEPSIZE;
       if (g->gcrunning)
         debt += g->GCdebt;  /* include current debt */
       luaE_setdebt(g, debt);
       luaC_forcestep(L);
       if (g->gcstate == GCSpause)  /* end of cycle? */
         res = 1;  /* signal it */
      }
      break;
    }
    case LUA_GCSETPAUSE: {
      res = g->gcpause;
      g->gcpause = data;
      break;
    }
    case LUA_GCSETMAJORINC: {
      res = g->gcmajorinc;
      g->gcmajorinc = data;
      break;
    }
    case LUA_GCSETSTEPMUL: {
      res = g->gcstepmul;
      g->gcstepmul = data;
      break;
    }
    case LUA_GCISRUNNING: {
      res = g->gcrunning;
      break;
    }
    case LUA_GCGEN: {  /* change collector to generational mode */
      luaC_changemode(L, KGC_GEN);
      break;
    }
    case LUA_GCINC: {  /* change collector to incremental mode */
      luaC_changemode(L, KGC_NORMAL);
      break;
    }
    default: res = -1;  /* invalid option */
  }
  lua_unlock(L);
  return res;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpl $0xb, %esi
ja 0x8683
movq %rdi, %r15
movq 0x18(%rdi), %r14
movl %esi, %eax
leaq 0x15d7f(%rip), %rcx     # 0x1e32c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x0, 0x57(%r14)
jmp 0x866f
xorl %ebx, %ebx
movq %r15, %rdi
xorl %esi, %esi
callq 0xc3a3
jmp 0x86bb
movl 0x18(%r14), %ebx
addl 0x10(%r14), %ebx
andl $0x3ff, %ebx            # imm = 0x3FF
jmp 0x86bb
movzbl 0x57(%r14), %ebx
jmp 0x86bb
xorl %ebx, %ebx
movq %r15, %rdi
xorl %esi, %esi
callq 0xcd65
jmp 0x86bb
movq 0x18(%r14), %rbx
addq 0x10(%r14), %rbx
shrq $0xa, %rbx
jmp 0x86bb
movl 0xf8(%r14), %ebx
movl %edx, 0xf8(%r14)
jmp 0x86bb
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0x130b0
movb $0x1, 0x57(%r14)
jmp 0x86bb
cmpb $0x2, 0x56(%r14)
jne 0x8688
xorl %ebx, %ebx
cmpq $0x0, 0x28(%r14)
sete %bl
movq %r15, %rdi
callq 0xcad3
jmp 0x86bb
movl 0xf0(%r14), %ebx
movl %edx, 0xf0(%r14)
jmp 0x86bb
pushq $0x2
popq %rsi
movq %r15, %rdi
callq 0xc3a3
xorl %ebx, %ebx
jmp 0x86bb
movl 0xf4(%r14), %ebx
movl %edx, 0xf4(%r14)
jmp 0x86bb
pushq $-0x1
popq %rbx
jmp 0x86bb
movslq %edx, %rsi
shlq $0xa, %rsi
addq $-0x960, %rsi           # imm = 0xF6A0
cmpb $0x0, 0x57(%r14)
je 0x86a1
addq 0x18(%r14), %rsi
movq %r14, %rdi
callq 0x130b0
movq %r15, %rdi
callq 0xcad3
xorl %ebx, %ebx
cmpb $0x5, 0x55(%r14)
sete %bl
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq