// File: /workspace/github_c_makefile_star2_O1/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 %rbx
testq %rdi, %rdi
je 0x5a4e0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5a50d
jp 0x5a50d
movw $0x30, (%rdi)
jmp 0x5a741
movq 0x2db09(%rip), %rbx     # 0x87ff0
movq (%rbx), %rdi
leaq 0x1789b(%rip), %rsi     # 0x71d8c
leaq 0x178b2(%rip), %rdx     # 0x71daa
movl $0x1b6c, %ecx           # imm = 0x1B6C
xorl %eax, %eax
callq 0x12d80
movq (%rbx), %rdi
popq %rbx
jmp 0x13780
movapd 0x1437b(%rip), %xmm2    # 0x6e890
movapd %xmm0, %xmm1
xorpd %xmm2, %xmm1
maxsd %xmm0, %xmm1
xorpd %xmm1, %xmm2
maxsd %xmm1, %xmm2
cvttsd2si %xmm2, %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
jl 0x5a54e
xorl %eax, %eax
movl $0xcccccccd, %edx       # imm = 0xCCCCCCCD
movl %ecx, %esi
imulq %rdx, %rsi
shrq $0x23, %rsi
incl %eax
cmpl $0x63, %ecx
movl %esi, %ecx
ja 0x5a53b
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm2
seta %cl
movl %eax, %esi
negl %esi
ucomisd %xmm1, %xmm2
cmovbel %eax, %esi
cmpl $0x9, %esi
setge %al
andb %cl, %al
leal -0xe(%rsi), %ecx
cmpl $-0x16, %ecx
setb %cl
orb %al, %cl
ucomisd %xmm0, %xmm2
jbe 0x5a583
movb $0x2d, (%rdi)
incq %rdi
xorl %edx, %edx
testb %cl, %cl
je 0x5a5e5
movl %esi, %eax
sarl $0x1f, %eax
movsd 0x143f2(%rip), %xmm0    # 0x6e988
movapd %xmm0, %xmm2
addl %esi, %eax
je 0x5a5d1
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movsd 0x143db(%rip), %xmm2    # 0x6e988
movsd 0x143e3(%rip), %xmm3    # 0x6e998
testb $0x1, %sil
je 0x5a5bf
mulsd %xmm3, %xmm2
movl %esi, %r8d
shrl %r8d
mulsd %xmm3, %xmm3
cmpl $0x1, %esi
movl %r8d, %esi
ja 0x5a5b5
testl %eax, %eax
jns 0x5a5dd
divsd %xmm2, %xmm0
movapd %xmm0, %xmm2
divsd %xmm2, %xmm1
xorl %esi, %esi
jmp 0x5a5e7
xorl %eax, %eax
testl %esi, %esi
cmovgl %esi, %edx
movsd 0x14394(%rip), %xmm0    # 0x6e988
xorpd %xmm2, %xmm2
movsd 0x143e8(%rip), %xmm3    # 0x6e9e8
movsd 0x14390(%rip), %xmm4    # 0x6e998
movl %edx, %esi
movapd %xmm0, %xmm5
testl %edx, %edx
je 0x5a63c
movl %esi, %edx
negl %edx
cmovsl %esi, %edx
movapd %xmm4, %xmm6
movapd %xmm0, %xmm5
testb $0x1, %dl
je 0x5a62a
mulsd %xmm6, %xmm5
movl %edx, %r8d
shrl %r8d
mulsd %xmm6, %xmm6
cmpl $0x1, %edx
movl %r8d, %edx
ja 0x5a621
testl %esi, %esi
jns 0x5a64c
movapd %xmm0, %xmm6
divsd %xmm5, %xmm6
movapd %xmm6, %xmm5
ucomisd %xmm2, %xmm5
jbe 0x5a683
movapd %xmm1, %xmm6
divsd %xmm5, %xmm6
cvttsd2si %xmm6, %edx
xorl %r8d, %r8d
ucomisd %xmm6, %xmm2
seta %r8b
subl %r8d, %edx
xorps %xmm6, %xmm6
cvtsi2sd %edx, %xmm6
mulsd %xmm5, %xmm6
subsd %xmm6, %xmm1
addb $0x30, %dl
movb %dl, (%rdi)
incq %rdi
movl %esi, %edx
subl $0x1, %edx
jae 0x5a696
ucomisd %xmm2, %xmm1
jbe 0x5a696
movb $0x2e, (%rdi)
incq %rdi
ucomisd %xmm3, %xmm1
ja 0x5a608
testl %esi, %esi
jg 0x5a608
testb %cl, %cl
je 0x5a73e
movb $0x65, (%rdi)
testl %eax, %eax
jle 0x5a6bd
movb $0x2b, 0x1(%rdi)
jmp 0x5a6c3
movb $0x2d, 0x1(%rdi)
negl %eax
addq $0x2, %rdi
xorl %ecx, %ecx
testl %eax, %eax
jle 0x5a6ff
movl $0xcccccccd, %edx       # imm = 0xCCCCCCCD
movl %eax, %esi
imulq %rdx, %rsi
shrq $0x23, %rsi
leal (%rsi,%rsi), %r8d
leal (%r8,%r8,4), %r8d
movl %eax, %r9d
subl %r8d, %r9d
orb $0x30, %r9b
movb %r9b, (%rdi,%rcx)
incq %rcx
cmpl $0x9, %eax
movl %esi, %eax
ja 0x5a6d2
addq %rcx, %rdi
cmpl $0x2, %ecx
jl 0x5a73e
movl %ecx, %eax
movq %rdi, %rcx
subq %rax, %rcx
addq $-0x2, %rax
xorl %edx, %edx
xorl %esi, %esi
movb (%rcx,%rsi), %r8b
xorb -0x1(%rdi,%rdx), %r8b
movb %r8b, (%rcx,%rsi)
xorb -0x1(%rdi,%rdx), %r8b
movb %r8b, -0x1(%rdi,%rdx)
xorb %r8b, (%rcx,%rsi)
incq %rsi
leaq (%rax,%rdx), %r8
decq %rdx
cmpq %r8, %rsi
jl 0x5a714
movb $0x0, (%rdi)
popq %rbx
retq
nop