// File: /workspace/github_c_makefile_star2_O3/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 0x10ee0b(%rip)          # 0x1163e0
movl $0x0, 0x37cd1(%rip)     # 0x3f2b0
movslq 0x37cce(%rip), %rax     # 0x3f2b4
leaq 0x37cd3(%rip), %rdi     # 0x3f2c0
testq %rax, %rax
jle 0x7616
xorl %ecx, %ecx
movq (%rdi,%rcx,8), %rdx
movl $0x11, %esi
movb $0x1, (%rdx,%rsi)
addq $0x18, %rsi
cmpq $0x3a991, %rsi          # imm = 0x3A991
jne 0x75fd
incq %rcx
cmpq %rax, %rcx
jne 0x75f4
movq 0x3bb23(%rip), %rdi     # 0x43140
callq 0x27cb3
movq 0x1044af(%rip), %rdi    # 0x10bad8
callq 0x27cb3
movq 0x10edbb(%rip), %rdi    # 0x1163f0
callq 0x27cb3
movq 0x10449f(%rip), %rdi    # 0x10bae0
callq 0x27cb3
cmpl $0x0, 0x37c6b(%rip)     # 0x3f2b8
jle 0x7674
leaq 0x40f6a(%rip), %rbx     # 0x485c0
xorl %r14d, %r14d
movq (%rbx), %rdi
callq 0x27cb3
incq %r14
movslq 0x37c4d(%rip), %rax     # 0x3f2b8
addq $0x8, %rbx
cmpq %rax, %r14
jl 0x7659
xorl %ebx, %ebx
leaq 0x3bae3(%rip), %r14     # 0x43160
leaq 0x10446c(%rip), %r15    # 0x10baf0
leaq 0x1098c5(%rip), %r12    # 0x110f50
movq (%rbx,%r14), %rdi
callq 0x27cb3
movq (%rbx,%r15), %rdi
callq 0x27cb3
movq (%rbx,%r12), %rdi
callq 0x27cb3
addq $0x8, %rbx
cmpq $0x5460, %rbx           # imm = 0x5460
jne 0x768b
movq $0x0, 0x37bea(%rip) # 0x3f2a8
movl $0x0, 0x37bd8(%rip)     # 0x3f2a0
cmpl $0x0, 0x37be5(%rip)     # 0x3f2b4
leaq 0x37bea(%rip), %rcx     # 0x3f2c0
jle 0x77fc
xorl %r14d, %r14d
leaq 0x2291e(%rip), %r15     # 0x2a004
xorl %r12d, %r12d
movq (%rcx,%r14,8), %r13
cmpb $0x0, 0x11(%r13,%r12)
je 0x77d8
leaq (%r12,%r13), %rbx
movzbl 0x10(%r13,%r12), %eax
addl $-0x2, %eax
cmpl $0x5, %eax
ja 0x77b9
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%rbx), %rdi
callq 0x7040
leaq 0x37b99(%rip), %rcx     # 0x3f2c0
leaq 0x10ecb6(%rip), %rax    # 0x1163e4
jmp 0x77b7
movq (%r13,%r12), %rdi
addq $-0x4, %rdi
callq 0x7040
decl 0x3ba15(%rip)           # 0x4315c
movq 0x8(%r13,%r12), %rdi
addq $-0x4, %rdi
callq 0x7040
leaq 0x37b64(%rip), %rcx     # 0x3f2c0
leaq 0x3b9f9(%rip), %rax     # 0x4315c
jmp 0x77b7
movq (%rbx), %rdi
callq 0x7040
leaq 0x37b4c(%rip), %rcx     # 0x3f2c0
leaq 0x10ec6d(%rip), %rax    # 0x1163e8
jmp 0x77b7
movq (%rbx), %rdi
leaq 0x3b9c5(%rip), %rax     # 0x4314c
testq %rdi, %rdi
je 0x77b7
callq 0x7040
leaq 0x37b28(%rip), %rcx     # 0x3f2c0
leaq 0x3b9ad(%rip), %rax     # 0x4314c
jmp 0x77b7
movq (%rbx), %rdi
callq 0x7040
leaq 0x37b10(%rip), %rcx     # 0x3f2c0
leaq 0x3b991(%rip), %rax     # 0x43148
decl (%rax)
movb $0x0, 0x10(%r13,%r12)
movq 0x37ae2(%rip), %rax     # 0x3f2a8
movq %rax, (%r13,%r12)
movq %rbx, 0x37ad6(%rip)     # 0x3f2a8
incl 0x37ac8(%rip)           # 0x3f2a0
addq $0x18, %r12
cmpq $0x3a980, %r12          # imm = 0x3A980
jne 0x76e9
incq %r14
movslq 0x37ac1(%rip), %rax     # 0x3f2b4
cmpq %rax, %r14
jl 0x76e6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq