// File: /workspace/github_c_makefile_star2_O0/phluid61[P]hsf/src/integer.c
// Function: SH_Integer__to_s
sh_char_t*
SH_Integer__to_s(SH_Integer* obj, int* err) {
	sh_char_t* str;
	sh_char_t* ptr;
	sh_char_t  buffer[17]; /* sign(1) + digits(15) + null(1) */
	size_t n;
	sh_int_t v;

	__cascade(err, (sh_char_t*)0);

	if (obj->value == SH_INT_C(0)) {
		str = (sh_char_t*)malloc(sizeof(sh_char_t) * 2);
		if ((sh_char_t*)0 == str) {
			__raise(err, SH_E_MALLOC_ERROR);
			return (sh_char_t*)0;
		}

		str[0] = (sh_char_t)'0';
		str[1] = SH_CHAR_C(0);
		__clear(err);
		return str;
	}

	n = 0;
	v = SH_Integer__abs(obj, err);

	buffer[n++] = SH_CHAR_C(0);

	while (v > SH_INT_C(0) && n <= 16) {
		buffer[n++] = (sh_char_t)(v % 10) + (sh_char_t)'0';
		v /= SH_INT_C(10);
	}

	/* FIXME: if v > 0: invalid state? */

	if (SH_Integer__negative(obj, err)) {
		buffer[n++] = (sh_char_t)'-';
	}

	str = (sh_char_t*)malloc(sizeof(sh_char_t) * n);
	if ((sh_char_t*)0 == str) {
		__raise(err, SH_E_MALLOC_ERROR);
		return (sh_char_t*)0;
	}

	ptr = str;
	while (n > 0) {
		n--;
		*ptr = buffer[n];
		ptr++;
	}

	__clear(err);
	return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
xorl %eax, %eax
cmpq -0x18(%rbp), %rax
je 0x2dff
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl (%rcx), %eax
je 0x2dff
movq $0x0, -0x8(%rbp)
jmp 0x2fa3
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2e6c
movl $0x2, %edi
callq 0x1090
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq -0x20(%rbp), %rax
jne 0x2e3e
xorl %eax, %eax
cmpq -0x18(%rbp), %rax
je 0x2e31
movq -0x18(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
movq $0x0, -0x8(%rbp)
jmp 0x2fa3
movq -0x20(%rbp), %rax
movb $0x30, (%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x1(%rax)
xorl %eax, %eax
cmpq -0x18(%rbp), %rax
je 0x2e5f
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fa3
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2d40
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movb $0x0, -0x40(%rbp,%rax)
xorl %eax, %eax
cmpq $0x0, -0x50(%rbp)
movb %al, -0x51(%rbp)
jle 0x2eb0
cmpq $0x10, -0x48(%rbp)
setbe %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x2eb9
jmp 0x2ef8
movq -0x50(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movb %dl, %al
movzbl %al, %eax
addl $0x30, %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x48(%rbp)
movb %cl, -0x40(%rbp,%rax)
movq -0x50(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, -0x50(%rbp)
jmp 0x2e99
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2cf0
cmpb $0x0, %al
je 0x2f1d
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movb $0x2d, -0x40(%rbp,%rax)
movq -0x48(%rbp), %rdi
shlq $0x0, %rdi
callq 0x1090
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq -0x20(%rbp), %rax
jne 0x2f52
xorl %eax, %eax
cmpq -0x18(%rbp), %rax
je 0x2f48
movq -0x18(%rbp), %rax
movl $0x80000001, (%rax)     # imm = 0x80000001
movq $0x0, -0x8(%rbp)
jmp 0x2fa3
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x48(%rbp)
jbe 0x2f89
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movb -0x40(%rbp,%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x2f5a
xorl %eax, %eax
cmpq -0x18(%rbp), %rax
je 0x2f9b
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)