// File: /workspace/github_c_makefile_star2_O3/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), %ecx
xorl %eax, %eax
cmpq $0x5, %rcx
ja 0xd423
movq %rdi, %r14
leaq 0x139c5(%rip), %rdx     # 0x20a0c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpq $0x0, 0x80(%rbx)
je 0xd1a7
movq 0x20(%rbx), %r14
movq %rbx, %rdi
callq 0xd88d
movq 0x20(%rbx), %rax
subq %r14, %rax
jmp 0xd423
movq 0x78(%rbx), %rsi
testq %rsi, %rsi
je 0xd19c
movl $0x55, %edx
movq %r14, %rdi
callq 0xce55
movq %rax, 0x78(%rbx)
jmp 0xd11b
xorl %r15d, %r15d
movl 0x3c(%rbx), %eax
movl 0x58(%rbx), %ecx
leal (%r15,%rcx), %edx
cmpl %eax, %edx
jge 0xd0dc
movslq %ecx, %rsi
addq %r15, %rsi
shlq $0x3, %rsi
addq 0x30(%rbx), %rsi
movq %r14, %rdi
movq $-0x3, %rdx
callq 0xce55
incq %r15
cmpl $0x55, %r15d
jne 0xd09c
movl 0x3c(%rbx), %eax
movl 0x58(%rbx), %ecx
movl $0x55, %r15d
addl %r15d, %ecx
movl %ecx, 0x58(%rbx)
cmpl %eax, %ecx
jl 0xd0ea
movb $0x3, 0x55(%rbx)
movl %r15d, %ecx
leaq (,%rcx,8), %rax
subq %rcx, %rax
jmp 0xd423
movq 0x70(%rbx), %rsi
testq %rsi, %rsi
je 0xd3ae
movl $0x55, %edx
movq %r14, %rdi
callq 0xce55
movq %rax, 0x70(%rbx)
movl $0x253, %eax            # imm = 0x253
jmp 0xd423
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 0xd167
testb $0x3, 0x9(%rsi)
je 0xd167
movq %rbx, %rdi
callq 0xc970
testb $0x40, 0x48(%rbx)
je 0xd17f
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xd17f
movq %rbx, %rdi
callq 0xc970
movq %rbx, %rdi
callq 0xdf34
movq %rbx, %rdi
callq 0xdf69
movb $0x0, 0x55(%rbx)
movq 0x20(%rbx), %rax
jmp 0xd423
movb $0x4, 0x55(%rbx)
xorl %eax, %eax
jmp 0xd423
movb $0x1, 0x55(%rbx)
movq 0x20(%rbx), %r13
movq %r13, 0x28(%rbx)
testb $0x3, 0x9(%r14)
je 0xd1c5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc970
testb $0x40, 0x48(%rbx)
je 0xd1dd
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xd1dd
movq %rbx, %rdi
callq 0xc970
movq %rbx, %rdi
callq 0xdf34
leaq 0xb0(%rbx), %r15
movq 0xd0(%rbx), %r12
cmpq %r15, %r12
je 0xd22b
testb $0x7, 0x9(%r12)
jne 0xd21c
movq 0x10(%r12), %rax
testb $0x40, 0x8(%rax)
je 0xd21c
movq (%rax), %rsi
testb $0x3, 0x9(%rsi)
je 0xd21c
movq %rbx, %rdi
callq 0xc970
movq 0x20(%r12), %r12
jmp 0xd1f3
movq %rbx, %rdi
callq 0xd88d
cmpq $0x0, 0x80(%rbx)
jne 0xd223
movq 0x20(%rbx), %rbp
movq 0x88(%rbx), %rax
movq 0x90(%rbx), %r12
movq 0x98(%rbx), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rbx)
movq $0x0, 0x98(%rbx)
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0xd281
movq %rbx, %rdi
callq 0xd88d
cmpq $0x0, 0x80(%rbx)
jne 0xd26f
movq %r12, 0x80(%rbx)
testq %r12, %r12
je 0xd29f
movq %rbx, %rdi
callq 0xd88d
cmpq $0x0, 0x80(%rbx)
jne 0xd28d
movq %r15, 0x80(%rbx)
testq %r15, %r15
je 0xd2bd
movq %rbx, %rdi
callq 0xd88d
cmpq $0x0, 0x80(%rbx)
jne 0xd2ab
movq 0x20(%rbx), %r15
movq %rbx, %rdi
callq 0xe11f
movq 0x90(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe179
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe179
movq 0x20(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rbx), %r12
movq 0xa0(%rbx), %rax
movq %rax, (%rsp)
movq 0x18(%r14), %rdi
xorl %esi, %esi
callq 0xcdc6
movq %rbx, %rdi
callq 0xdf69
cmpq $0x0, 0x80(%rbx)
je 0xd32d
movq %rbx, %rdi
callq 0xd88d
jmp 0xd319
addq %r15, %r13
addq 0x20(%rbx), %r13
movq %rbx, %rdi
callq 0xe11f
movq 0x98(%rbx), %rsi
movq %rbx, %rdi
callq 0xe264
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
callq 0xe264
movq 0x90(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xe179
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
movq (%rsp), %rdx
callq 0xe179
xorb $0x3, 0x54(%rbx)
addq 0x8(%rsp), %rbp
subq %r13, %rbp
addq 0x20(%rbx), %rbp
addq %rbp, 0x28(%rbx)
movq %r14, %rdi
callq 0xccc3
movslq %eax, %rcx
leaq (,%rcx,8), %rax
subq %rcx, %rax
addq %rbp, %rax
jmp 0xd423
movq 0x108(%rbx), %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movl $0x1, %edx
movq %r14, %rdi
callq 0xce55
movq 0x18(%r14), %r15
cmpb $0x1, 0x56(%r15)
je 0xd41a
movl 0x3c(%r15), %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
cmpl %esi, 0x38(%r15)
jae 0xd3f0
movq %r14, %rdi
callq 0x14a50
movq 0xd8(%r15), %rsi
movq 0xe8(%r15), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0xfb80
movq %rax, 0xd8(%r15)
movq $0x0, 0xe8(%r15)
movb $0x5, 0x55(%rbx)
movl $0x7, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq