// File: /workspace/github_c_makefile_star2_O0/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lgc.c
// Function: singlestep
static lu_mem singlestep (lua_State *L) {
  global_State *g = G(L);
  switch (g->gcstate) {
    case GCSpause: {
      /* start to count memory traversed */
      g->GCmemtrav = g->strt.size * sizeof(GCObject*);
      lua_assert(!isgenerational(g));
      restartcollection(g);
      g->gcstate = GCSpropagate;
      return g->GCmemtrav;
    }
    case GCSpropagate: {
      if (g->gray) {
        lu_mem oldtrav = g->GCmemtrav;
        propagatemark(g);
        return g->GCmemtrav - oldtrav;  /* memory traversed in this step */
      }
      else {  /* no more `gray' objects */
        lu_mem work;
        int sw;
        g->gcstate = GCSatomic;  /* finish mark phase */
        g->GCestimate = g->GCmemtrav;  /* save what was counted */;
        work = atomic(L);  /* add what was traversed by 'atomic' */
        g->GCestimate += work;  /* estimate of total memory traversed */ 
        sw = entersweep(L);
        return work + sw * GCSWEEPCOST;
      }
    }
    case GCSsweepstring: {
      int i;
      for (i = 0; i < GCSWEEPMAX && g->sweepstrgc + i < g->strt.size; i++)
        sweepwholelist(L, &g->strt.hash[g->sweepstrgc + i]);
      g->sweepstrgc += i;
      if (g->sweepstrgc >= g->strt.size)  /* no more strings to sweep? */
        g->gcstate = GCSsweepudata;
      return i * GCSWEEPCOST;
    }
    case GCSsweepudata: {
      if (g->sweepfin) {
        g->sweepfin = sweeplist(L, g->sweepfin, GCSWEEPMAX);
        return GCSWEEPMAX*GCSWEEPCOST;
      }
      else {
        g->gcstate = GCSsweep;
        return 0;
      }
    }
    case GCSsweep: {
      if (g->sweepgc) {
        g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
        return GCSWEEPMAX*GCSWEEPCOST;
      }
      else {
        /* sweep main thread */
        GCObject *mt = obj2gco(g->mainthread);
        sweeplist(L, &mt, 1);
        checkSizes(L);
        g->gcstate = GCSpause;  /* finish collection */
        return GCSWEEPCOST;
      }
    }
    default: lua_assert(0); return 0;
  }
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movzbl 0x55(%rax), %eax
movq %rax, 0x8(%rsp)
subq $0x5, %rax
ja 0x13a0a
movq 0x8(%rsp), %rax
leaq 0x223a9(%rip), %rcx     # 0x35b44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%rsp), %rax
movslq 0x3c(%rax), %rcx
shlq $0x3, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x30(%rsp), %rdi
callq 0x14360
movq 0x30(%rsp), %rax
movb $0x0, 0x55(%rax)
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x13a13
movq 0x30(%rsp), %rax
cmpq $0x0, 0x80(%rax)
je 0x1381f
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rdi
callq 0x14440
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
subq 0x28(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x13a13
movq 0x30(%rsp), %rax
movb $0x1, 0x55(%rax)
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x38(%rsp), %rdi
callq 0x14600
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq 0x38(%rsp), %rdi
callq 0x13330
movl %eax, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
imulq $0x7, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
jmp 0x13a13
movl $0x0, 0x18(%rsp)
xorl %eax, %eax
cmpl $0x55, 0x18(%rsp)
movb %al, 0x7(%rsp)
jge 0x138b4
movq 0x30(%rsp), %rax
movl 0x58(%rax), %eax
addl 0x18(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x3c(%rcx), %eax
setl %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x138be
jmp 0x138fa
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rsi
movq 0x30(%rsp), %rax
movl 0x58(%rax), %eax
addl 0x18(%rsp), %eax
cltq
shlq $0x3, %rax
addq %rax, %rsi
movq $-0x3, %rdx
callq 0x135d0
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x1388c
movl 0x18(%rsp), %ecx
movq 0x30(%rsp), %rax
addl 0x58(%rax), %ecx
movl %ecx, 0x58(%rax)
movq 0x30(%rsp), %rax
movl 0x58(%rax), %eax
movq 0x30(%rsp), %rcx
cmpl 0x3c(%rcx), %eax
jl 0x13924
movq 0x30(%rsp), %rax
movb $0x3, 0x55(%rax)
movslq 0x18(%rsp), %rax
imulq $0x7, %rax, %rax
movq %rax, 0x40(%rsp)
jmp 0x13a13
movq 0x30(%rsp), %rax
cmpq $0x0, 0x78(%rax)
je 0x13975
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x78(%rax), %rsi
movl $0x55, %edx
callq 0x135d0
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x78(%rax)
movq $0x253, 0x40(%rsp)      # imm = 0x253
jmp 0x13a13
movq 0x30(%rsp), %rax
movb $0x4, 0x55(%rax)
movq $0x0, 0x40(%rsp)
jmp 0x13a13
movq 0x30(%rsp), %rax
cmpq $0x0, 0x70(%rax)
je 0x139c7
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x70(%rax), %rsi
movl $0x55, %edx
callq 0x135d0
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x70(%rax)
movq $0x253, 0x40(%rsp)      # imm = 0x253
jmp 0x13a13
movq 0x30(%rsp), %rax
movq 0x108(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x135d0
movq 0x38(%rsp), %rdi
callq 0x14830
movq 0x30(%rsp), %rax
movb $0x5, 0x55(%rax)
movq $0x7, 0x40(%rsp)
jmp 0x13a13
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopl (%rax)