// File: /workspace/github_c_makefile_star2_O3/hughbarney[P]zepl/lisp.c
// Function: writeObject
void writeObject(Object * object, bool readably, Stream *stream)
{
	switch (object->type) {
#define CASE(type, ...)                                                      \
  case type:                                                                 \
    writeFmt(stream, __VA_ARGS__);                                              \
    break
		CASE(TYPE_NUMBER, "%g", object->number);
		CASE(TYPE_SYMBOL, "%s", object->string);
		CASE(TYPE_PRIMITIVE, "#<Primitive %s>", object->name);
#undef CASE
	case TYPE_STRING:
		if (readably) {
			writeChar('"', stream);
			for (char *string = object->string; *string; ++string) {
				switch (*string) {
				case '"':
					writeString("\\\"", stream);
					break;
				case '\t':
					writeString("\\t", stream);
					break;
				case '\r':
					writeString("\\r", stream);
					break;
				case '\n':
					writeString("\\n", stream);
					break;
				case '\\':
					writeString("\\\\", stream);
					break;
				default:
					writeChar(*string, stream);
					break;
				}
			}
			writeChar('"', stream);
		} else
			writeFmt(stream, "%s", object->string);
		break;
	case TYPE_CONS:
		writeChar('(', stream);
		writeObject(object->car, readably, stream);
		while (object->cdr != nil) {
			object = object->cdr;
			if (object->type == TYPE_CONS) {
				writeChar(' ', stream);
				writeObject(object->car, readably, stream);
			} else {
				writeString(" . ", stream);
				writeObject(object, readably, stream);
				break;
			}
		}
		writeChar(')', stream);
		break;
#define CASE(type, name, object)                                             \
  case type:                                                                 \
    writeFmt(stream, "#<%s ", name);                                            \
    writeObject(object, readably, stream);                                     \
    writeChar('>', stream);                                                    \
    break
		CASE(TYPE_LAMBDA, "Lambda", object->params);
		CASE(TYPE_MACRO, "Macro", object->params);
		CASE(TYPE_ENV, "Env", object->vars);
#undef CASE
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl (%rdi), %eax
cmpq $0x7, %rax
ja 0x465a
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
leaq 0x3f6d(%rip), %rcx      # 0x841c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x10(%r14), %xmm0
leaq 0x41d0(%rip), %rsi      # 0x8695
movq %rbx, %rdi
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x428d
leaq 0x41d7(%rip), %rsi      # 0x86bb
leaq 0x41d6(%rip), %rdx      # 0x86c1
jmp 0x4616
testb %bpl, %bpl
je 0x4587
movl $0x22, %edi
movq %rbx, %rsi
callq 0x4350
addq $0x10, %r14
leaq 0x41a0(%rip), %r12      # 0x86b1
leaq 0x4196(%rip), %r13      # 0x86ae
leaq 0x4189(%rip), %rbp      # 0x86a8
leaq 0x418e(%rip), %r15      # 0x86b4
movb (%r14), %al
movzbl %al, %ecx
cmpl $0xc, %ecx
jle 0x4545
cmpl $0xd, %ecx
je 0x4554
cmpl $0x22, %ecx
je 0x4559
cmpl $0x5c, %ecx
jne 0x457a
movq %r15, %rdi
jmp 0x4565
cmpl $0x9, %ecx
je 0x455e
cmpl $0xa, %ecx
jne 0x4572
movq %r12, %rdi
jmp 0x4565
movq %r13, %rdi
jmp 0x4565
movq %rbp, %rdi
jmp 0x4565
leaq 0x4146(%rip), %rdi      # 0x86ab
movq %rbx, %rsi
callq 0x4208
incq %r14
jmp 0x4526
testl %ecx, %ecx
je 0x4669
movsbl %al, %edi
movq %rbx, %rsi
callq 0x4350
jmp 0x456d
addq $0x10, %r14
leaq 0x3fe9(%rip), %rsi      # 0x857b
movq %rbx, %rdi
movq %r14, %rdx
jmp 0x4645
movl $0x28, %edi
movq %rbx, %rsi
callq 0x4350
movq 0x10(%r14), %rdi
movzbl %bpl, %ebp
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4489
movq 0x18(%r14), %r14
cmpq 0x8c41(%rip), %r14      # 0xd208
je 0x468c
cmpl $0x3, (%r14)
jne 0x4670
movl $0x20, %edi
movq %rbx, %rsi
callq 0x4350
movq 0x10(%r14), %rdi
jmp 0x45b2
leaq 0x40ca(%rip), %rsi      # 0x86bb
leaq 0x40d6(%rip), %rdx      # 0x86ce
movq %rbx, %rdi
xorl %eax, %eax
callq 0x428d
movq 0x18(%r14), %rdi
jmp 0x4624
leaq 0x40ac(%rip), %rsi      # 0x86bb
leaq 0x40b2(%rip), %rdx      # 0x86c8
movq %rbx, %rdi
xorl %eax, %eax
callq 0x428d
movq 0x10(%r14), %rdi
movzbl %bpl, %esi
movq %rbx, %rdx
callq 0x4489
movl $0x3e, %edi
jmp 0x4691
movq 0x18(%r14), %rdx
leaq 0x4056(%rip), %rsi      # 0x8698
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x428d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x22, %edi
jmp 0x4691
leaq 0x4040(%rip), %rdi      # 0x86b7
movq %rbx, %rsi
callq 0x4208
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4489
movl $0x29, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4350