// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x18(%rdi), %rbx
movzbl 0x55(%rbx), %eax
xorl %r15d, %r15d
cmpq $0x5, %rax
ja 0xcac1
movq %rdi, %r14
leaq 0x12294(%rip), %rcx     # 0x1e9e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, 0x80(%rbx)
je 0xc896
movq 0x20(%rbx), %r14
movq %rbx, %rdi
callq 0xce57
movq 0x20(%rbx), %r15
subq %r14, %r15
jmp 0xcac1
movq 0x78(%rbx), %rsi
testq %rsi, %rsi
je 0xc88a
pushq $0x55
popq %rdx
movq %r14, %rdi
callq 0xc580
movq %rax, 0x78(%rbx)
jmp 0xc80b
xorl %r15d, %r15d
pushq $-0x3
popq %r12
xorl %r13d, %r13d
movl 0x3c(%rbx), %eax
movl 0x58(%rbx), %ecx
cmpl $0x55, %r13d
je 0xc7d6
leal (%rcx,%r13), %edx
cmpl %eax, %edx
jge 0xc7d6
movslq %edx, %rsi
shlq $0x3, %rsi
addq 0x30(%rbx), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0xc580
incl %r13d
addq $0x7, %r15
jmp 0xc7a3
addl %ecx, %r13d
movl %r13d, 0x58(%rbx)
cmpl %eax, %r13d
jl 0xcac1
movb $0x3, 0x55(%rbx)
jmp 0xcac1
movq 0x70(%rbx), %rsi
testq %rsi, %rsi
je 0xca51
pushq $0x55
popq %rdx
movq %r14, %rdi
callq 0xc580
movq %rax, 0x70(%rbx)
movl $0x253, %r15d           # imm = 0x253
jmp 0xcac1
movslq 0x3c(%rbx), %rax
shlq $0x3, %rax
movq %rax, 0x20(%rbx)
xorps %xmm0, %xmm0
andq $0x0, 0xa0(%rbx)
movups %xmm0, 0x80(%rbx)
movups %xmm0, 0x90(%rbx)
movq 0x108(%rbx), %rsi
testq %rsi, %rsi
je 0xc855
testb $0x3, 0x9(%rsi)
je 0xc855
movq %rbx, %rdi
callq 0xc0dc
testb $0x40, 0x48(%rbx)
je 0xc86d
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xc86d
movq %rbx, %rdi
callq 0xc0dc
movq %rbx, %rdi
callq 0xd359
movq %rbx, %rdi
callq 0xd38e
movb $0x0, 0x55(%rbx)
movq 0x20(%rbx), %r15
jmp 0xcac1
movb $0x4, 0x55(%rbx)
xorl %r15d, %r15d
jmp 0xcac1
movb $0x1, 0x55(%rbx)
movq 0x20(%rbx), %rax
movq %rax, 0x8(%rsp)
movq %rax, 0x28(%rbx)
testb $0x3, 0x9(%r14)
je 0xc8b9
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc0dc
testb $0x40, 0x48(%rbx)
je 0xc8d1
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xc8d1
movq %rbx, %rdi
callq 0xc0dc
movq %rbx, %rdi
callq 0xd359
leaq 0xb0(%rbx), %r15
leaq 0xd0(%rbx), %r12
movq (%r12), %r12
cmpq %r15, %r12
je 0xc91a
testb $0x7, 0x9(%r12)
jne 0xc914
movq 0x10(%r12), %rax
testb $0x40, 0x8(%rax)
je 0xc914
movq (%rax), %rsi
testb $0x3, 0x9(%rsi)
je 0xc914
movq %rbx, %rdi
callq 0xc0dc
addq $0x20, %r12
jmp 0xc8e7
movq %rbx, %rdi
callq 0xd54d
movq 0x90(%rbx), %r15
movq 0x20(%rbx), %rbp
movq 0x88(%rbx), %r12
movq 0x98(%rbx), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rbx)
andq $0x0, 0x98(%rbx)
movq %rbx, %rdi
callq 0xd54d
movq %r12, 0x80(%rbx)
movq %rbx, %rdi
callq 0xd54d
movq %r15, 0x80(%rbx)
movq %rbx, %rdi
callq 0xd54d
movq %r13, 0x80(%rbx)
movq %rbx, %rdi
callq 0xd54d
movq 0x8(%rsp), %r13
addq 0x20(%rbx), %r13
movq %rbx, %rdi
callq 0xd567
movq 0x90(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xd5b2
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xd5b2
movq 0x90(%rbx), %r12
movq 0xa0(%rbx), %r15
addq 0x20(%rbx), %rbp
movq %r14, %rdi
xorl %esi, %esi
callq 0xc4fc
movq %rbx, %rdi
callq 0xd38e
movq %rbx, %rdi
callq 0xd54d
addq 0x20(%rbx), %r13
subq %r13, %rbp
movq %rbx, %rdi
callq 0xd567
movq 0x98(%rbx), %rsi
movq %rbx, %rdi
callq 0xd66f
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
callq 0xd66f
movq 0x90(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xd5b2
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0xd5b2
xorb $0x3, 0x54(%rbx)
addq 0x20(%rbx), %rbp
addq %rbp, 0x28(%rbx)
movq %r14, %rdi
callq 0xc427
cltq
imulq $0x7, %rax, %r15
addq %rbp, %r15
jmp 0xcac1
movq 0x108(%rbx), %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0xc580
movq 0x18(%r14), %r15
cmpb $0x1, 0x56(%r15)
je 0xcab9
movl 0x38(%r15), %ecx
movl 0x3c(%r15), %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
cmpl %eax, %ecx
jae 0xca92
movq %r14, %rdi
movl %eax, %esi
callq 0x1366c
movq 0xd8(%r15), %rsi
movq 0xe8(%r15), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0xed73
movq %rax, 0xd8(%r15)
andq $0x0, 0xe8(%r15)
movb $0x5, 0x55(%rbx)
pushq $0x7
popq %r15
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq