// File: /workspace/github_c_makefile_star2_O1/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 %r13d, %r13d
cmpb $0x2, 0x56(%rax)
movq %rsi, %r12
sete %r13b
movzbl %cl, %eax
movl $0x40, %ecx
cmovnel %eax, %ecx
movl %ecx, 0x14(%rsp)
movl %r13d, %eax
negb %al
orb $-0x48, %al
movb %al, 0x7(%rsp)
shll $0x6, %r13d
incq %rbx
movq (%r12), %r15
testq %r15, %r15
je 0xcef1
decq %rbx
je 0xcef4
movzbl 0x9(%r15), %r14d
movl %r14d, %eax
xorl $0x3, %eax
testl %ebp, %eax
je 0xcdd7
testl %r14d, %r13d
je 0xce17
xorl %r14d, %r14d
jmp 0xced1
movq (%r15), %rax
movq %rax, (%r12)
movzbl 0x8(%r15), %eax
movb $0x1, %r14b
leal -0x4(%rax), %ecx
cmpl $0x10, %ecx
ja 0xce6b
leaq 0x13bd7(%rip), %rdx     # 0x209cc
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
decl 0x38(%rax)
movq 0x10(%r15), %rdx
addq $0x19, %rdx
jmp 0xcec2
cmpb $0x8, 0x8(%r15)
jne 0xce58
cmpq $0x0, 0x38(%r15)
je 0xce58
leaq 0x60(%r15), %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq $-0x3, %rdx
callq 0xcd50
movq %r15, %rdi
callq 0x14350
movq 0x18(%r12), %rax
cmpb $0x1, 0x56(%rax)
je 0xce58
movq %r15, %rdi
callq 0xb4f2
andb 0x7(%rsp), %r14b
orb 0x14(%rsp), %r14b
movb %r14b, 0x9(%r15)
movb $0x1, %r14b
jmp 0xced4
cmpl $0x26, %eax
jne 0xced1
movzbl 0xa(%r15), %edx
shll $0x4, %edx
addq $0x20, %rdx
jmp 0xcec2
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0xc65e
jmp 0xced1
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0xc75a
jmp 0xced1
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x16ff6
jmp 0xced1
movq 0x20(%r15), %rdx
addq $0x28, %rdx
jmp 0xcec2
movzbl 0xa(%r15), %eax
leaq 0x20(,%rax,8), %rdx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0xfa40
movq %r12, %r15
movq %r15, %r12
testb %r14b, %r14b
jne 0xcda5
jmp 0xcef1
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x144c8
jmp 0xced1
xorl %r12d, %r12d
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq