// File: /workspace/github_c_makefile_star2_O3/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 0x8a41
movq %rdi, %r15
movq 0x18(%rdi), %r14
movl %esi, %eax
leaq 0x179f3(%rip), %rcx     # 0x2035c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x0, 0x57(%r14)
jmp 0x8a2d
xorl %ebx, %ebx
movq %r15, %rdi
xorl %esi, %esi
callq 0xcc33
jmp 0x8a7b
movl 0x18(%r14), %ebx
addl 0x10(%r14), %ebx
andl $0x3ff, %ebx            # imm = 0x3FF
jmp 0x8a7b
movzbl 0x57(%r14), %ebx
jmp 0x8a7b
xorl %ebx, %ebx
movq %r15, %rdi
xorl %esi, %esi
callq 0xd787
jmp 0x8a7b
movq 0x18(%r14), %rbx
addq 0x10(%r14), %rbx
shrq $0xa, %rbx
jmp 0x8a7b
movl 0xf8(%r14), %ebx
movl %edx, 0xf8(%r14)
jmp 0x8a7b
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0x14420
movb $0x1, 0x57(%r14)
jmp 0x8a7b
cmpb $0x2, 0x56(%r14)
jne 0x8a48
xorl %ebx, %ebx
cmpq $0x0, 0x28(%r14)
sete %bl
movq %r15, %rdi
callq 0xd432
jmp 0x8a7b
movl 0xf0(%r14), %ebx
movl %edx, 0xf0(%r14)
jmp 0x8a7b
movq %r15, %rdi
movl $0x2, %esi
callq 0xcc33
xorl %ebx, %ebx
jmp 0x8a7b
movl 0xf4(%r14), %ebx
movl %edx, 0xf4(%r14)
jmp 0x8a7b
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x8a7b
movslq %edx, %rsi
shlq $0xa, %rsi
addq $-0x960, %rsi           # imm = 0xF6A0
cmpb $0x0, 0x57(%r14)
je 0x8a61
addq 0x18(%r14), %rsi
movq %r14, %rdi
callq 0x14420
movq %r15, %rdi
callq 0xd432
xorl %ebx, %ebx
cmpb $0x5, 0x55(%r14)
sete %bl
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq