// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: gc
void
gc(void)
{
	int i, j;
	struct atom *p;

	gc_count++;
	alloc_count = 0;

	// tag everything

	for (i = 0; i < block_count; i++)
		for (j = 0; j < BLOCKSIZE; j++)
			mem[i][j].tag = 1;

	// untag what's used

	untag(zero);
	untag(one);
	untag(minusone);
	untag(imaginaryunit);

	for (i = 0; i < tos; i++)
		untag(stack[i]);

	for (i = 0; i < 27 * BUCKETSIZE; i++) {
		untag(symtab[i]);
		untag(binding[i]);
		untag(usrfunc[i]);
	}

	// collect everything that's still tagged

	free_list = NULL;
	free_count = 0;

	for (i = 0; i < block_count; i++)
		for (j = 0; j < BLOCKSIZE; j++) {

			p = mem[i] + j;

			if (p->tag == 0)
				continue;

			// still tagged so it's unused, put on free list

			switch (p->atomtype) {
			case KSYM:
				free(p->u.ksym.name);
				ksym_count--;
				break;
			case USYM:
				free(p->u.usym.name);
				usym_count--;
				break;
			case RATIONAL:
				mfree(p->u.q.a);
				mfree(p->u.q.b);
				break;
			case STR:
				if (p->u.str)
					free(p->u.str);
				string_count--;
				break;
			case TENSOR:
				free(p->u.tensor);
				tensor_count--;
				break;
			default:
				break; // FREEATOM, CONS, or DOUBLE
			}

			p->atomtype = FREEATOM;
			p->u.next = free_list;

			free_list = p;
			free_count++;
		}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
incl 0x107e52(%rip)          # 0x10f3d0
andl $0x0, 0x30d1b(%rip)     # 0x382a0
movl 0x30d19(%rip), %eax     # 0x382a4
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
pushq $0x11
popq %rdx
cmpq %rax, %rcx
je 0x75c0
leaq 0x30d0f(%rip), %rsi     # 0x382b0
movq (%rsi,%rcx,8), %rsi
movq %rdx, %rdi
cmpq $0x3a991, %rdi          # imm = 0x3A991
je 0x75bb
movb $0x1, (%rsi,%rdi)
addq $0x18, %rdi
jmp 0x75a8
incq %rcx
jmp 0x7595
movq 0x34b69(%rip), %rdi     # 0x3c130
callq 0x20b6d
movq 0xfd4f5(%rip), %rdi     # 0x104ac8
callq 0x20b6d
movq 0x107e01(%rip), %rdi    # 0x10f3e0
callq 0x20b6d
movq 0xfd4e5(%rip), %rdi     # 0x104ad0
callq 0x20b6d
leaq 0x39fb9(%rip), %rbx     # 0x415b0
xorl %r14d, %r14d
movslq 0x30ca7(%rip), %rax     # 0x382a8
cmpq %rax, %r14
jge 0x7617
movq (%rbx), %rdi
callq 0x20b6d
incq %r14
addq $0x8, %rbx
jmp 0x75fa
xorl %ebx, %ebx
leaq 0x34b30(%rip), %r14     # 0x3c150
leaq 0xfd4b9(%rip), %r15     # 0x104ae0
leaq 0x102912(%rip), %r12    # 0x109f40
cmpq $0x5460, %rbx           # imm = 0x5460
je 0x7658
movq (%rbx,%r14), %rdi
callq 0x20b6d
movq (%rbx,%r15), %rdi
callq 0x20b6d
movq (%rbx,%r12), %rdi
callq 0x20b6d
addq $0x8, %rbx
jmp 0x762e
andq $0x0, 0x30c38(%rip)     # 0x38298
andl $0x0, 0x30c29(%rip)     # 0x38290
xorl %r14d, %r14d
leaq 0x1b993(%rip), %r15     # 0x23004
movslq 0x30c2c(%rip), %rax     # 0x382a4
cmpq %rax, %r14
jge 0x7747
xorl %r12d, %r12d
cmpq $0x3a980, %r12          # imm = 0x3A980
je 0x773f
leaq 0x30c18(%rip), %rax     # 0x382b0
movq (%rax,%r14,8), %r13
cmpb $0x0, 0x11(%r13,%r12)
je 0x7736
leaq (%r12,%r13), %rbx
movzbl 0x10(%r13,%r12), %eax
addl $-0x2, %eax
cmpl $0x5, %eax
ja 0x7717
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%rbx), %rdi
callq 0x7040
decl 0x107d03(%rip)          # 0x10f3d4
jmp 0x7717
movq (%r13,%r12), %rdi
callq 0x7ad9
movq 0x8(%r13,%r12), %rdi
callq 0x7ad9
jmp 0x7717
movq (%rbx), %rdi
callq 0x7040
decl 0x107ce1(%rip)          # 0x10f3d8
jmp 0x7717
movq (%rbx), %rdi
callq 0x7040
decl 0x34a35(%rip)           # 0x3c13c
jmp 0x7717
movq (%rbx), %rdi
callq 0x7040
decl 0x34a21(%rip)           # 0x3c138
movb $0x0, 0x10(%r13,%r12)
movq 0x30b74(%rip), %rax     # 0x38298
movq %rax, (%r13,%r12)
movq %rbx, 0x30b68(%rip)     # 0x38298
incl 0x30b5a(%rip)           # 0x38290
addq $0x18, %r12
jmp 0x7684
incq %r14
jmp 0x7671
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq