// File: /workspace/github_c_makefile_star2_O1/dalnefre[P]kernel_abe/emit.c
// Function: depth_to_str
static void
depth_to_str(int depth, char* buf, CONS* cons)
{
	XDBUG_ENTER("depth_to_str");
	XDBUG_PRINT("", ("depth = %d", depth));
	strncpy(buf, "", CONS_BUFSZ);	/* zero buffer */
	if (nilp(cons)) {
		strcpy(buf, "NIL");
	} else if (boolp(cons)) {
		strcpy(buf, (cons ? "TRUE" : "FALSE"));
	} else if (atomp(cons)) {
		char *q = atom_str(cons);
		int n = 0;
		int qtd = q[strcspn(q, HUMUS_TOKEN_BRKS)]; /* look for special chars */

		buf[n++] = '#';
		if (qtd) {
			buf[n++] = '"';
		}
		if (strlen(q) > 249) {
			sprintf((buf + n), "%.249s...", q);
		} else {
			strcpy((buf + n), q);
		}
		if (qtd) {
			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, "^%lx", (ulint)MK_PTR(cons));
#endif
	} else if (depth < 0) {			/* depth limit */
		strcpy(buf, "...");
	} else if (actorp(cons)) {
		int n = 0;

		XDBUG_PRINT("", ("actor = @%lx[^%lx, 16#%08lx]", 
			(ulint)cons, (ulint)_THIS(cons), (ulint)_MINE(cons)));
		sprintf(buf, "@%lx[^%lx, ", (ulint)cons, (ulint)_THIS(cons));
		child_to_str((depth - 1), buf, _MINE(cons));
		n = strlen(buf);
		if (n < (CONS_BUFSZ - 2)) {
			buf[n++] = ']';
			buf[n] = '\0';
		}
	} else if (consp(cons)) {
		int n = 0;

		XDBUG_PRINT("", ("cons = (16#%08lx, 16#%08lx)", 
			(ulint)car(cons), (ulint)cdr(cons)));
		buf[n++] = '(';
		buf[n] = '\0';
		tail_to_str(depth, TAIL_LENGTH, buf, cons);
		n = strlen(buf);
		if (n < (CONS_BUFSZ - 2)) {
			buf[n++] = ')';
			buf[n] = '\0';
		}
	} else {
		sprintf(buf, "16#%08lx", (ulint)cons);
	}
	XDBUG_PRINT("", ("buf = %s", buf));
	XDBUG_RETURN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movl %edi, %ebp
movl $0x400, %edx            # imm = 0x400
movq %rsi, %rdi
xorl %esi, %esi
callq 0x2110
cmpq 0xf3e2(%rip), %r14      # 0x22fc0
je 0x13c0d
cmpq $0x1, %r14
ja 0x13c1e
testq %r14, %r14
leaq 0xa314(%rip), %rax      # 0x1df04
leaq 0xa2d7(%rip), %rsi      # 0x1dece
cmoveq %rax, %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2090
movl $0x4c494e, (%rbx)       # imm = 0x4C494E
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, %eax
andl $0x3, %eax
cmpq $0x3, %rax
je 0x13c68
cmpl $0x2, %eax
jne 0x13c8a
movq %r14, %rdi
callq 0x170e9
movq %rax, %r14
leaq 0x9cc2(%rip), %rsi      # 0x1d903
movq %rax, %rdi
callq 0x2140
movb (%r14,%rax), %bpl
movb $0x23, (%rbx)
testb %bpl, %bpl
je 0x13cec
movb $0x22, 0x1(%rbx)
movl $0x2, %r15d
jmp 0x13cf2
shrq $0x2, %r14
leaq 0x9a7d(%rip), %rsi      # 0x1d6f0
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2220
testl %ebp, %ebp
js 0x13d4a
cmpl $0x1, %eax
jne 0x13d55
movq %r14, %rdi
callq 0x11cd8
leaq 0x9c6e(%rip), %rsi      # 0x1d918
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2220
decl %ebp
movq %r14, %rdi
callq 0x11d11
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x16d86
movq %rbx, %rdi
callq 0x20d0
cmpl $0x3fd, %eax            # imm = 0x3FD
jg 0x13c13
cltq
movb $0x5d, (%rbx,%rax)
jmp 0x13d3d
movl $0x1, %r15d
movq %r14, %rdi
callq 0x20d0
addq %rbx, %r15
cmpq $0xfa, %rax
jb 0x13d1b
leaq 0x9c02(%rip), %rsi      # 0x1d90e
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2220
jmp 0x13d26
movq %r15, %rdi
movq %r14, %rsi
callq 0x2090
testb %bpl, %bpl
je 0x13c13
movq %rbx, %rdi
callq 0x20d0
cltq
movb $0x22, (%rbx,%rax)
incl %eax
cltq
movb $0x0, (%rbx,%rax)
jmp 0x13c13
movl $0x2e2e2e, (%rbx)       # imm = 0x2E2E2E
jmp 0x13c13
testq %r14, %r14
sete %cl
testq %rax, %rax
setne %al
orb %cl, %al
je 0x13d83
leaq 0xa365(%rip), %rsi      # 0x1e0d1
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2220
movw $0x28, (%rbx)
movl %ebp, %edi
movl $0x6, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x16df1
movq %rbx, %rdi
callq 0x20d0
cmpl $0x3fd, %eax            # imm = 0x3FD
jg 0x13c13
cltq
movb $0x29, (%rbx,%rax)
jmp 0x13d3d