// File: /workspace/github_c_makefile_star2_O2/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 0x4468
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
leaq 0x316f(%rip), %rcx      # 0x741c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x10(%r14), %xmm0
leaq 0x33ca(%rip), %rsi      # 0x768d
movq %rbx, %rdi
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4095
leaq 0x33d1(%rip), %rsi      # 0x76b3
leaq 0x33d0(%rip), %rdx      # 0x76b9
jmp 0x4412
testb %bpl, %bpl
je 0x437c
pushq $0x22
popq %rdi
movq %rbx, %rsi
callq 0x4158
addq $0x10, %r14
leaq 0x339c(%rip), %r12      # 0x76a9
leaq 0x3392(%rip), %r13      # 0x76a6
leaq 0x3385(%rip), %rbp      # 0x76a0
leaq 0x338a(%rip), %r15      # 0x76ac
movzbl (%r14), %eax
cmpl $0x9, %eax
je 0x435e
cmpl $0xa, %eax
je 0x436c
cmpl $0xd, %eax
je 0x4354
cmpl $0x22, %eax
je 0x4367
cmpl $0x5c, %eax
je 0x4359
testl %eax, %eax
je 0x4477
movsbl %al, %edi
movq %rbx, %rsi
callq 0x4158
jmp 0x4377
movq %r13, %rdi
jmp 0x436f
movq %r15, %rdi
jmp 0x436f
leaq 0x333e(%rip), %rdi      # 0x76a3
jmp 0x436f
movq %rbp, %rdi
jmp 0x436f
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4010
incq %r14
jmp 0x4322
addq $0x10, %r14
leaq 0x31ec(%rip), %rsi      # 0x7573
movq %rbx, %rdi
movq %r14, %rdx
jmp 0x4453
movb $0x28, %al
movzbl %bpl, %ebp
movsbl %al, %edi
movq %rbx, %rsi
callq 0x4158
movq 0x10(%r14), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4287
movq 0x18(%r14), %r14
cmpq 0x7e4c(%rip), %r14      # 0xc208
je 0x43e2
movb $0x20, %al
cmpl $0x3, (%r14)
je 0x4398
leaq 0x32e2(%rip), %rdi      # 0x76af
movq %rbx, %rsi
callq 0x4010
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4287
pushq $0x29
jmp 0x442e
leaq 0x32c6(%rip), %rsi      # 0x76b3
leaq 0x32d2(%rip), %rdx      # 0x76c6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4095
movq 0x18(%r14), %rdi
jmp 0x4420
leaq 0x32a8(%rip), %rsi      # 0x76b3
leaq 0x32ae(%rip), %rdx      # 0x76c0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4095
movq 0x10(%r14), %rdi
movzbl %bpl, %esi
movq %rbx, %rdx
callq 0x4287
pushq $0x3e
popq %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4158
movq 0x18(%r14), %rdx
leaq 0x3240(%rip), %rsi      # 0x7690
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4095
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x22
jmp 0x442e