// File: /workspace/github_c_makefile_star2_O2/jeff-1amstudios[P]carmageddon-1-cheat-code-disassembly/src/test/framework/unity.c
// Function: UnityPrintFloat
void UnityPrintFloat(const UNITY_DOUBLE input_number)
{
#ifdef UNITY_INCLUDE_DOUBLE
    static const int sig_digits = 9;
    static const UNITY_INT32 min_scaled = 100000000;
    static const UNITY_INT32 max_scaled = 1000000000;
#else
    static const int sig_digits = 7;
    static const UNITY_INT32 min_scaled = 1000000;
    static const UNITY_INT32 max_scaled = 10000000;
#endif

    UNITY_DOUBLE number = input_number;

    /* print minus sign (including for negative zero) */
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
    {
        UNITY_OUTPUT_CHAR('-');
        number = -number;
    }

    /* handle zero, NaN, and +/- infinity */
    if (number == 0.0f)
    {
        UnityPrint("0");
    }
    else if (isnan(number))
    {
        UnityPrint("nan");
    }
    else if (isinf(number))
    {
        UnityPrint("inf");
    }
    else
    {
        UNITY_INT32 n_int = 0, n;
        int exponent = 0;
        int decimals, digits;
        char buf[16] = {0};

        /*
         * Scale up or down by powers of 10.  To minimize rounding error,
         * start with a factor/divisor of 10^10, which is the largest
         * power of 10 that can be represented exactly.  Finally, compute
         * (exactly) the remaining power of 10 and perform one more
         * multiplication or division.
         */
        if (number < 1.0f)
        {
            UNITY_DOUBLE factor = 1.0f;

            while (number < (UNITY_DOUBLE)max_scaled / 1e10f) { number *= 1e10f; exponent -= 10; }
            while (number * factor < (UNITY_DOUBLE)min_scaled) { factor *= 10.0f; exponent--; }

            number *= factor;
        }
        else if (number > (UNITY_DOUBLE)max_scaled)
        {
            UNITY_DOUBLE divisor = 1.0f;

            while (number > (UNITY_DOUBLE)min_scaled * 1e10f) { number /= 1e10f; exponent += 10; }
            while (number / divisor > (UNITY_DOUBLE)max_scaled) { divisor *= 10.0f; exponent++; }

            number /= divisor;
        }
        else
        {
            /*
             * In this range, we can split off the integer part before
             * doing any multiplications.  This reduces rounding error by
             * freeing up significant bits in the fractional part.
             */
            UNITY_DOUBLE factor = 1.0f;
            n_int = (UNITY_INT32)number;
            number -= (UNITY_DOUBLE)n_int;

            while (n_int < min_scaled) { n_int *= 10; factor *= 10.0f; exponent--; }

            number *= factor;
        }

        /* round to nearest integer */
        n = ((UNITY_INT32)(number + number) + 1) / 2;

#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO
        /* round to even if exactly between two integers */
        if ((n & 1) && ((UNITY_DOUBLE)n - number == 0.5f))
            n--;
#endif

        n += n_int;

        if (n >= max_scaled)
        {
            n = min_scaled;
            exponent++;
        }

        /* determine where to place decimal point */
        decimals = (exponent <= 0 && exponent >= -(sig_digits + 3)) ? -exponent : (sig_digits - 1);
        exponent += decimals;

        /* truncate trailing zeroes after decimal point */
        while (decimals > 0 && n % 10 == 0)
        {
            n /= 10;
            decimals--;
        }

        /* build up buffer in reverse order */
        digits = 0;
        while (n != 0 || digits < decimals + 1)
        {
            buf[digits++] = (char)('0' + n % 10);
            n /= 10;
        }
        while (digits > 0)
        {
            if(digits == decimals) UNITY_OUTPUT_CHAR('.');
            UNITY_OUTPUT_CHAR(buf[--digits]);
        }

        /* print exponent if needed */
        if (exponent != 0)
        {
            UNITY_OUTPUT_CHAR('e');

            if(exponent < 0)
            {
                UNITY_OUTPUT_CHAR('-');
                exponent = -exponent;
            }
            else
            {
                UNITY_OUTPUT_CHAR('+');
            }

            digits = 0;
            while (exponent != 0 || digits < 2)
            {
                buf[digits++] = (char)('0' + exponent % 10);
                exponent /= 10;
            }
            while (digits > 0)
            {
                UNITY_OUTPUT_CHAR(buf[--digits]);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x3bef
ucomiss %xmm1, %xmm0
jne 0x3c08
jp 0x3c08
movss 0x368e(%rip), %xmm2     # 0x7274
divss %xmm0, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x3c08
pushq $0x2d
popq %rdi
movaps %xmm0, 0x10(%rsp)
callq 0x2040
movaps 0x10(%rsp), %xmm0
xorps 0x3698(%rip), %xmm0     # 0x72a0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3c1b
jp 0x3c1b
leaq 0x38f5(%rip), %rdi      # 0x750e
jmp 0x3c3b
ucomiss %xmm0, %xmm0
jp 0x3e75
movd %xmm0, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x7f800000, %eax       # imm = 0x7F800000
jne 0x3c4e
leaq 0x38d9(%rip), %rdi      # 0x7514
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3942
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
movss 0x3617(%rip), %xmm3     # 0x7274
ucomiss %xmm0, %xmm3
jbe 0x3c84
xorl %r14d, %r14d
movss 0x361b(%rip), %xmm2     # 0x7288
movss 0x360f(%rip), %xmm1     # 0x7284
ucomiss %xmm0, %xmm2
jbe 0x3caf
mulss %xmm1, %xmm0
addl $-0xa, %r14d
jmp 0x3c75
ucomiss 0x35ed(%rip), %xmm0     # 0x7278
jbe 0x3cdc
xorl %r14d, %r14d
movss 0x35e8(%rip), %xmm2     # 0x7280
movss 0x35e4(%rip), %xmm1     # 0x7284
ucomiss %xmm2, %xmm0
jbe 0x3d06
divss %xmm1, %xmm0
addl $0xa, %r14d
jmp 0x3ca0
movss 0x35bd(%rip), %xmm1     # 0x7274
movss 0x35cd(%rip), %xmm2     # 0x728c
movss 0x35b5(%rip), %xmm3     # 0x727c
movaps %xmm0, %xmm4
mulss %xmm1, %xmm4
ucomiss %xmm4, %xmm2
jbe 0x3d33
mulss %xmm3, %xmm1
decl %r14d
jmp 0x3cc7
cvttss2si %xmm0, %ecx
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm1
xorl %r14d, %r14d
movss 0x358a(%rip), %xmm2     # 0x727c
cmpl $0xf423f, %ecx          # imm = 0xF423F
jg 0x3d37
imull $0xa, %ecx, %ecx
mulss %xmm2, %xmm3
decl %r14d
jmp 0x3cf2
movss 0x3566(%rip), %xmm1     # 0x7274
movss 0x3562(%rip), %xmm2     # 0x7278
movss 0x355e(%rip), %xmm3     # 0x727c
movaps %xmm0, %xmm4
divss %xmm1, %xmm4
ucomiss %xmm2, %xmm4
jbe 0x3d33
mulss %xmm3, %xmm1
incl %r14d
jmp 0x3d1e
xorl %ecx, %ecx
jmp 0x3d42
subss %xmm1, %xmm0
mulss %xmm3, %xmm0
movaps %xmm0, %xmm4
movaps %xmm4, %xmm1
addss %xmm4, %xmm1
cvttss2si %xmm1, %eax
incl %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
testb $0x1, %al
je 0x3d6e
cvtsi2ss %eax, %xmm1
subss %xmm4, %xmm1
ucomiss 0x3528(%rip), %xmm1     # 0x7290
jne 0x3d6e
jp 0x3d6e
decl %eax
addl %ecx, %eax
xorl %edx, %edx
cmpl $0x989680, %eax         # imm = 0x989680
movl $0xf4240, %ecx          # imm = 0xF4240
cmovll %eax, %ecx
setge %dl
movl %r14d, %eax
addl %edx, %r14d
addl %edx, %eax
addl $0xa, %eax
movl %r14d, %edx
negl %edx
cmpl $0xb, %eax
pushq $0x6
popq %rbx
cmovbl %edx, %ebx
pushq $0xa
popq %r15
movq %rbx, %r12
movl %ecx, %eax
cltd
idivl %r15d
testl %r12d, %r12d
jle 0x3db8
testl %edx, %edx
jne 0x3db8
decq %r12
movl %eax, %ecx
jmp 0x3da2
movslq %r12d, %rsi
xorl %r13d, %r13d
testl %ecx, %ecx
jne 0x3dc7
cmpq %rsi, %r13
jg 0x3ddb
movl %ecx, %eax
cltd
idivl %r15d
addb $0x30, %dl
movb %dl, (%rsp,%r13)
incq %r13
movl %eax, %ecx
jmp 0x3dbe
subq %r13, %r12
pushq $0x2e
popq %rbp
testq %r13, %r13
jle 0x3e06
testq %r12, %r12
jne 0x3df2
movl %ebp, %edi
callq 0x2040
decq %r13
movl %r13d, %eax
movsbl (%rsp,%rax), %edi
callq 0x2040
incq %r12
jmp 0x3de1
addl %r14d, %ebx
je 0x3e66
pushq $0x65
popq %rdi
callq 0x2040
testl %ebx, %ebx
js 0x3e21
pushq $0x2b
popq %rdi
callq 0x2040
jmp 0x3e2b
pushq $0x2d
popq %rdi
callq 0x2040
negl %ebx
xorl %r14d, %r14d
testl %ebx, %ebx
setne %al
cmpq $0x2, %r14
setb %cl
orb %al, %cl
je 0x3e61
movl %ebx, %eax
xorl %edx, %edx
divl %r15d
orb $0x30, %dl
movb %dl, (%rsp,%r14)
incq %r14
movl %eax, %ebx
jmp 0x3e2e
movsbl -0x1(%rsp,%r14), %edi
decq %r14
callq 0x2040
testq %r14, %r14
jg 0x3e53
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3694(%rip), %rdi      # 0x7510
jmp 0x3c3b