// File: /workspace/github_c_makefile_star2_O2/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lgc.c
// Function: sweeplist
static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
  global_State *g = G(L);
  int ow = otherwhite(g);
  int toclear, toset;  /* bits to clear and to set in all live objects */
  int tostop;  /* stop sweep when this is true */
  if (isgenerational(g)) {  /* generational mode? */
    toclear = ~0;  /* clear nothing */
    toset = bitmask(OLDBIT);  /* set the old bit of all surviving objects */
    tostop = bitmask(OLDBIT);  /* do not sweep old generation */
  }
  else {  /* normal mode */
    toclear = maskcolors;  /* clear all color bits + old bit */
    toset = luaC_white(g);  /* make object white */
    tostop = 0;  /* do not stop */
  }
  while (*p != NULL && count-- > 0) {
    GCObject *curr = *p;
    int marked = gch(curr)->marked;
    if (isdeadm(ow, marked)) {  /* is 'curr' dead? */
      *p = gch(curr)->next;  /* remove 'curr' from list */
      freeobj(L, curr);  /* erase 'curr' */
    }
    else {
      if (testbits(marked, tostop))
        return NULL;  /* stop sweeping this list */
      if (gch(curr)->tt == LUA_TTHREAD)
        sweepthread(L, gco2th(curr));  /* sweep thread's upvalues */
      /* update marks */
      gch(curr)->marked = cast_byte((marked & toclear) | toset);
      p = &gch(curr)->next;  /* go to next element */
    }
  }
  return (*p == NULL) ? NULL : p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rdi, 0x8(%rsp)
movq 0x18(%rdi), %rax
movzbl 0x54(%rax), %ecx
movl %ecx, %ebp
xorl $0x3, %ebp
andb $0x3, %cl
xorl %r15d, %r15d
cmpb $0x2, 0x56(%rax)
movq %rsi, %r12
sete %r15b
movzbl %cl, %eax
pushq $0x40
popq %rcx
cmovnel %eax, %ecx
movl %ecx, 0x14(%rsp)
movl %r15d, %eax
negb %al
orb $-0x48, %al
movb %al, 0x7(%rsp)
shll $0x6, %r15d
movq (%r12), %r13
testq %r13, %r13
je 0xc70a
subq $0x1, %rbx
jb 0xc70d
movzbl 0x9(%r13), %r14d
movl %r14d, %eax
xorl $0x3, %eax
testl %ebp, %eax
je 0xc64f
testl %r14d, %r15d
jne 0xc70a
cmpb $0x8, 0x8(%r13)
jne 0xc63c
cmpq $0x0, 0x38(%r13)
je 0xc63c
leaq 0x60(%r13), %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdi
pushq $-0x3
popq %rdx
callq 0xc580
movq %r13, %rdi
callq 0x130e3
movq 0x18(%r12), %rax
cmpb $0x1, 0x56(%rax)
je 0xc63c
movq %r13, %rdi
callq 0xaf5f
andb 0x7(%rsp), %r14b
orb 0x14(%rsp), %r14b
movb %r14b, 0x9(%r13)
jmp 0xc6f3
movq (%r13), %rax
movq %rax, (%r12)
movzbl 0x8(%r13), %eax
leal -0x4(%rax), %ecx
cmpl $0x10, %ecx
ja 0xc68a
leaq 0x12331(%rip), %rdx     # 0x1e99c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
decl 0x38(%rax)
movq 0x10(%r13), %rdx
addq $0x19, %rdx
jmp 0xc6e1
cmpl $0x26, %eax
jne 0xc6f0
movzbl 0xa(%r13), %edx
shll $0x4, %edx
addq $0x20, %rdx
jmp 0xc6e1
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0xbef5
jmp 0xc6f0
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0xbfdd
jmp 0xc6f0
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x15a75
jmp 0xc6f0
movq 0x20(%r13), %rdx
addq $0x28, %rdx
jmp 0xc6e1
movzbl 0xa(%r13), %eax
leaq 0x20(,%rax,8), %rdx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0xed73
movq %r12, %r13
movq %r13, %r12
jmp 0xc5d0
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x13254
jmp 0xc6f0
xorl %r12d, %r12d
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq