// File: /workspace/github_c_makefile_star2_O3/blakemcbride[P]LISP9/ls9.c
// Function: gc
int gc(void) {
	int	i, n, k, sk;
	char	buf[100];
	cell	*a;
	byte	*m;

	for (i=0; i<NPORTS; i++) {
		if (Port_flags[i] & LOCK_TAG)
			Port_flags[i] |= USED_TAG;
		else if (i == Inport || i == Outport)
			Port_flags[i] |= USED_TAG;
		else
			Port_flags[i] &= ~USED_TAG;
	}
	if (Rts != NIL) {
		sk = stringlen(Rts);
		stringlen(Rts) = (1 + Sp) * sizeof(cell);
	}
	for (i=0; GC_roots[i] != NULL; i++) {
		mark(*GC_roots[i]);
	}
	if (Rts != NIL) {
		stringlen(Rts) = sk;
	}
	k = 0;
	Freelist = NIL;
	for (i=0; i<NNODES; i++) {
		if (!(tag(i) & MARK_TAG)) {
			cdr(i) = Freelist;
			Freelist = i;
			k++;
		}
		else {
			tag(i) &= ~MARK_TAG;
		}
	}
	for (i=0; i<NPORTS; i++) {
		if (!(Port_flags[i] & USED_TAG) && Ports[i] != NULL) {
			fclose(Ports[i]);
			Ports[i] = NULL;
		}
	}
	n = NIL == Obarray? 0: veclen(Obarray);
	a = NIL == Obarray? NULL: vector(Obarray);
	m = NIL == Obmap? NULL: string(Obmap);
	for (i=0; i<n; i++) {
		if (OBUSED  == m[i]) {
			m[i] = OBALLOC;
		}
		else {
			m[i] = OBFREE;
			a[i] = NIL;
		}
	}
	if (GC_verbose) {
		sprintf(buf, "GC: %d nodes reclaimed", k);
		prints(buf); nl();
		flush();
	}
	return k;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl 0x16673(%rip), %eax     # 0x19548
movl 0x1626d(%rip), %ecx     # 0x19148
xorl %edx, %edx
leaq 0x1671c(%rip), %r14     # 0x19600
movb (%rdx,%r14), %sil
testb $0x40, %sil
jne 0x2efe
cmpq %rdx, %rax
je 0x2efe
cmpq %rdx, %rcx
je 0x2efe
andb $-0x61, %sil
jmp 0x2f02
orb $0x20, %sil
movb %sil, (%rdx,%r14)
incq %rdx
cmpq $0x14, %rdx
jne 0x2ee4
movslq 0x16246(%rip), %rax     # 0x1915c
cmpq $-0x1, %rax
je 0x2f45
movq 0x16435(%rip), %rcx     # 0x19358
movq 0x1641e(%rip), %rdx     # 0x19348
movslq (%rdx,%rax,4), %rax
movl -0x4(%rcx,%rax,4), %ebx
movl 0x16228(%rip), %edx     # 0x19160
leal 0x4(,%rdx,4), %edx
movl %edx, -0x4(%rcx,%rax,4)
jmp 0x2f45
movq 0x162f4(%rip), %rax     # 0x19240
testq %rax, %rax
je 0x2f6b
leaq 0x162f0(%rip), %r15     # 0x19248
movl (%rax), %edi
callq 0x2cb6
movq (%r15), %rax
addq $0x8, %r15
testq %rax, %rax
jne 0x2f58
movslq 0x161ea(%rip), %rax     # 0x1915c
cmpq $-0x1, %rax
je 0x2f8e
movq 0x163d9(%rip), %rcx     # 0x19358
movq 0x163c2(%rip), %rdx     # 0x19348
movslq (%rdx,%rax,4), %rax
movl %ebx, -0x4(%rcx,%rax,4)
movl $0xffffffff, 0x16198(%rip) # imm = 0xFFFFFFFF
xorl %eax, %eax
movq 0x163af(%rip), %rcx     # 0x19350
xorl %ebx, %ebx
movb (%rcx,%rax), %dl
testb $0x2, %dl
jne 0x2fc5
movl 0x1617f(%rip), %edx     # 0x19130
movq 0x16390(%rip), %rsi     # 0x19348
movl %edx, (%rsi,%rax,4)
movl %eax, 0x1616f(%rip)     # 0x19130
incl %ebx
jmp 0x2fd2
andb $-0x3, %dl
movb %dl, (%rcx,%rax)
movq 0x1637e(%rip), %rcx     # 0x19350
incq %rax
cmpq $0x40000, %rax          # imm = 0x40000
jne 0x2fa3
leaq 0x1657c(%rip), %r15     # 0x19560
xorl %r12d, %r12d
testb $0x20, (%r12,%r14)
jne 0x3002
movq (%r15), %rdi
testq %rdi, %rdi
je 0x3002
callq 0x2070
movq $0x0, (%r15)
incq %r12
addq $0x8, %r15
cmpq $0x14, %r12
jne 0x2fe7
movslq 0x1614e(%rip), %rax     # 0x19164
cmpq $-0x1, %rax
je 0x3040
movq 0x16335(%rip), %rcx     # 0x19358
movq 0x1631e(%rip), %rdx     # 0x19348
movslq (%rdx,%rax,4), %rax
leaq (%rcx,%rax,4), %rax
movslq -0x4(%rax), %rdx
addq $0x3, %rdx
shrq $0x2, %rdx
jmp 0x3044
xorl %edx, %edx
xorl %eax, %eax
movslq 0x1610d(%rip), %rcx     # 0x19158
cmpq $-0x1, %rcx
je 0x3069
movq 0x162f0(%rip), %rsi     # 0x19348
movslq (%rsi,%rcx,4), %rcx
shlq $0x2, %rcx
addq 0x162f1(%rip), %rcx     # 0x19358
jmp 0x306b
xorl %ecx, %ecx
testl %edx, %edx
jle 0x3092
movl %edx, %edx
xorl %esi, %esi
cmpb $0x2, (%rcx,%rsi)
jne 0x307f
movb $0x1, (%rcx,%rsi)
jmp 0x308a
movb $0x0, (%rcx,%rsi)
movl $0xffffffff, (%rax,%rsi,4) # imm = 0xFFFFFFFF
incq %rsi
cmpq %rsi, %rdx
jne 0x3073
cmpl $0x0, 0x1657b(%rip)     # 0x19614
je 0x30d9
leaq 0x10375(%rip), %rsi     # 0x13417
movq %rsp, %r14
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x21e0
movq %r14, %rdi
callq 0x2080
movq %r14, %rdi
movl %eax, %esi
callq 0x29c1
leaq 0x1113e(%rip), %rdi     # 0x14208
movl $0x1, %esi
callq 0x29c1
callq 0x2937
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq