// File: /workspace/github_c_makefile_star2_O3/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 %rdi, 0x8(%rsp)
movq 0x18(%rdi), %rax
movzbl 0x54(%rax), %ebp
movl %ebp, %ecx
andb $0x3, %cl
xorl %edi, %edi
cmpb $0x2, 0x56(%rax)
sete %r14b
movzbl %cl, %eax
movl $0x40, %ecx
cmovnel %eax, %ecx
movl %ecx, 0x14(%rsp)
movq (%rsi), %r12
testq %r12, %r12
je 0xd006
movq %rdx, %rbx
movq %rsi, %r15
xorl $0x3, %ebp
movb %r14b, %dil
negb %r14b
orb $-0x48, %r14b
shll $0x6, %edi
incq %rbx
movl %edi, 0x4(%rsp)
decq %rbx
je 0xd009
movzbl 0x9(%r12), %r13d
movl %r13d, %eax
xorl $0x3, %eax
testl %ebp, %eax
je 0xcf36
testl %r13d, %edi
jne 0xd006
cmpb $0x8, 0x8(%r12)
jne 0xcf24
cmpq $0x0, 0x38(%r12)
je 0xcf24
leaq 0x60(%r12), %rsi
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq $-0x3, %rdx
callq 0xce55
movq %r12, %rdi
callq 0x14458
movl 0x4(%rsp), %edi
movq 0x18(%r15), %rax
cmpb $0x1, 0x56(%rax)
je 0xcf24
movq %r12, %rdi
callq 0xb5fe
movl 0x4(%rsp), %edi
andb %r14b, %r13b
orb 0x14(%rsp), %r13b
movb %r13b, 0x9(%r12)
jmp 0xcfe2
movq (%r12), %rax
movq %rax, (%r15)
movzbl 0x8(%r12), %ecx
leal -0x4(%rcx), %edx
cmpl $0x10, %edx
ja 0xcf72
leaq 0x13a76(%rip), %rsi     # 0x209c8
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
decl 0x38(%rax)
movq 0x10(%r12), %rdx
addq $0x19, %rdx
jmp 0xcfcc
cmpl $0x26, %ecx
jne 0xcfe9
movzbl 0xa(%r12), %edx
shll $0x4, %edx
addq $0x20, %rdx
jmp 0xcfcc
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xc779
jmp 0xcfdb
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xc86d
jmp 0xcfdb
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x170d5
jmp 0xcfdb
movq 0x20(%r12), %rdx
addq $0x28, %rdx
jmp 0xcfcc
movzbl 0xa(%r12), %eax
leaq 0x20(,%rax,8), %rdx
movq 0x8(%rsp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xfb80
movl 0x4(%rsp), %edi
movq %r15, %r12
movq (%r12), %rax
movq %r12, %r15
movq %rax, %r12
testq %rax, %rax
jne 0xceb7
jmp 0xd006
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x145d4
jmp 0xcfdb
xorl %r15d, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq