// File: /workspace/github_c_makefile_star2_O1/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 0x109e08(%rip)          # 0x1113e0
movl $0x0, 0x32cce(%rip)     # 0x3a2b0
movslq 0x32ccb(%rip), %rax     # 0x3a2b4
testq %rax, %rax
jle 0x7619
xorl %ecx, %ecx
leaq 0x32cc9(%rip), %rdx     # 0x3a2c0
movq (%rdx,%rcx,8), %rdx
movl $0x11, %esi
movb $0x1, (%rdx,%rsi)
addq $0x18, %rsi
cmpq $0x3a991, %rsi          # imm = 0x3A991
jne 0x7600
incq %rcx
cmpq %rax, %rcx
jne 0x75f0
movq 0x36b20(%rip), %rdi     # 0x3e140
callq 0x24738
movq 0xff4ac(%rip), %rdi     # 0x106ad8
callq 0x24738
movq 0x109db8(%rip), %rdi    # 0x1113f0
callq 0x24738
movq 0xff49c(%rip), %rdi     # 0x106ae0
callq 0x24738
cmpl $0x0, 0x32c68(%rip)     # 0x3a2b8
jle 0x7677
leaq 0x3bf67(%rip), %rbx     # 0x435c0
xorl %r14d, %r14d
movq (%rbx), %rdi
callq 0x24738
incq %r14
movslq 0x32c4a(%rip), %rax     # 0x3a2b8
addq $0x8, %rbx
cmpq %rax, %r14
jl 0x765c
xorl %ebx, %ebx
leaq 0x36ae0(%rip), %r14     # 0x3e160
leaq 0xff469(%rip), %r15     # 0x106af0
leaq 0x1048c2(%rip), %r12    # 0x10bf50
movq (%rbx,%r14), %rdi
callq 0x24738
movq (%rbx,%r15), %rdi
callq 0x24738
movq (%rbx,%r12), %rdi
callq 0x24738
addq $0x8, %rbx
cmpq $0x5460, %rbx           # imm = 0x5460
jne 0x768e
movq $0x0, 0x32be7(%rip) # 0x3a2a8
movl $0x0, 0x32bd5(%rip)     # 0x3a2a0
cmpl $0x0, 0x32be2(%rip)     # 0x3a2b4
jle 0x77b9
xorl %r14d, %r14d
xorl %r13d, %r13d
leaq 0x32bdb(%rip), %rax     # 0x3a2c0
movq (%rax,%r14,8), %r12
cmpb $0x0, 0x11(%r12,%r13)
je 0x7795
leaq (%r12,%r13), %rbx
movzbl 0x10(%r12,%r13), %eax
addl $-0x2, %eax
cmpl $0x5, %eax
ja 0x7777
leaq 0x1e8f6(%rip), %rcx     # 0x26004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rbx), %rdi
leaq 0x109cc3(%rip), %r15    # 0x1113e4
jmp 0x776f
movq (%r12,%r13), %rdi
addq $-0x4, %rdi
callq 0x7040
decl 0x36a26(%rip)           # 0x3e15c
movq 0x8(%r12,%r13), %rdi
addq $-0x4, %rdi
leaq 0x36a16(%rip), %r15     # 0x3e15c
jmp 0x776f
movq (%rbx), %rdi
leaq 0x109c96(%rip), %r15    # 0x1113e8
jmp 0x776f
movq (%rbx), %rdi
leaq 0x369ee(%rip), %r15     # 0x3e14c
testq %rdi, %rdi
jne 0x776f
jmp 0x7774
movq (%rbx), %rdi
leaq 0x369d9(%rip), %r15     # 0x3e148
callq 0x7040
decl (%r15)
movb $0x0, 0x10(%r12,%r13)
movq 0x32b24(%rip), %rax     # 0x3a2a8
movq %rax, (%r12,%r13)
movq %rbx, 0x32b19(%rip)     # 0x3a2a8
incl 0x32b0b(%rip)           # 0x3a2a0
addq $0x18, %r13
cmpq $0x3a980, %r13          # imm = 0x3A980
jne 0x76de
incq %r14
movslq 0x32b04(%rip), %rax     # 0x3a2b4
cmpq %rax, %r14
jl 0x76db
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq