// File: /workspace/github_c_makefile_star2_O1/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 0xa631
movq %rdi, %r14
leaq 0x17267(%rip), %rcx     # 0x2150c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq $0x0, 0x20(%rbx)
movq %rbx, %rdi
callq 0xa9ef
cmpq $0x0, 0x70(%rbx)
jne 0xa392
movb $0x1, 0x55(%rbx)
jmp 0xa392
cmpq $0x0, 0x70(%rbx)
je 0xa39b
movq %rbx, %rdi
callq 0xa9ef
jmp 0xa2d2
movq %r14, %rdi
movq %rbx, %rsi
movl $0x5, %edx
xorl %ecx, %ecx
jmp 0xa319
leaq 0x68(%rbx), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movl $0x3, %edx
jmp 0xa319
leaq 0x98(%rbx), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movl $0x4, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaf86
movslq 0x3c(%rbx), %rax
shlq $0x3, %rax
movq %rax, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
movups %xmm0, 0x80(%rbx)
movq $0x0, 0x90(%rbx)
movq 0xc8(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xa366
movq %rbx, %rdi
callq 0x9dfc
testb $0x40, 0x48(%rbx)
je 0xa37e
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xa37e
movq %rbx, %rdi
callq 0x9dfc
movq %rbx, %rdi
callq 0xafdd
movq %rbx, %rdi
callq 0xb012
movb $0x0, 0x55(%rbx)
movq 0x20(%rbx), %r12
jmp 0xa634
movq 0x18(%r14), %r15
movq 0x78(%r15), %r12
movb $0x8, 0x55(%r15)
movq $0x0, 0x20(%r15)
testb $0x3, 0x9(%r14)
je 0xa3c2
movq %r15, %rdi
movq %r14, %rsi
callq 0x9dfc
testb $0x40, 0x48(%r15)
je 0xa3db
movq 0x40(%r15), %rsi
testb $0x3, 0x9(%rsi)
je 0xa3db
movq %r15, %rdi
callq 0x9dfc
movq %r15, %rdi
callq 0xafdd
movq 0xa8(%r15), %rax
testq %rax, %rax
je 0xa460
leaq 0xa8(%r15), %r13
testb $0x7, 0x9(%rax)
je 0xa43f
movq 0x50(%rax), %rcx
movq %rcx, (%r13)
movq %rax, 0x50(%rax)
movq 0x40(%rax), %rbp
testq %rbp, %rbp
je 0xa44d
cmpl $0x0, 0x18(%rbp)
je 0xa439
movq (%rbp), %rax
testb $0x40, 0x8(%rax)
je 0xa432
movq (%rax), %rsi
testb $0x3, 0x9(%rsi)
je 0xa432
movq %r15, %rdi
callq 0x9dfc
movl $0x0, 0x18(%rbp)
movq 0x10(%rbp), %rbp
jmp 0xa40c
cmpq $0x0, 0x40(%rax)
je 0xa3fc
addq $0x50, %rax
movq %rax, %r13
movq (%r13), %rax
testq %rax, %rax
jne 0xa3f6
jmp 0xa460
movq %r15, %rdi
callq 0xa9ef
cmpq $0x0, 0x70(%r15)
jne 0xa458
movq 0x20(%r15), %rax
movq %rax, (%rsp)
movq %r12, 0x70(%r15)
testq %r12, %r12
je 0xa487
movq %r15, %rdi
callq 0xa9ef
cmpq $0x0, 0x70(%r15)
jne 0xa478
movq $0x0, 0x20(%r15)
movq %r15, %rdi
callq 0xb1cd
movq 0x80(%r15), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xb224
movq 0x90(%r15), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xb224
movq 0x20(%r15), %r12
movq 0x80(%r15), %rbp
movq 0x90(%r15), %r13
leaq 0x98(%r15), %rcx
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0xa4d2
movq 0x68(%r15), %rdx
testq %rdx, %rdx
je 0xa50f
leaq 0x68(%r15), %rcx
testb $0x3, 0x9(%rdx)
je 0xa504
movq (%rdx), %rsi
movq %rsi, (%rcx)
movq (%rax), %rsi
movq %rsi, (%rdx)
movq %rdx, (%rax)
movq %rdx, %rax
jmp 0xa507
movq %rdx, %rcx
movq (%rcx), %rdx
testq %rdx, %rdx
jne 0xa4ea
movl $0x1, 0xb0(%r15)
movq %r15, %rdi
callq 0xb012
cmpq $0x0, 0x70(%r15)
je 0xa533
movq %r15, %rdi
callq 0xa9ef
jmp 0xa522
addq (%rsp), %r12
movq $0x0, 0x20(%r15)
movq %r15, %rdi
callq 0xb1cd
movq 0x88(%r15), %rsi
movq %r15, %rdi
callq 0xb2f9
movq 0x90(%r15), %rsi
movq %r15, %rdi
callq 0xb2f9
movq 0x80(%r15), %rsi
movq %r15, %rdi
movq %rbp, %rdx
callq 0xb224
movq 0x90(%r15), %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0xb224
movq %r15, %rdi
callq 0xf24b
xorb $0x3, 0x54(%r15)
addq 0x20(%r15), %r12
movq 0x18(%r14), %r15
movb $0x2, 0x55(%r15)
leaq 0x58(%r15), %rsi
movl $0x1, %edx
movq %r14, %rdi
callq 0xa0f8
movq %rax, 0x60(%r15)
movq 0x18(%rbx), %rax
addq 0x10(%rbx), %rax
movq %rax, 0x28(%rbx)
jmp 0xa634
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 0xa617
movl 0x3c(%rbx), %eax
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movq 0x18(%rbx), %r15
sarl $0x2, %ecx
cmpl %ecx, 0x38(%rbx)
jge 0xa60c
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
movq %r14, %rdi
callq 0xf164
movq 0x18(%rbx), %rax
subq %r15, %rax
addq %rax, 0x28(%rbx)
movb $0x6, 0x55(%rbx)
jmp 0xa631
cmpq $0x0, 0x98(%rbx)
je 0xa62d
cmpb $0x1, 0x56(%rbx)
jne 0xa646
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 0xa768
cltq
leaq (,%rax,8), %r12
subq %rax, %r12
jmp 0xa634