// File: /workspace/github_c_makefile_star2_O2/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_dtoa
NK_LIB char*
nk_dtoa(char *s, double n)
{
    int useExp = 0;
    int digit = 0, m = 0, m1 = 0;
    char *c = s;
    int neg = 0;

    NK_ASSERT(s);
    if (!s) return 0;

    if (n == 0.0) {
        s[0] = '0'; s[1] = '\0';
        return s;
    }

    neg = (n < 0);
    if (neg) n = -n;

    /* calculate magnitude */
    m = nk_log10(n);
    useExp = (m >= 14 || (neg && m >= 9) || m <= -9);
    if (neg) *(c++) = '-';

    /* set up for scientific notation */
    if (useExp) {
        if (m < 0)
           m -= 1;
        n = n / (double)nk_pow(10.0, m);
        m1 = m;
        m = 0;
    }
    if (m < 1.0) {
        m = 0;
    }

    /* convert the number */
    while (n > NK_FLOAT_PRECISION || m >= 0) {
        double weight = nk_pow(10.0, m);
        if (weight > 0) {
            double t = (double)n / weight;
            digit = nk_ifloord(t);
            n -= ((double)digit * weight);
            *(c++) = (char)('0' + (char)digit);
        }
        if (m == 0 && n > 0)
            *(c++) = '.';
        m--;
    }

    if (useExp) {
        /* convert the exponent */
        int i, j;
        *(c++) = 'e';
        if (m1 > 0) {
            *(c++) = '+';
        } else {
            *(c++) = '-';
            m1 = -m1;
        }
        m = 0;
        while (m1 > 0) {
            *(c++) = (char)('0' + (char)(m1 % 10));
            m1 /= 10;
            m++;
        }
        c -= m;
        for (i = 0, j = m-1; i<j; i++, j--) {
            /* swap without temporary */
            c[i] ^= c[j];
            c[j] ^= c[i];
            c[i] ^= c[j];
        }
        c += m;
    }
    *(c) = '\0';
    return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testq %rdi, %rdi
je 0x54098
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x540c9
jp 0x540c9
movw $0x30, (%rbx)
jmp 0x54257
movq 0x30f51(%rip), %r14     # 0x84ff0
movq (%r14), %rdi
leaq 0x15c63(%rip), %rsi     # 0x69d0c
leaq 0x15c7a(%rip), %rdx     # 0x69d2a
movl $0x1b6c, %ecx           # imm = 0x1B6C
xorl %eax, %eax
callq 0x12ea0
movq (%r14), %rdi
callq 0x13960
jmp 0x54257
movapd 0x1273f(%rip), %xmm1    # 0x66810
movapd %xmm0, %xmm2
xorpd %xmm1, %xmm2
maxsd %xmm0, %xmm2
xorpd %xmm2, %xmm1
maxsd %xmm2, %xmm1
cvttsd2si %xmm1, %eax
xorl %ecx, %ecx
pushq $0xa
popq %r15
cmpl $0xa, %eax
jl 0x540fd
xorl %edx, %edx
divl %r15d
incl %ecx
jmp 0x540ef
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
movl %ecx, %r14d
negl %r14d
ucomisd %xmm2, %xmm1
cmovbel %ecx, %r14d
cmpl $0x9, %r14d
setge %cl
andb %al, %cl
leal -0xe(%r14), %eax
cmpl $-0x16, %eax
setb %r13b
orb %cl, %r13b
ucomisd %xmm0, %xmm1
movq %rbx, %r12
jbe 0x5413d
leaq 0x1(%rbx), %r12
movb $0x2d, (%rbx)
testb %r13b, %r13b
je 0x54165
movl %r14d, %ebp
sarl $0x1f, %ebp
addl %r14d, %ebp
movl %ebp, %edi
movapd %xmm2, (%rsp)
callq 0x5429d
movapd (%rsp), %xmm2
divsd %xmm0, %xmm2
xorl %r14d, %r14d
jmp 0x541d3
xorl %ebp, %ebp
testl %r14d, %r14d
cmovlel %ebp, %r14d
jmp 0x541d3
movapd %xmm2, (%rsp)
movl %r14d, %edi
callq 0x5429d
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm0
jbe 0x541ba
movapd (%rsp), %xmm2
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
xorl %ecx, %ecx
ucomisd %xmm1, %xmm3
seta %cl
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm2
addb $0x30, %al
movb %al, (%r12)
incq %r12
jmp 0x541bf
movapd (%rsp), %xmm2
subl $0x1, %r14d
jae 0x541d3
ucomisd %xmm3, %xmm2
jbe 0x541d3
movb $0x2e, (%r12)
incq %r12
ucomisd 0x12785(%rip), %xmm2    # 0x66960
ja 0x54170
testl %r14d, %r14d
jns 0x54170
testb %r13b, %r13b
je 0x54252
movb $0x65, (%r12)
testl %ebp, %ebp
setle %cl
addb %cl, %cl
addb $0x2b, %cl
movl %ebp, %eax
negl %eax
cmovsl %ebp, %eax
movb %cl, 0x1(%r12)
pushq $0x2
popq %rcx
testl %eax, %eax
je 0x5421a
xorl %edx, %edx
divl %r15d
orb $0x30, %dl
movb %dl, (%r12,%rcx)
incq %rcx
jmp 0x54205
leaq (%r12,%rcx), %rax
addq $-0x3, %rcx
xorl %edx, %edx
cmpq %rcx, %rdx
jge 0x5424f
movb 0x2(%r12,%rdx), %sil
xorb 0x2(%r12,%rcx), %sil
movb %sil, 0x2(%r12,%rdx)
xorb 0x2(%r12,%rcx), %sil
movb %sil, 0x2(%r12,%rcx)
xorb %sil, 0x2(%r12,%rdx)
incq %rdx
decq %rcx
jmp 0x54224
movq %rax, %r12
movb $0x0, (%r12)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq