// File: /workspace/github_c_makefile_star2_O3/dalnefre[P]kernel_abe/emit.c
// Function: emit_cons
void
emit_cons(CONS* cons, int indent, void (*emit)(char c, void* ctx), void* ctx)
{
	char buf[256];
	int emit_length = 0;
	int i;
	char c;
	char *p;

	XDBUG_ENTER("emit_cons");
	++emit_depth;
	if (boolp(cons)) {
		sprintf(buf, cons ? "-T-" : "-F-");
	} else if (nilp(cons)) {
		sprintf(buf, "NIL");
	} else if (atomp(cons)) {
		char *s = atom_str(cons);
		int qtd = s[strcspn(s, REDUCE_TOKEN_BRKS)]; /* look for special chars */

		if (qtd) {
			(*emit)('"', ctx);
		}
		if (strlen(s) > 250) {
			sprintf(buf, "%.250s...", s);
		} else {
			strncpy(buf, s, 255);
		}
		if (qtd) {
			int n = strlen(buf);

			buf[n++] = '"';
			buf[n] = '\0';
		}
	} else if (numberp(cons)) {
		sprintf(buf, "%d", MK_INT(cons));
#if NUMBER_IS_FUNC
#else
	} else if (funcp(cons)) {
		sprintf(buf, "@%p", MK_PTR(cons));
#endif
	} else if (consp(cons)) {
		if (emit_depth > EMIT_DEPTH_LIMIT) {
			sprintf(buf, "[%p;%p]", (void*)car(cons), (void*)cdr(cons));
		} else {
			(*emit)('(', ctx);
			for (emit_length = 0; emit_length < EMIT_LENGTH_LIMIT; ++emit_length) {
				emit_cons(car(cons), indent, emit, ctx);
				cons = cdr(cons);
				if (nilp(cons)) {
					break;
				} else if (!consp(cons)) {
					(*emit)(' ', ctx);
					(*emit)(':', ctx);
					(*emit)(' ', ctx);
					emit_cons(cons, indent, emit, ctx);
					break;
				}
				if (indent) {
					(*emit)('\n', ctx);
					for (i = 0; i < emit_depth; ++i) {
						(*emit)(' ', ctx);
					}
				} else {
					(*emit)(' ', ctx);
				}
			}
			sprintf(buf, "%s)", (emit_length >= EMIT_LENGTH_LIMIT) ? "... " : "");
		}
	} else {
		sprintf(buf, "#%p", (void*)cons);
	}
	/* tie off the buffer and safely stream it out one character at a time */
	buf[255] = '\0';
	p = buf;
	while ((c = *p++) != '\0') {
		(*emit)(c, ctx);
	}
	--emit_depth;
	XDBUG_RETURN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movl 0xf030(%rip), %eax      # 0x237f8
leal 0x1(%rax), %ecx
movl %ecx, 0xf027(%rip)      # 0x237f8
cmpq $0x1, %rdi
ja 0x1480e
testq %r15, %r15
leaq 0x8b52(%rip), %rax      # 0x1d333
leaq 0x8b47(%rip), %rsi      # 0x1d32f
cmoveq %rax, %rsi
movq %rsp, %rdi
xorl %eax, %eax
callq 0x2220
movb (%rsp), %al
movb $0x0, 0xff(%rsp)
testb %al, %al
jne 0x1489c
jmp 0x148b4
cmpq 0xe7ab(%rip), %r15      # 0x22fc0
je 0x1488b
movl %r15d, %ecx
andl $0x3, %ecx
cmpq $0x3, %rcx
je 0x148cc
cmpl $0x2, %ecx
jne 0x148e9
movq %r15, %rdi
callq 0x1715e
movq %rax, %r15
leaq 0x8af5(%rip), %rsi      # 0x1d337
movq %rax, %rdi
callq 0x2140
movb (%r15,%rax), %bpl
testb %bpl, %bpl
je 0x1485e
movl $0x22, %edi
movq %rbx, %rsi
callq *%r14
movq %r15, %rdi
callq 0x20d0
cmpq $0xfb, %rax
jb 0x1490b
leaq 0x8ac9(%rip), %rsi      # 0x1d342
movq %rsp, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2220
jmp 0x1491b
movl $0x4c494e, (%rsp)       # imm = 0x4C494E
movb $0x0, 0xff(%rsp)
movb $0x4e, %al
leaq 0x1(%rsp), %r15
movsbl %al, %edi
movq %rbx, %rsi
callq *%r14
movb (%r15), %al
incq %r15
testb %al, %al
jne 0x148a1
decl 0xef3e(%rip)            # 0x237f8
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shrq $0x2, %r15
leaq 0x8e19(%rip), %rsi      # 0x1d6f0
movq %rsp, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2220
jmp 0x147f6
testq %r15, %r15
sete %dl
testq %rcx, %rcx
setne %cl
orb %dl, %cl
je 0x1493f
leaq 0x8a5d(%rip), %rsi      # 0x1d35d
movq %rsp, %rdi
movq %r15, %rdx
jmp 0x14a5f
movq %rsp, %rdi
movl $0xff, %edx
movq %r15, %rsi
callq 0x2070
testb %bpl, %bpl
je 0x147f6
movq %rsp, %rdi
callq 0x20d0
cltq
movb $0x22, (%rsp,%rax)
incl %eax
cltq
movb $0x0, (%rsp,%rax)
jmp 0x147f6
cmpl $0x6, %eax
jl 0x14973
movq %r15, %rdi
callq 0x19c72
movq %rax, %r12
movq %r15, %rdi
callq 0x19d11
leaq 0x89ee(%rip), %rsi      # 0x1d34c
movq %rsp, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2220
jmp 0x147f6
movl %esi, %ebp
movl $0x28, %edi
movq %rbx, %rsi
callq *%r14
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x19c72
movq %rax, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x147a8
movq %r15, %rdi
callq 0x19d11
cmpq 0xe616(%rip), %rax      # 0x22fc0
je 0x14a3f
movq %rax, %r15
testq %rax, %rax
je 0x14a0e
movl %r15d, %eax
andl $0x3, %eax
jne 0x14a0e
testl %ebp, %ebp
je 0x149f4
movl $0xa, %edi
movq %rbx, %rsi
callq *%r14
cmpl $0x0, 0xee22(%rip)      # 0x237f8
jle 0x149ff
xorl %r13d, %r13d
movl $0x20, %edi
movq %rbx, %rsi
callq *%r14
incl %r13d
cmpl 0xee08(%rip), %r13d     # 0x237f8
jl 0x149db
jmp 0x149ff
movl $0x20, %edi
movq %rbx, %rsi
callq *%r14
incl %r12d
cmpl $0x9, %r12d
jne 0x14983
jmp 0x14a45
movl $0x20, %edi
movq %rbx, %rsi
callq *%r14
movl $0x3a, %edi
movq %rbx, %rsi
callq *%r14
movl $0x20, %edi
movq %rbx, %rsi
callq *%r14
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x147a8
cmpl $0x9, %r12d
jb 0x14a4e
leaq 0x890c(%rip), %rdx      # 0x1d358
jmp 0x14a55
leaq 0x78f5(%rip), %rdx      # 0x1c34a
leaq 0x88f8(%rip), %rsi      # 0x1d354
movq %rsp, %rdi
xorl %eax, %eax
callq 0x2220
jmp 0x147f6