// File: /workspace/github_c_makefile_star2_O0/hughbarney[P]zepl/lisp.c
// Function: gc
void gc(GC_PARAM)
{
	memory->toOffset = 0;

	// move symbols and root objects
	symbols = gcMoveObject(symbols);

	for (Object * object = GC_ROOTS; object != nil; object = object->cdr)
		object->car = gcMoveObject(object->car);

	// iterate over objects in to-space and move all objects they reference
	for (Object * object = memory->toSpace; object < (Object *) ((char *)memory->toSpace + memory->toOffset); object = (Object *) ((char *)object + object->size)) {

		switch (object->type) {
		case TYPE_NUMBER:
		case TYPE_STRING:
		case TYPE_SYMBOL:
		case TYPE_PRIMITIVE:
			break;
		case TYPE_CONS:
			object->car = gcMoveObject(object->car);
			object->cdr = gcMoveObject(object->cdr);
			break;
		case TYPE_LAMBDA:
		case TYPE_MACRO:
			object->params = gcMoveObject(object->params);
			object->body = gcMoveObject(object->body);
			object->env = gcMoveObject(object->env);
			break;
		case TYPE_ENV:
			object->parent = gcMoveObject(object->parent);
			object->vars = gcMoveObject(object->vars);
			object->vals = gcMoveObject(object->vals);
			break;
		}
	}

	// swap from- and to-space
	void *swap = memory->fromSpace;
	memory->fromSpace = memory->toSpace;
	memory->toSpace = swap;
	memory->fromOffset = memory->toOffset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq 0x9bf5(%rip), %rax      # 0xf218
movq $0x0, 0x10(%rax)
movq 0xb946(%rip), %rdi      # 0x10f78
callq 0x5540
movq %rax, 0xb93a(%rip)      # 0x10f78
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0x9bcf(%rip), %rax      # 0xf220
je 0x5679
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x5646
movq 0x9b98(%rip), %rax      # 0xf218
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x9b85(%rip), %rcx      # 0xf218
movq 0x20(%rcx), %rcx
movq 0x9b7a(%rip), %rdx      # 0xf218
addq 0x10(%rdx), %rcx
cmpq %rcx, %rax
jae 0x57b6
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x28(%rbp)
subq $0x7, %rax
ja 0x579f
movq -0x28(%rbp), %rax
leaq 0x5d96(%rip), %rcx      # 0xb460
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x579f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x579f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x579f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x5540
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x57a1
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
addq 0x8(%rcx), %rax
movq %rax, -0x18(%rbp)
jmp 0x5688
movq 0x9a5b(%rip), %rax      # 0xf218
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x9a4c(%rip), %rax      # 0xf218
movq 0x20(%rax), %rcx
movq 0x9a41(%rip), %rax      # 0xf218
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rcx
movq 0x9a32(%rip), %rax      # 0xf218
movq %rcx, 0x20(%rax)
movq 0x9a27(%rip), %rax      # 0xf218
movq 0x10(%rax), %rcx
movq 0x9a1c(%rip), %rax      # 0xf218
movq %rcx, 0x8(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)