// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x55(%rax), %eax
movq %rax, -0x30(%rbp)
subq $0x7, %rax
ja 0xe095
movq -0x30(%rbp), %rax
leaq 0x26893(%rip), %rcx     # 0x3476c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movslq 0x3c(%rax), %rcx
shlq $0x3, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rdi
callq 0xe920
movq -0x18(%rbp), %rax
movb $0x0, 0x55(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0xe09d
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x18(%rbp), %rdi
callq 0xe9f0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x70(%rax)
jne 0xdf40
movq -0x18(%rbp), %rax
movb $0x1, 0x55(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0xe09d
movq -0x18(%rbp), %rdi
callq 0xeb70
movq -0x10(%rbp), %rdi
callq 0xeba0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xe430
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
addq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xe09d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rcx
addq $0x68, %rcx
movl $0x3, %edx
callq 0xedb0
movq %rax, -0x8(%rbp)
jmp 0xe09d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rcx
addq $0x98, %rcx
movl $0x4, %edx
callq 0xedb0
movq %rax, -0x8(%rbp)
jmp 0xe09d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x5, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0xedb0
movq %rax, -0x8(%rbp)
jmp 0xe09d
movq -0x18(%rbp), %rax
movq 0xc8(%rax), %rax
movzbl 0x9(%rax), %eax
andl $-0x8, %eax
movq -0x18(%rbp), %rcx
movzbl 0x54(%rcx), %ecx
andl $0x3, %ecx
movzbl %cl, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movq 0xc8(%rax), %rax
movb %cl, 0x9(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xee60
movq -0x18(%rbp), %rax
movb $0x6, 0x55(%rax)
movq $0x0, -0x8(%rbp)
jmp 0xe09d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x98(%rax)
je 0xe083
movq -0x18(%rbp), %rax
movzbl 0x56(%rax), %eax
cmpl $0x1, %eax
je 0xe083
movq -0x10(%rbp), %rdi
callq 0xe2f0
movl %eax, -0x24(%rbp)
movslq -0x24(%rbp), %rax
imulq $0x7, %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xe09d
movq -0x18(%rbp), %rax
movb $0x7, 0x55(%rax)
movq $0x0, -0x8(%rbp)
jmp 0xe09d
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)