// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq 0x18(%rdi), %rbx
movzbl 0x55(%rbx), %ecx
xorl %eax, %eax
cmpq $0x5, %rcx
ja 0xd329
movq %rdi, %r14
leaq 0x13ade(%rip), %rdx     # 0x20a10
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpq $0x0, 0x80(%rbx)
je 0xd089
movq 0x20(%rbx), %r14
movq %rbx, %rdi
callq 0xd794
movq 0x20(%rbx), %rax
subq %r14, %rax
jmp 0xd329
movq 0x78(%rbx), %rsi
testq %rsi, %rsi
je 0xd07e
movl $0x55, %edx
movq %r14, %rdi
callq 0xcd50
movq %rax, 0x78(%rbx)
jmp 0xcffd
xorl %r15d, %r15d
movslq 0x58(%rbx), %rsi
leal (%r15,%rsi), %eax
cmpl 0x3c(%rbx), %eax
jge 0xcfba
addq %r15, %rsi
shlq $0x3, %rsi
addq 0x30(%rbx), %rsi
movq %r14, %rdi
movq $-0x3, %rdx
callq 0xcd50
incq %r15
cmpl $0x55, %r15d
jne 0xcf84
movl $0x55, %r15d
movl 0x58(%rbx), %eax
addl %r15d, %eax
movl %eax, 0x58(%rbx)
cmpl 0x3c(%rbx), %eax
jl 0xcfcc
movb $0x3, 0x55(%rbx)
movl %r15d, %ecx
leaq (,%rcx,8), %rax
subq %rcx, %rax
jmp 0xd329
movq 0x70(%rbx), %rsi
testq %rsi, %rsi
je 0xd2b4
movl $0x55, %edx
movq %r14, %rdi
callq 0xcd50
movq %rax, 0x70(%rbx)
movl $0x253, %eax            # imm = 0x253
jmp 0xd329
movslq 0x3c(%rbx), %rax
shlq $0x3, %rax
movq %rax, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x80(%rbx)
movups %xmm0, 0x90(%rbx)
movq $0x0, 0xa0(%rbx)
movq 0x108(%rbx), %rsi
testq %rsi, %rsi
je 0xd049
testb $0x3, 0x9(%rsi)
je 0xd049
movq %rbx, %rdi
callq 0xc85c
testb $0x40, 0x48(%rbx)
je 0xd061
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xd061
movq %rbx, %rdi
callq 0xc85c
movq %rbx, %rdi
callq 0xde0d
movq %rbx, %rdi
callq 0xde42
movb $0x0, 0x55(%rbx)
movq 0x20(%rbx), %rax
jmp 0xd329
movb $0x4, 0x55(%rbx)
xorl %eax, %eax
jmp 0xd329
movb $0x1, 0x55(%rbx)
movq 0x20(%rbx), %rax
movq %rax, 0x18(%rsp)
movq %rax, 0x28(%rbx)
testq %r14, %r14
je 0xd0b1
testb $0x3, 0x9(%r14)
je 0xd0b1
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc85c
testb $0x40, 0x48(%rbx)
je 0xd0c9
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xd0c9
movq %rbx, %rdi
callq 0xc85c
movq %rbx, %rdi
callq 0xde0d
leaq 0xb0(%rbx), %r15
movq 0xd0(%rbx), %r12
cmpq %r15, %r12
je 0xd117
testb $0x7, 0x9(%r12)
jne 0xd108
movq 0x10(%r12), %rax
testb $0x40, 0x8(%rax)
je 0xd108
movq (%rax), %rsi
testb $0x3, 0x9(%rsi)
je 0xd108
movq %rbx, %rdi
callq 0xc85c
movq 0x20(%r12), %r12
jmp 0xd0df
movq %rbx, %rdi
callq 0xd794
cmpq $0x0, 0x80(%rbx)
jne 0xd10f
movq 0x20(%rbx), %rbp
movq 0x88(%rbx), %r13
movq 0x90(%rbx), %r12
movq 0x98(%rbx), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rbx)
movq $0x0, 0x98(%rbx)
cmpq $0x0, 0x80(%rbx)
je 0xd163
movq %rbx, %rdi
callq 0xd794
jmp 0xd14f
movq %r13, 0x80(%rbx)
testq %r13, %r13
je 0xd181
movq %rbx, %rdi
callq 0xd794
cmpq $0x0, 0x80(%rbx)
jne 0xd16f
movq %r12, 0x80(%rbx)
testq %r12, %r12
je 0xd19f
movq %rbx, %rdi
callq 0xd794
cmpq $0x0, 0x80(%rbx)
jne 0xd18d
movq %r15, 0x80(%rbx)
testq %r15, %r15
je 0xd1bd
movq %rbx, %rdi
callq 0xd794
cmpq $0x0, 0x80(%rbx)
jne 0xd1ab
movq 0x20(%rbx), %r15
movq %rbx, %rdi
callq 0xe018
movq 0x90(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe072
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe072
movq 0x20(%rbx), %rax
movq %rax, 0x10(%rsp)
movq 0x90(%rbx), %r12
movq 0xa0(%rbx), %rax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0xccbb
movq %rbx, %rdi
callq 0xde42
cmpq $0x0, 0x80(%rbx)
je 0xd22d
movq %rbx, %rdi
callq 0xd794
jmp 0xd219
movq 0x18(%rsp), %r13
addq %r15, %r13
addq 0x20(%rbx), %r13
movq %rbx, %rdi
callq 0xe018
movq 0x98(%rbx), %rsi
movq %rbx, %rdi
callq 0xe14a
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
callq 0xe14a
movq 0x90(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xe072
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
movq 0x8(%rsp), %rdx
callq 0xe072
xorb $0x3, 0x54(%rbx)
addq 0x10(%rsp), %rbp
subq %r13, %rbp
addq 0x20(%rbx), %rbp
addq %rbp, 0x28(%rbx)
movq %r14, %rdi
callq 0xcbbb
movslq %eax, %rcx
leaq (,%rcx,8), %rax
subq %rcx, %rax
addq %rbp, %rax
jmp 0xd329
movq 0x108(%rbx), %rax
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movl $0x1, %edx
movq %r14, %rdi
callq 0xcd50
movq 0x18(%r14), %r15
cmpb $0x1, 0x56(%r15)
je 0xd320
movl 0x3c(%r15), %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
cmpl %esi, 0x38(%r15)
jae 0xd2f6
movq %r14, %rdi
callq 0x14944
movq 0xd8(%r15), %rsi
movq 0xe8(%r15), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0xfa40
movq %rax, 0xd8(%r15)
movq $0x0, 0xe8(%r15)
movb $0x5, 0x55(%rbx)
movl $0x7, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq