// File: /workspace/github_c_makefile_star2_O3/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 0xa9a0
movq %rdi, %r14
leaq 0x17f2b(%rip), %rcx     # 0x22538
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq $0x0, 0x20(%rbx)
movq %rbx, %rdi
callq 0xad40
cmpq $0x0, 0x70(%rbx)
jne 0xa6e5
movb $0x1, 0x55(%rbx)
jmp 0xa6e5
movq %r14, %rdi
movq %rbx, %rsi
movl $0x5, %edx
xorl %ecx, %ecx
jmp 0xa66c
leaq 0x68(%rbx), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movl $0x3, %edx
jmp 0xa66c
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 0xb419
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 0xa6b9
movq %rbx, %rdi
callq 0xa160
testb $0x40, 0x48(%rbx)
je 0xa6d1
movq 0x40(%rbx), %rsi
testb $0x3, 0x9(%rsi)
je 0xa6d1
movq %rbx, %rdi
callq 0xa160
movq %rbx, %rdi
callq 0xb470
movq %rbx, %rdi
callq 0xb4a5
movb $0x0, 0x55(%rbx)
movq 0x20(%rbx), %r12
jmp 0xa9a3
cmpq $0x0, 0x70(%rbx)
movq %rbx, %r15
je 0xa70b
movq %rbx, %rdi
callq 0xad40
cmpq $0x0, 0x70(%rbx)
jne 0xa6f8
movq 0x18(%r14), %r15
movq 0x78(%r15), %r12
movb $0x8, 0x55(%r15)
movq $0x0, 0x20(%r15)
testb $0x3, 0x9(%r14)
je 0xa72e
movq %r15, %rdi
movq %r14, %rsi
callq 0xa160
testb $0x40, 0x48(%r15)
je 0xa747
movq 0x40(%r15), %rsi
testb $0x3, 0x9(%rsi)
je 0xa747
movq %r15, %rdi
callq 0xa160
movq %r15, %rdi
callq 0xb470
movq 0xa8(%r15), %rax
testq %rax, %rax
je 0xa7cc
leaq 0xa8(%r15), %r13
testb $0x7, 0x9(%rax)
je 0xa7ab
movq 0x50(%rax), %rcx
movq %rcx, (%r13)
movq %rax, 0x50(%rax)
movq 0x40(%rax), %rbp
testq %rbp, %rbp
je 0xa7b9
cmpl $0x0, 0x18(%rbp)
je 0xa7a5
movq (%rbp), %rax
testb $0x40, 0x8(%rax)
je 0xa79e
movq (%rax), %rsi
testb $0x3, 0x9(%rsi)
je 0xa79e
movq %r15, %rdi
callq 0xa160
movl $0x0, 0x18(%rbp)
movq 0x10(%rbp), %rbp
jmp 0xa778
cmpq $0x0, 0x40(%rax)
je 0xa768
addq $0x50, %rax
movq %rax, %r13
movq (%r13), %rax
testq %rax, %rax
jne 0xa762
jmp 0xa7cc
movq %r15, %rdi
callq 0xad40
cmpq $0x0, 0x70(%r15)
jne 0xa7c4
movq 0x20(%r15), %rax
movq %rax, (%rsp)
movq %r12, 0x70(%r15)
testq %r12, %r12
je 0xa7f3
movq %r15, %rdi
callq 0xad40
cmpq $0x0, 0x70(%r15)
jne 0xa7e4
movq $0x0, 0x20(%r15)
movq %r15, %rdi
callq 0xb664
movq 0x80(%r15), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xb6bb
movq 0x90(%r15), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xb6bb
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 0xa83e
movq 0x68(%r15), %rdx
testq %rdx, %rdx
je 0xa87b
leaq 0x68(%r15), %rcx
testb $0x3, 0x9(%rdx)
je 0xa870
movq (%rdx), %rsi
movq %rsi, (%rcx)
movq (%rax), %rsi
movq %rsi, (%rdx)
movq %rdx, (%rax)
movq %rdx, %rax
jmp 0xa873
movq %rdx, %rcx
movq (%rcx), %rdx
testq %rdx, %rdx
jne 0xa856
movl $0x1, 0xb0(%r15)
movq %r15, %rdi
callq 0xb4a5
cmpq $0x0, 0x70(%r15)
je 0xa89f
movq %r15, %rdi
callq 0xad40
jmp 0xa88e
addq (%rsp), %r12
movq $0x0, 0x20(%r15)
movq %r15, %rdi
callq 0xb664
movq 0x88(%r15), %rsi
movq %r15, %rdi
callq 0xb7a2
movq 0x90(%r15), %rsi
movq %r15, %rdi
callq 0xb7a2
movq 0x80(%r15), %rsi
movq %r15, %rdi
movq %rbp, %rdx
callq 0xb6bb
movq 0x90(%r15), %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0xb6bb
movq %r15, %rdi
callq 0xf774
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 0xa452
movq %rax, 0x60(%r15)
movq 0x18(%rbx), %rax
addq 0x10(%rbx), %rax
movq %rax, 0x28(%rbx)
jmp 0xa9a3
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 0xa986
movq 0x18(%rbx), %r15
movl 0x3c(%rbx), %eax
leal 0x3(%rax), %edx
testl %eax, %eax
cmovnsl %eax, %edx
sarl $0x2, %edx
movq %r15, %rcx
cmpl %edx, 0x38(%rbx)
jge 0xa97f
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
movq %r14, %rdi
callq 0xf689
movq 0x18(%rbx), %rcx
subq %r15, %rcx
addq %rcx, 0x28(%rbx)
movb $0x6, 0x55(%rbx)
jmp 0xa9a0
cmpq $0x0, 0x98(%rbx)
je 0xa99c
cmpb $0x1, 0x56(%rbx)
jne 0xa9b5
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 0xaade
cltq
leaq (,%rax,8), %r12
subq %rax, %r12
jmp 0xa9a3