// File: /workspace/github_c_makefile_star2_O2/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 0x147ac(%rip), %eax     # 0x17548
movl 0x143a6(%rip), %ecx     # 0x17148
xorl %edx, %edx
leaq 0x14855(%rip), %r14     # 0x17600
cmpq $0x14, %rdx
je 0x2dd8
movb (%rdx,%r14), %sil
testb $0x40, %sil
jne 0x2dcb
cmpq %rdx, %rax
je 0x2dcb
cmpq %rdx, %rcx
je 0x2dcb
andb $-0x61, %sil
jmp 0x2dcf
orb $0x20, %sil
movb %sil, (%rdx,%r14)
incq %rdx
jmp 0x2dab
movslq 0x1437d(%rip), %rax     # 0x1715c
cmpq $-0x1, %rax
je 0x2e0e
movq 0x1456c(%rip), %rcx     # 0x17358
movq 0x14555(%rip), %rdx     # 0x17348
movslq (%rdx,%rax,4), %rax
movl -0x4(%rcx,%rax,4), %ebx
movl 0x1435f(%rip), %edx     # 0x17160
leal 0x4(,%rdx,4), %edx
movl %edx, -0x4(%rcx,%rax,4)
jmp 0x2e0e
leaq 0x1442b(%rip), %r15     # 0x17240
movq (%r15), %rax
testq %rax, %rax
je 0x2e2a
movl (%rax), %edi
callq 0x2b82
addq $0x8, %r15
jmp 0x2e15
movslq 0x1432b(%rip), %rax     # 0x1715c
cmpq $-0x1, %rax
je 0x2e4d
movq 0x1451a(%rip), %rcx     # 0x17358
movq 0x14503(%rip), %rdx     # 0x17348
movslq (%rdx,%rax,4), %rax
movl %ebx, -0x4(%rcx,%rax,4)
orl $-0x1, 0x142dc(%rip)    # 0x17130
xorl %eax, %eax
xorl %ebx, %ebx
cmpq $0x40000, %rax          # imm = 0x40000
je 0x2e94
movq 0x144e9(%rip), %rcx     # 0x17350
movb (%rcx,%rax), %dl
testb $0x2, %dl
jne 0x2e89
movl 0x142bb(%rip), %ecx     # 0x17130
movq 0x144cc(%rip), %rdx     # 0x17348
movl %ecx, (%rdx,%rax,4)
movl %eax, 0x142ab(%rip)     # 0x17130
incl %ebx
jmp 0x2e8f
andb $-0x3, %dl
movb %dl, (%rcx,%rax)
incq %rax
jmp 0x2e58
leaq 0x146c5(%rip), %r15     # 0x17560
xorl %r12d, %r12d
cmpq $0x14, %r12
je 0x2ec5
testb $0x20, (%r12,%r14)
jne 0x2ebc
movq (%r15), %rdi
testq %rdi, %rdi
je 0x2ebc
callq 0x2070
andq $0x0, (%r15)
incq %r12
addq $0x8, %r15
jmp 0x2e9e
movslq 0x14298(%rip), %rax     # 0x17164
cmpq $-0x1, %rax
je 0x2ef6
movq 0x1447f(%rip), %rcx     # 0x17358
movq 0x14468(%rip), %rdx     # 0x17348
movslq (%rdx,%rax,4), %rax
leaq (%rcx,%rax,4), %rcx
movslq -0x4(%rcx), %rax
addq $0x3, %rax
shrq $0x2, %rax
jmp 0x2efa
xorl %eax, %eax
xorl %ecx, %ecx
movslq 0x14257(%rip), %rsi     # 0x17158
xorl %edx, %edx
cmpq $-0x1, %rsi
je 0x2f21
movq 0x14438(%rip), %rdi     # 0x17348
movslq (%rdi,%rsi,4), %rsi
shlq $0x2, %rsi
addq 0x14439(%rip), %rsi     # 0x17358
jmp 0x2f23
xorl %esi, %esi
testl %eax, %eax
cmovlel %edx, %eax
cmpq %rdx, %rax
je 0x2f46
cmpb $0x2, (%rsi,%rdx)
jne 0x2f39
movb $0x1, (%rsi,%rdx)
jmp 0x2f41
movb $0x0, (%rsi,%rdx)
orl $-0x1, (%rcx,%rdx,4)
incq %rdx
jmp 0x2f28
cmpl $0x0, 0x146c7(%rip)     # 0x17614
je 0x2f7e
leaq 0xd481(%rip), %rsi      # 0x103d7
movq %rsp, %r14
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x21e0
movq %r14, %rdi
callq 0x2514
leaq 0xe254(%rip), %rdi      # 0x111c8
callq 0x2514
callq 0x2815
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq