// File: /workspace/github_c_makefile_star2_O2/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 0x10878(%rip), %r14     # 0x23fc0
je 0x13777
cmpq $0x1, %r14
ja 0x13788
testq %r14, %r14
leaq 0xa78a(%rip), %rax      # 0x1dee4
leaq 0xa74d(%rip), %rsi      # 0x1deae
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 0x137ce
cmpl $0x2, %eax
jne 0x137f0
movq %r14, %rdi
callq 0x1697e
movq %rax, %r14
leaq 0xa138(%rip), %rsi      # 0x1d8e3
movq %rax, %rdi
callq 0x2140
movb (%r14,%rax), %bpl
movb $0x23, (%rbx)
testb %bpl, %bpl
je 0x13852
movb $0x22, 0x1(%rbx)
pushq $0x2
jmp 0x13854
shrq $0x2, %r14
leaq 0x9ef7(%rip), %rsi      # 0x1d6d0
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2230
testl %ebp, %ebp
js 0x138ae
cmpl $0x1, %eax
jne 0x138b9
movq %r14, %rdi
callq 0x11724
leaq 0xa0e8(%rip), %rsi      # 0x1d8f8
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2230
decl %ebp
movq %r14, %rdi
callq 0x1175b
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x16659
movq %rbx, %rdi
callq 0x20d0
cmpl $0x3fd, %eax            # imm = 0x3FD
jg 0x1377d
cltq
movb $0x5d, (%rbx,%rax)
jmp 0x138a1
pushq $0x1
popq %r15
movq %r14, %rdi
callq 0x20d0
addq %rbx, %r15
cmpq $0xfa, %rax
jb 0x1387f
leaq 0xa07e(%rip), %rsi      # 0x1d8ee
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2230
jmp 0x1388a
movq %r15, %rdi
movq %r14, %rsi
callq 0x2090
testb %bpl, %bpl
je 0x1377d
movq %rbx, %rdi
callq 0x20d0
cltq
movb $0x22, (%rbx,%rax)
incl %eax
cltq
movb $0x0, (%rbx,%rax)
jmp 0x1377d
movl $0x2e2e2e, (%rbx)       # imm = 0x2E2E2E
jmp 0x1377d
testq %r14, %r14
je 0x138ee
movw $0x28, (%rbx)
pushq $0x6
popq %rsi
movl %ebp, %edi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x166c4
movq %rbx, %rdi
callq 0x20d0
cmpl $0x3fd, %eax            # imm = 0x3FD
jg 0x1377d
cltq
movb $0x29, (%rbx,%rax)
jmp 0x138a1
leaq 0xa7bc(%rip), %rsi      # 0x1e0b1
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2230