// File: /workspace/github_c_makefile_star2_O1/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 0x4662
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
leaq 0x3f65(%rip), %rcx      # 0x841c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x10(%r14), %xmm0
leaq 0x41c8(%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 0x4295
leaq 0x41cf(%rip), %rsi      # 0x86bb
leaq 0x41ce(%rip), %rdx      # 0x86c1
jmp 0x461e
testb %bpl, %bpl
je 0x458f
movl $0x22, %edi
movq %rbx, %rsi
callq 0x4358
addq $0x10, %r14
leaq 0x4198(%rip), %r12      # 0x86b1
leaq 0x418e(%rip), %r13      # 0x86ae
leaq 0x4181(%rip), %rbp      # 0x86a8
leaq 0x4186(%rip), %r15      # 0x86b4
movb (%r14), %al
movzbl %al, %ecx
cmpl $0xc, %ecx
jle 0x454d
cmpl $0xd, %ecx
je 0x455c
cmpl $0x22, %ecx
je 0x4561
cmpl $0x5c, %ecx
jne 0x4582
movq %r15, %rdi
jmp 0x456d
cmpl $0x9, %ecx
je 0x4566
cmpl $0xa, %ecx
jne 0x457a
movq %r12, %rdi
jmp 0x456d
movq %r13, %rdi
jmp 0x456d
movq %rbp, %rdi
jmp 0x456d
leaq 0x413e(%rip), %rdi      # 0x86ab
movq %rbx, %rsi
callq 0x4210
incq %r14
jmp 0x452e
testl %ecx, %ecx
je 0x4671
movsbl %al, %edi
movq %rbx, %rsi
callq 0x4358
jmp 0x4575
addq $0x10, %r14
leaq 0x3fe1(%rip), %rsi      # 0x857b
movq %rbx, %rdi
movq %r14, %rdx
jmp 0x464d
movl $0x28, %edi
movq %rbx, %rsi
callq 0x4358
movq 0x10(%r14), %rdi
movzbl %bpl, %ebp
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4491
movq 0x18(%r14), %r14
cmpq 0x8c39(%rip), %r14      # 0xd208
je 0x4694
cmpl $0x3, (%r14)
jne 0x4678
movl $0x20, %edi
movq %rbx, %rsi
callq 0x4358
movq 0x10(%r14), %rdi
jmp 0x45ba
leaq 0x40c2(%rip), %rsi      # 0x86bb
leaq 0x40ce(%rip), %rdx      # 0x86ce
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4295
movq 0x18(%r14), %rdi
jmp 0x462c
leaq 0x40a4(%rip), %rsi      # 0x86bb
leaq 0x40aa(%rip), %rdx      # 0x86c8
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4295
movq 0x10(%r14), %rdi
movzbl %bpl, %esi
movq %rbx, %rdx
callq 0x4491
movl $0x3e, %edi
jmp 0x4699
movq 0x18(%r14), %rdx
leaq 0x404e(%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 0x4295
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x22, %edi
jmp 0x4699
leaq 0x4038(%rip), %rdi      # 0x86b7
movq %rbx, %rsi
callq 0x4210
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4491
movl $0x29, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4358