// File: /workspace/github_c_makefile_star2_O3/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 0xf33e(%rip), %r14      # 0x22fc0
je 0x13cb1
cmpq $0x1, %r14
ja 0x13cc2
testq %r14, %r14
leaq 0xa270(%rip), %rax      # 0x1df04
leaq 0xa233(%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 0x13d0c
cmpl $0x2, %eax
jne 0x13d2e
movq %r14, %rdi
callq 0x1715e
movq %rax, %r14
leaq 0x9c1e(%rip), %rsi      # 0x1d903
movq %rax, %rdi
callq 0x2140
movb (%r14,%rax), %bpl
movb $0x23, (%rbx)
testb %bpl, %bpl
je 0x13d90
movb $0x22, 0x1(%rbx)
movl $0x2, %r15d
jmp 0x13d96
shrq $0x2, %r14
leaq 0x99d9(%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 0x13dee
cmpl $0x1, %eax
jne 0x13df9
movq %r14, %rdi
callq 0x11d2c
leaq 0x9bca(%rip), %rsi      # 0x1d918
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2220
decl %ebp
movq %r14, %rdi
callq 0x11d65
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x16dfd
movq %rbx, %rdi
callq 0x20d0
cmpl $0x3fd, %eax            # imm = 0x3FD
jg 0x13cb7
cltq
movb $0x5d, (%rbx,%rax)
jmp 0x13de1
movl $0x1, %r15d
movq %r14, %rdi
callq 0x20d0
addq %rbx, %r15
cmpq $0xfa, %rax
jb 0x13dbf
leaq 0x9b5e(%rip), %rsi      # 0x1d90e
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2220
jmp 0x13dca
movq %r15, %rdi
movq %r14, %rsi
callq 0x2090
testb %bpl, %bpl
je 0x13cb7
movq %rbx, %rdi
callq 0x20d0
cltq
movb $0x22, (%rbx,%rax)
incl %eax
cltq
movb $0x0, (%rbx,%rax)
jmp 0x13cb7
movl $0x2e2e2e, (%rbx)       # imm = 0x2E2E2E
jmp 0x13cb7
testq %r14, %r14
je 0x13e30
movw $0x28, (%rbx)
movl %ebp, %edi
movl $0x6, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x16e68
movq %rbx, %rdi
callq 0x20d0
cmpl $0x3fd, %eax            # imm = 0x3FD
jg 0x13cb7
cltq
movb $0x29, (%rbx,%rax)
jmp 0x13de1
leaq 0xa29a(%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