// File: /workspace/github_c_makefile_star2_O1/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 0x1660b(%rip), %eax     # 0x19548
movl 0x16205(%rip), %ecx     # 0x19148
xorl %edx, %edx
leaq 0x166b4(%rip), %r14     # 0x19600
movb (%rdx,%r14), %sil
testb $0x40, %sil
jne 0x2f66
cmpq %rdx, %rax
je 0x2f66
cmpq %rdx, %rcx
je 0x2f66
andb $-0x61, %sil
jmp 0x2f6a
orb $0x20, %sil
movb %sil, (%rdx,%r14)
incq %rdx
cmpq $0x14, %rdx
jne 0x2f4c
movslq 0x161de(%rip), %rax     # 0x1915c
cmpq $-0x1, %rax
je 0x2fad
movq 0x163cd(%rip), %rcx     # 0x19358
movq 0x163b6(%rip), %rdx     # 0x19348
movslq (%rdx,%rax,4), %rax
movl -0x4(%rcx,%rax,4), %ebx
movl 0x161c0(%rip), %edx     # 0x19160
leal 0x4(,%rdx,4), %edx
movl %edx, -0x4(%rcx,%rax,4)
jmp 0x2fad
movq 0x1628c(%rip), %rax     # 0x19240
testq %rax, %rax
je 0x2fd3
leaq 0x16288(%rip), %r15     # 0x19248
movl (%rax), %edi
callq 0x2d0e
movq (%r15), %rax
addq $0x8, %r15
testq %rax, %rax
jne 0x2fc0
movslq 0x16182(%rip), %rax     # 0x1915c
cmpq $-0x1, %rax
je 0x2ff6
movq 0x16371(%rip), %rcx     # 0x19358
movq 0x1635a(%rip), %rdx     # 0x19348
movslq (%rdx,%rax,4), %rax
movl %ebx, -0x4(%rcx,%rax,4)
movl $0xffffffff, 0x16130(%rip) # imm = 0xFFFFFFFF
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x16345(%rip), %rcx     # 0x19350
movb (%rcx,%rax), %dl
testb $0x2, %dl
jne 0x302d
movl 0x16117(%rip), %ecx     # 0x19130
movq 0x16328(%rip), %rdx     # 0x19348
movl %ecx, (%rdx,%rax,4)
movl %eax, 0x16107(%rip)     # 0x19130
incl %ebx
jmp 0x3033
andb $-0x3, %dl
movb %dl, (%rcx,%rax)
incq %rax
cmpq $0x40000, %rax          # imm = 0x40000
jne 0x3004
leaq 0x1651b(%rip), %r15     # 0x19560
xorl %r12d, %r12d
testb $0x20, (%r12,%r14)
jne 0x3063
movq (%r15), %rdi
testq %rdi, %rdi
je 0x3063
callq 0x2070
movq $0x0, (%r15)
incq %r12
addq $0x8, %r15
cmpq $0x14, %r12
jne 0x3048
movslq 0x160ed(%rip), %rax     # 0x19164
cmpq $-0x1, %rax
je 0x309e
movq 0x162d4(%rip), %rcx     # 0x19358
movq 0x162bd(%rip), %rdx     # 0x19348
movslq (%rdx,%rax,4), %rdx
movslq -0x4(%rcx,%rdx,4), %rcx
addq $0x3, %rcx
shrq $0x2, %rcx
jmp 0x30a0
xorl %ecx, %ecx
cmpl $-0x1, %eax
je 0x30bd
movq 0x1629c(%rip), %rdx     # 0x19348
movslq (%rdx,%rax,4), %rax
shlq $0x2, %rax
addq 0x1629d(%rip), %rax     # 0x19358
jmp 0x30bf
xorl %eax, %eax
movslq 0x16092(%rip), %rdx     # 0x19158
cmpq $-0x1, %rdx
je 0x30e4
movq 0x16275(%rip), %rsi     # 0x19348
movslq (%rsi,%rdx,4), %rdx
shlq $0x2, %rdx
addq 0x16276(%rip), %rdx     # 0x19358
jmp 0x30e6
xorl %edx, %edx
testl %ecx, %ecx
jle 0x310d
movl %ecx, %ecx
xorl %esi, %esi
cmpb $0x2, (%rdx,%rsi)
jne 0x30fa
movb $0x1, (%rdx,%rsi)
jmp 0x3105
movb $0x0, (%rdx,%rsi)
movl $0xffffffff, (%rax,%rsi,4) # imm = 0xFFFFFFFF
incq %rsi
cmpq %rsi, %rcx
jne 0x30ee
cmpl $0x0, 0x16500(%rip)     # 0x19614
je 0x3154
leaq 0x102ca(%rip), %rsi     # 0x133e7
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 0x29f6
leaq 0x11093(%rip), %rdi     # 0x141d8
movl $0x1, %esi
callq 0x29f6
callq 0x296c
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq