// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movaps %xmm0, %xmm4
xorps %xmm0, %xmm0
ucomiss %xmm4, %xmm0
ja 0x41d3
ucomiss %xmm0, %xmm4
jne 0x41ee
jp 0x41ee
movss 0x40ad(%rip), %xmm0     # 0x8274
divss %xmm4, %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x41ee
movl $0x2d, %edi
movaps %xmm4, 0x10(%rsp)
callq 0x2040
movaps 0x10(%rsp), %xmm4
xorps 0x40b2(%rip), %xmm4     # 0x82a0
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm4
jne 0x4201
jp 0x4201
leaq 0x430f(%rip), %rdi      # 0x850e
jmp 0x4221
ucomiss %xmm4, %xmm4
jp 0x4532
movd %xmm4, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x7f800000, %eax       # imm = 0x7F800000
jne 0x422f
leaq 0x42f3(%rip), %rdi      # 0x8514
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x3efa
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movss 0x4036(%rip), %xmm0     # 0x8274
ucomiss %xmm4, %xmm0
jbe 0x429d
xorl %ecx, %ecx
movss 0x403b(%rip), %xmm0     # 0x8288
xorl %eax, %eax
ucomiss %xmm4, %xmm0
jbe 0x4268
movss 0x4028(%rip), %xmm1     # 0x8284
mulss %xmm1, %xmm4
addl $-0xa, %eax
ucomiss %xmm4, %xmm0
ja 0x425c
movss 0x401c(%rip), %xmm0     # 0x828c
ucomiss %xmm4, %xmm0
jbe 0x4350
movss 0x3ff3(%rip), %xmm1     # 0x8274
movss 0x3ff3(%rip), %xmm2     # 0x827c
mulss %xmm2, %xmm1
decl %eax
movaps %xmm4, %xmm3
mulss %xmm1, %xmm3
ucomiss %xmm3, %xmm0
ja 0x4289
jmp 0x4302
ucomiss 0x3fd4(%rip), %xmm4     # 0x8278
jbe 0x4307
xorl %ecx, %ecx
xorl %eax, %eax
ucomiss 0x3fcf(%rip), %xmm4     # 0x8280
jbe 0x42cf
movss 0x3fc9(%rip), %xmm0     # 0x8284
movss 0x3fbd(%rip), %xmm1     # 0x8280
divss %xmm0, %xmm4
addl $0xa, %eax
ucomiss %xmm1, %xmm4
ja 0x42c3
ucomiss 0x3fa2(%rip), %xmm4     # 0x8278
jbe 0x4350
movss 0x3f94(%rip), %xmm0     # 0x8274
movss 0x3f94(%rip), %xmm1     # 0x827c
movss 0x3f88(%rip), %xmm2     # 0x8278
mulss %xmm1, %xmm0
incl %eax
movaps %xmm4, %xmm3
divss %xmm0, %xmm3
ucomiss %xmm2, %xmm3
ja 0x42f0
movaps %xmm3, %xmm4
jmp 0x4350
cvttss2si %xmm4, %edx
cvttps2dq %xmm4, %xmm1
cvtdq2ps %xmm1, %xmm1
subss %xmm1, %xmm4
xorl %eax, %eax
cmpl $0xf423f, %edx          # imm = 0xF423F
jg 0x434a
xorl %eax, %eax
movss 0x3f4a(%rip), %xmm0     # 0x8274
movss 0x3f4a(%rip), %xmm1     # 0x827c
leal (%rdx,%rdx), %ecx
leal (%rcx,%rcx,4), %ecx
mulss %xmm1, %xmm0
decl %eax
cmpl $0x186a0, %edx          # imm = 0x186A0
movl %ecx, %edx
jl 0x4332
jmp 0x434c
movl %edx, %ecx
mulss %xmm0, %xmm4
movaps %xmm4, %xmm0
addss %xmm4, %xmm0
cvttss2si %xmm0, %edx
movl %edx, %esi
incl %esi
shrl $0x1f, %esi
addl %esi, %edx
incl %edx
sarl %edx
testb $0x1, %dl
je 0x4385
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
subss %xmm4, %xmm0
ucomiss 0x3f11(%rip), %xmm0     # 0x8290
jne 0x4385
jp 0x4385
decl %edx
addl %ecx, %edx
xorl %esi, %esi
cmpl $0x989680, %edx         # imm = 0x989680
setge %sil
movl $0xf4240, %ecx          # imm = 0xF4240
cmovll %edx, %ecx
movl %eax, %edx
addl %esi, %eax
addl %esi, %edx
addl $0xa, %edx
movl %eax, %esi
negl %esi
cmpl $0xb, %edx
movl $0x6, %ebx
cmovbl %esi, %ebx
testl %ebx, %ebx
jle 0x441d
movslq %ecx, %rdx
imulq $0x66666667, %rdx, %rsi # imm = 0x66666667
movq %rsi, %rdi
shrq $0x3f, %rdi
sarq $0x22, %rsi
addl %edi, %esi
addl %esi, %esi
leal (%rsi,%rsi,4), %esi
subl %esi, %edx
jne 0x441d
movl %ebx, %edx
movl %edx, %esi
movslq %ecx, %rcx
imulq $0x66666667, %rcx, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
leal -0x1(%rsi), %edx
cmpl $0x2, %esi
jl 0x441f
movslq %ecx, %rsi
imulq $0x66666667, %rsi, %rdi # imm = 0x66666667
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x22, %rdi
addl %r8d, %edi
addl %edi, %edi
leal (%rdi,%rdi,4), %edi
subl %edi, %esi
je 0x43d9
jmp 0x441f
movl %ebx, %edx
testl %ecx, %ecx
jne 0x4429
xorl %edi, %edi
testl %edx, %edx
js 0x446f
movslq %edx, %rsi
xorl %edi, %edi
movq %rdi, %r8
movslq %ecx, %r9
imulq $0x66666667, %r9, %rcx  # imm = 0x66666667
movq %rcx, %rdi
shrq $0x3f, %rdi
sarq $0x22, %rcx
addl %edi, %ecx
leal (%rcx,%rcx), %edi
leal (%rdi,%rdi,4), %edi
movl %r9d, %r10d
subl %edi, %r10d
addb $0x30, %r10b
leaq 0x1(%r8), %rdi
movb %r10b, (%rsp,%r8)
addl $-0xa, %r9d
cmpl $-0x13, %r9d
jb 0x442e
cmpq %rsi, %r8
jl 0x442e
addl %eax, %ebx
testl %edi, %edi
jle 0x44a9
movl %edi, %r14d
movl %edx, %r15d
incq %r14
negq %r15
leaq (%r15,%r14), %rax
cmpq $0x1, %rax
jne 0x4495
movl $0x2e, %edi
callq 0x2040
movsbl -0x2(%rsp,%r14), %edi
callq 0x2040
decq %r14
cmpq $0x1, %r14
jg 0x4481
testl %ebx, %ebx
je 0x4528
movl $0x65, %edi
callq 0x2040
testl %ebx, %ebx
js 0x44c7
movl $0x2b, %edi
callq 0x2040
jmp 0x44d3
movl $0x2d, %edi
callq 0x2040
negl %ebx
movq $-0x1, %r14
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
movl %ebx, %ecx
imulq %rax, %rcx
shrq $0x23, %rcx
leal (%rcx,%rcx), %edx
leal (%rdx,%rdx,4), %edx
movl %ebx, %esi
subl %edx, %esi
orb $0x30, %sil
movb %sil, 0x1(%rsp,%r14)
cmpl $0xa, %ebx
setae %dl
incq %r14
sete %sil
orb %dl, %sil
movl %ecx, %ebx
jne 0x44df
movl %r14d, %eax
movsbl (%rsp,%rax), %edi
callq 0x2040
decq %r14
leal 0x2(%r14), %eax
cmpl $0x1, %eax
jg 0x4510
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x3fd7(%rip), %rdi      # 0x8510
jmp 0x4221