// File: /workspace/github_c_makefile_star2_O2/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 $0x118, %rsp            # imm = 0x118
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movl 0x106c1(%rip), %eax     # 0x247f8
leal 0x1(%rax), %ecx
movl %ecx, 0x106b8(%rip)     # 0x247f8
cmpq $0x1, %rdi
ja 0x1416c
testq %r15, %r15
leaq 0x91c3(%rip), %rax      # 0x1d313
leaq 0x91b8(%rip), %rsi      # 0x1d30f
cmoveq %rax, %rsi
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x2230
jmp 0x14391
cmpq 0xfe4d(%rip), %r15      # 0x23fc0
je 0x141de
movl %r15d, %ecx
andl $0x3, %ecx
cmpq $0x3, %rcx
je 0x141eb
cmpl $0x2, %ecx
jne 0x1420a
movq %r15, %rdi
callq 0x1697e
movq %rax, %r15
leaq 0x917b(%rip), %rsi      # 0x1d317
movq %rax, %rdi
callq 0x2140
movb (%r15,%rax), %bpl
testb %bpl, %bpl
je 0x141b6
pushq $0x22
popq %rdi
movq %rbx, %rsi
callq *%r14
movq %r15, %rdi
callq 0x20d0
cmpq $0xfb, %rax
jb 0x1422e
leaq 0x9155(%rip), %rsi      # 0x1d322
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2230
jmp 0x14240
movl $0x4c494e, 0x10(%rsp)   # imm = 0x4C494E
jmp 0x14391
shrq $0x2, %r15
leaq 0x94da(%rip), %rsi      # 0x1d6d0
leaq 0x10(%rsp), %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2230
jmp 0x14391
testq %r15, %r15
sete %dl
testq %rcx, %rcx
setne %cl
orb %dl, %cl
je 0x14268
leaq 0x911c(%rip), %rsi      # 0x1d33d
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
jmp 0x1438a
leaq 0x10(%rsp), %rdi
movl $0xff, %edx
movq %r15, %rsi
callq 0x2070
testb %bpl, %bpl
je 0x14391
leaq 0x10(%rsp), %rdi
callq 0x20d0
cltq
movb $0x22, 0x10(%rsp,%rax)
incl %eax
cltq
movb $0x0, 0x10(%rsp,%rax)
jmp 0x14391
cmpl $0x6, %eax
jl 0x1429e
movq %r15, %rdi
callq 0x191fb
movq %rax, %r12
movq %r15, %rdi
callq 0x19306
leaq 0x90a5(%rip), %rsi      # 0x1d32c
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2230
jmp 0x14391
movl %esi, %ebp
pushq $0x28
popq %rdi
movq %rbx, %rsi
callq *%r14
xorl %r13d, %r13d
pushq $0x20
popq %r12
cmpl $0x9, %r13d
je 0x1436e
movq %r15, %rdi
callq 0x191fb
movq %rax, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x14117
movq %r15, %rdi
callq 0x19306
cmpq 0xfcdf(%rip), %rax      # 0x23fc0
je 0x14368
movq %rax, %r15
testq %rax, %rax
je 0x14339
movl %r15d, %eax
andl $0x3, %eax
jne 0x14339
movl %r13d, 0xc(%rsp)
testl %ebp, %ebp
je 0x14323
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq *%r14
xorl %r13d, %r13d
cmpl 0x104e5(%rip), %r13d    # 0x247f8
jge 0x1432c
movl %r12d, %edi
movq %rbx, %rsi
callq *%r14
incl %r13d
jmp 0x1430c
movl %r12d, %edi
movq %rbx, %rsi
callq *%r14
movl 0xc(%rsp), %r13d
incl %r13d
jmp 0x142b0
pushq $0x20
popq %r12
movl %r12d, %edi
movq %rbx, %rsi
callq *%r14
pushq $0x3a
popq %rdi
movq %rbx, %rsi
callq *%r14
movl %r12d, %edi
movq %rbx, %rsi
callq *%r14
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x14117
cmpl $0x9, %r13d
jb 0x14377
leaq 0x8fc3(%rip), %rdx      # 0x1d338
jmp 0x1437e
leaq 0x7fcc(%rip), %rdx      # 0x1c34a
leaq 0x8faf(%rip), %rsi      # 0x1d334
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x2230
leaq 0x10(%rsp), %r15
movb $0x0, 0xff(%r15)
movb (%r15), %al
testb %al, %al
je 0x143b3
incq %r15
movsbl %al, %edi
movq %rbx, %rsi
callq *%r14
jmp 0x1439e
decl 0x1043f(%rip)           # 0x247f8
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq