// File: /workspace/github_c_makefile_star2_O2/tylerneylon[P]APIsWithLua/lua/lgc.c
// Function: singlestep
static lu_mem singlestep (lua_State *L) {
  global_State *g = G(L);
  switch (g->gcstate) {
    case GCSpause: {
      g->GCmemtrav = g->strt.size * sizeof(GCObject*);
      restartcollection(g);
      g->gcstate = GCSpropagate;
      return g->GCmemtrav;
    }
    case GCSpropagate: {
      g->GCmemtrav = 0;
      lua_assert(g->gray);
      propagatemark(g);
       if (g->gray == NULL)  /* no more gray objects? */
        g->gcstate = GCSatomic;  /* finish propagate phase */
      return g->GCmemtrav;  /* memory traversed in this step */
    }
    case GCSatomic: {
      lu_mem work;
      propagateall(g);  /* make sure gray list is empty */
      work = atomic(L);  /* work is what was traversed by 'atomic' */
      entersweep(L);
      g->GCestimate = gettotalbytes(g);  /* first estimate */;
      return work;
    }
    case GCSswpallgc: {  /* sweep "regular" objects */
      return sweepstep(L, g, GCSswpfinobj, &g->finobj);
    }
    case GCSswpfinobj: {  /* sweep objects with finalizers */
      return sweepstep(L, g, GCSswptobefnz, &g->tobefnz);
    }
    case GCSswptobefnz: {  /* sweep objects to be finalized */
      return sweepstep(L, g, GCSswpend, NULL);
    }
    case GCSswpend: {  /* finish sweeps */
      makewhite(g, g->mainthread);  /* sweep main thread */
      checkSizes(L, g);
      g->gcstate = GCScallfin;
      return 0;
    }
    case GCScallfin: {  /* call remaining finalizers */
      if (g->tobefnz && g->gckind != KGC_EMERGENCY) {
        int n = runafewfinalizers(L);
        return (n * GCFINALIZECOST);
      }
      else {  /* emergency mode or no more finalizers */
        g->gcstate = GCSpause;  /* finish collection */
        return 0;
      }
    }
    default: lua_assert(0); return 0;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x18(%rdi), %rbx
movzbl 0x55(%rbx), %eax
cmpq $0x7, %rax
ja 0x9ee0
movq %rdi, %r14
leaq 0x15965(%rip), %rcx     # 0x1f554
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
andq $0x0, 0x20(%rbx)
movq %rbx, %rdi
callq 0xa21c
cmpq $0x0, 0x70(%rbx)
jne 0x9cb4
movb $0x1, 0x55(%rbx)
jmp 0x9cb4
pushq $0x5
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
jmp 0x9c3e
leaq 0x68(%rbx), %rcx
pushq $0x3
jmp 0x9c37
leaq 0x98(%rbx), %rcx
pushq $0x4
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa769
movslq 0x3c(%rbx), %rax
shlq $0x3, %rax
movq %rax, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
andq $0x0, 0x90(%rbx)
movups %xmm0, 0x80(%rbx)
movq 0xc8(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0x9c88
movq %rbx, %rdi
callq 0x974c
testb $0x40, 0x48(%rbx)
je 0x9ca0
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0x9ca0
movq %rbx, %rdi
callq 0x974c
movq %rbx, %rdi
callq 0xa7be
movq %rbx, %rdi
callq 0xa7f3
movb $0x0, 0x55(%rbx)
movq 0x20(%rbx), %r12
jmp 0x9ee3
movq %rbx, %rdi
callq 0xa752
movq 0x18(%r14), %r15
movq 0x78(%r15), %rax
movq %rax, (%rsp)
movb $0x8, 0x55(%r15)
andq $0x0, 0x20(%r15)
testb $0x3, 0x9(%r14)
je 0x9ced
movq %r15, %rdi
movq %r14, %rsi
callq 0x974c
testb $0x40, 0x48(%r15)
je 0x9d06
movq 0x40(%r15), %rsi
testb $0x3, 0x9(%rsi)
je 0x9d06
movq %r15, %rdi
callq 0x974c
movq %r15, %rdi
callq 0xa7be
leaq 0xa8(%r15), %r12
movq (%r12), %rbp
testq %rbp, %rbp
je 0x9d7a
testb $0x7, 0x9(%rbp)
jne 0x9d2b
cmpq $0x0, 0x40(%rbp)
jne 0x9d71
movq 0x50(%rbp), %rax
movq %rax, (%r12)
movq %rbp, 0x50(%rbp)
addq $0x40, %rbp
movq (%rbp), %r13
testq %r13, %r13
je 0x9d15
leaq 0x10(%r13), %rbp
cmpl $0x0, 0x18(%r13)
je 0x9d3b
movq (%r13), %rax
testb $0x40, 0x8(%rax)
je 0x9d6a
movq (%rax), %rsi
testb $0x3, 0x9(%rsi)
je 0x9d6a
movq %r15, %rdi
callq 0x974c
andl $0x0, 0x18(%r13)
jmp 0x9d3b
addq $0x50, %rbp
movq %rbp, %r12
jmp 0x9d15
movq %r15, %rdi
callq 0xa752
movq 0x20(%r15), %r12
movq (%rsp), %rax
movq %rax, 0x70(%r15)
movq %r15, %rdi
callq 0xa752
andq $0x0, 0x20(%r15)
movq %r15, %rdi
callq 0xa98f
movq 0x80(%r15), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xa9da
movq 0x90(%r15), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xa9da
movq 0x80(%r15), %rbp
movq 0x90(%r15), %r13
addq 0x20(%r15), %r12
movq %r15, %rdi
xorl %esi, %esi
callq 0x99fc
movl $0x1, 0xb0(%r15)
movq %r15, %rdi
callq 0xa7f3
movq %r15, %rdi
callq 0xa752
andq $0x0, 0x20(%r15)
movq %r15, %rdi
callq 0xa98f
movq 0x88(%r15), %rsi
movq %r15, %rdi
callq 0xaa9a
movq 0x90(%r15), %rsi
movq %r15, %rdi
callq 0xaa9a
movq 0x80(%r15), %rsi
movq %r15, %rdi
movq %rbp, %rdx
callq 0xa9da
movq 0x90(%r15), %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0xa9da
movq %r15, %rdi
callq 0xe5ac
xorb $0x3, 0x54(%r15)
addq 0x20(%r15), %r12
movq %r14, %rdi
callq 0xa0bc
movq 0x18(%rbx), %rax
addq 0x10(%rbx), %rax
movq %rax, 0x28(%rbx)
jmp 0x9ee3
movq 0xc8(%rbx), %rax
movb 0x9(%rax), %cl
andb $-0x8, %cl
movb 0x54(%rbx), %dl
andb $0x3, %dl
orb %cl, %dl
movb %dl, 0x9(%rax)
cmpb $0x1, 0x56(%rbx)
je 0x9ec6
movq 0x18(%rbx), %r15
movl 0x38(%rbx), %esi
movl 0x3c(%rbx), %ecx
pushq $0x4
popq %rdi
movl %ecx, %eax
cltd
idivl %edi
movq %r15, %rdx
cmpl %eax, %esi
jge 0x9ebf
pushq $0x2
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
movq %r14, %rdi
movl %eax, %esi
callq 0xe4d2
movq 0x18(%rbx), %rdx
subq %r15, %rdx
addq %rdx, 0x28(%rbx)
movb $0x6, 0x55(%rbx)
jmp 0x9ee0
cmpq $0x0, 0x98(%rbx)
je 0x9edc
cmpb $0x1, 0x56(%rbx)
jne 0x9ef5
movb $0x7, 0x55(%rbx)
xorl %r12d, %r12d
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0xa005
cltq
imulq $0x7, %rax, %r12
jmp 0x9ee3