// File: /workspace/github_c_makefile_star2_O0/tylerneylon[P]APIsWithLua/lua/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: {
      l_mem debt = 1;  /* =1 to signal that it did an actual step */
      lu_byte oldrunning = g->gcrunning;
      g->gcrunning = 1;  /* allow GC to run */
      if (data == 0) {
        luaE_setdebt(g, -GCSTEPSIZE);  /* to do a "small" step */
        luaC_step(L);
      }
      else {  /* add 'data' to total debt */
        debt = cast(l_mem, data) * 1024 + g->GCdebt;
        luaE_setdebt(g, debt);
        luaC_checkGC(L);
      }
      g->gcrunning = oldrunning;  /* restore previous state */
      if (debt > 0 && g->gcstate == GCSpause)  /* end of cycle? */
        res = 1;  /* signal it */
      break;
    }
    case LUA_GCSETPAUSE: {
      res = g->gcpause;
      g->gcpause = data;
      break;
    }
    case LUA_GCSETSTEPMUL: {
      res = g->gcstepmul;
      if (data < 40) data = 40;  /* avoid ridiculous low values (and 0) */
      g->gcstepmul = data;
      break;
    }
    case LUA_GCISRUNNING: {
      res = g->gcrunning;
      break;
    }
    default: res = -1;  /* invalid option */
  }
  lua_unlock(L);
  return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x38(%rbp)
subq $0x9, %rax
ja 0x877a
movq -0x38(%rbp), %rax
leaq 0x2bba7(%rip), %rcx     # 0x341b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movb $0x0, 0x57(%rax)
jmp 0x8781
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x158c0
movq -0x20(%rbp), %rax
movb $0x1, 0x57(%rax)
jmp 0x8781
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xe3a0
jmp 0x8781
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
addq 0x18(%rcx), %rax
shrq $0xa, %rax
movl %eax, -0x14(%rbp)
jmp 0x8781
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
addq 0x18(%rcx), %rax
andq $0x3ff, %rax            # imm = 0x3FF
movl %eax, -0x14(%rbp)
jmp 0x8781
movq $0x1, -0x28(%rbp)
movq -0x20(%rbp), %rax
movb 0x57(%rax), %al
movb %al, -0x29(%rbp)
movq -0x20(%rbp), %rax
movb $0x1, 0x57(%rax)
cmpl $0x0, -0x10(%rbp)
jne 0x86c6
movq -0x20(%rbp), %rdi
movq $-0x960, %rsi           # imm = 0xF6A0
callq 0x158c0
movq -0x8(%rbp), %rdi
callq 0xe0b0
jmp 0x8701
movslq -0x10(%rbp), %rax
shlq $0xa, %rax
movq -0x20(%rbp), %rcx
addq 0x18(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x158c0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x18(%rax)
jle 0x86ff
movq -0x8(%rbp), %rdi
callq 0xe0b0
jmp 0x8701
movb -0x29(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x57(%rax)
cmpq $0x0, -0x28(%rbp)
jle 0x8726
movq -0x20(%rbp), %rax
movzbl 0x55(%rax), %eax
cmpl $0x7, %eax
jne 0x8726
movl $0x1, -0x14(%rbp)
jmp 0x8781
movq -0x20(%rbp), %rax
movl 0xb4(%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xb4(%rax)
jmp 0x8781
movq -0x20(%rbp), %rax
movl 0xb8(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x28, -0x10(%rbp)
jge 0x875e
movl $0x28, -0x10(%rbp)
movl -0x10(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xb8(%rax)
jmp 0x8781
movq -0x20(%rbp), %rax
movzbl 0x57(%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x8781
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movl -0x14(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)