// File: /workspace/github_c_makefile_star2_O0/hoobaa[P]ficl/utility.c
// Function: ficlLtoa
char *ficlLtoa( ficlInteger value, char *string, int radix )
{                               /* convert long to string, any base */
    char *cp = string;
    int sign = ((radix == 10) && (value < 0));
    int pwr;

    FICL_ASSERT(NULL, radix > 1);
    FICL_ASSERT(NULL, radix < 37);
    FICL_ASSERT(NULL, string);

    pwr = ficlIsPowerOfTwo((ficlUnsigned)radix);

    if (sign)
        value = -value;

    if (value == 0)
        *cp++ = '0';
    else if (pwr != 0)
    {
        ficlUnsigned v = (ficlUnsigned) value;
        ficlUnsigned mask = (ficlUnsigned) ~(-1 << pwr);
        while (v)
        {
            *cp++ = digits[v & mask];
            v >>= pwr;
        }
    }
    else
    {
        ficl2UnsignedQR result;
        ficl2Unsigned v;
		FICL_UNSIGNED_TO_2UNSIGNED((ficlUnsigned)value, v);
        while (FICL_2UNSIGNED_NOT_ZERO(v))
        {
            result = ficl2UnsignedDivide(v, (ficlUnsigned)radix);
            *cp++ = digits[result.remainder];
			v = result.quotient;
        }
    }

    if (sign)
        *cp++ = '-';

    *cp++ = '\0';

    return ficlStringReverse(string);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpl $0xa, -0x14(%rbp)
movb %al, -0x89(%rbp)
jne 0xfc6a
cmpq $0x0, -0x8(%rbp)
setl %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movslq -0x14(%rbp), %rdi
callq 0xfbc0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xfc94
xorl %eax, %eax
subq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xfcb2
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0x30, (%rax)
jmp 0xfdc8
cmpl $0x0, -0x28(%rbp)
je 0xfd14
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x28(%rbp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
xorl $-0x1, %eax
cltq
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xfd0f
movq -0x30(%rbp), %rcx
andq -0x38(%rbp), %rcx
leaq 0xf1f7(%rip), %rax      # 0x1eee0
movb (%rax,%rcx), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movl -0x28(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x30(%rbp)
jmp 0xfcd3
jmp 0xfdc6
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movb $0x1, %al
cmpq $0x0, -0x60(%rbp)
movb %al, -0x8a(%rbp)
jne 0xfd51
cmpq $0x0, -0x58(%rbp)
setne %al
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
testb $0x1, %al
jne 0xfd5d
jmp 0xfdc4
movslq -0x14(%rbp), %rcx
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x88(%rbp), %rdi
callq 0x13740
movq -0x88(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
leaq 0xf145(%rip), %rax      # 0x1eee0
movb (%rax,%rcx), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0xfd34
jmp 0xfdc6
jmp 0xfdc8
cmpl $0x0, -0x24(%rbp)
je 0xfde0
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0x2d, (%rax)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
callq 0xfb10
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)