// File: /workspace/github_c_makefile_star2_O3/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 0x420c
ucomiss %xmm0, %xmm4
jne 0x4227
jp 0x4227
movss 0x4074(%rip), %xmm0     # 0x8274
divss %xmm4, %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x4227
movl $0x2d, %edi
movaps %xmm4, 0x10(%rsp)
callq 0x2040
movaps 0x10(%rsp), %xmm4
xorps 0x4079(%rip), %xmm4     # 0x82a0
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm4
jne 0x423a
jp 0x423a
leaq 0x42d6(%rip), %rdi      # 0x850e
jmp 0x425a
ucomiss %xmm4, %xmm4
jp 0x4579
movd %xmm4, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x7f800000, %eax       # imm = 0x7F800000
jne 0x4268
leaq 0x42ba(%rip), %rdi      # 0x8514
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x3f36
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movss 0x3ffd(%rip), %xmm0     # 0x8274
ucomiss %xmm4, %xmm0
jbe 0x42d6
xorl %ecx, %ecx
movss 0x4002(%rip), %xmm0     # 0x8288
xorl %eax, %eax
ucomiss %xmm4, %xmm0
jbe 0x42a1
movss 0x3fef(%rip), %xmm1     # 0x8284
mulss %xmm1, %xmm4
addl $-0xa, %eax
ucomiss %xmm4, %xmm0
ja 0x4295
movss 0x3fe3(%rip), %xmm0     # 0x828c
ucomiss %xmm4, %xmm0
jbe 0x4389
movss 0x3fba(%rip), %xmm1     # 0x8274
movss 0x3fba(%rip), %xmm2     # 0x827c
mulss %xmm2, %xmm1
decl %eax
movaps %xmm4, %xmm3
mulss %xmm1, %xmm3
ucomiss %xmm3, %xmm0
ja 0x42c2
jmp 0x433b
ucomiss 0x3f9b(%rip), %xmm4     # 0x8278
jbe 0x4340
xorl %ecx, %ecx
xorl %eax, %eax
ucomiss 0x3f96(%rip), %xmm4     # 0x8280
jbe 0x4308
movss 0x3f90(%rip), %xmm0     # 0x8284
movss 0x3f84(%rip), %xmm1     # 0x8280
divss %xmm0, %xmm4
addl $0xa, %eax
ucomiss %xmm1, %xmm4
ja 0x42fc
ucomiss 0x3f69(%rip), %xmm4     # 0x8278
jbe 0x4389
movss 0x3f5b(%rip), %xmm0     # 0x8274
movss 0x3f5b(%rip), %xmm1     # 0x827c
movss 0x3f4f(%rip), %xmm2     # 0x8278
mulss %xmm1, %xmm0
incl %eax
movaps %xmm4, %xmm3
divss %xmm0, %xmm3
ucomiss %xmm2, %xmm3
ja 0x4329
movaps %xmm3, %xmm4
jmp 0x4389
cvttss2si %xmm4, %edx
cvttps2dq %xmm4, %xmm1
cvtdq2ps %xmm1, %xmm1
subss %xmm1, %xmm4
xorl %eax, %eax
cmpl $0xf423f, %edx          # imm = 0xF423F
jg 0x4383
xorl %eax, %eax
movss 0x3f11(%rip), %xmm0     # 0x8274
movss 0x3f11(%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 0x436b
jmp 0x4385
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 0x43be
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
subss %xmm4, %xmm0
ucomiss 0x3ed8(%rip), %xmm0     # 0x8290
jne 0x43be
jp 0x43be
decl %edx
addl %ecx, %edx
xorl %esi, %esi
cmpl $0x989680, %edx         # imm = 0x989680
movl $0xf4240, %ecx          # imm = 0xF4240
cmovll %edx, %ecx
setge %sil
movl %eax, %ebx
addl %esi, %ebx
addl %esi, %eax
addl $0xa, %eax
movl %ebx, %edx
negl %edx
cmpl $0xb, %eax
movl $0x6, %eax
cmovbl %edx, %eax
addl %eax, %ebx
testl %eax, %eax
jle 0x4455
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 0x4455
movl %eax, %edx
movslq %ecx, %rax
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x22, %rcx
addl %eax, %ecx
leal -0x1(%rdx), %eax
cmpl $0x2, %edx
jb 0x4461
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
je 0x4412
jmp 0x4461
testl %ecx, %ecx
jne 0x4461
testl %eax, %eax
js 0x44f0
movslq %eax, %rdx
movl $0x1, %r8d
xorl %edi, %edi
movq %rdi, %rsi
movl %r8d, %r14d
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, %r8d
subl %edi, %r8d
addb $0x30, %r8b
leaq 0x1(%rsi), %rdi
movb %r8b, (%rsp,%rsi)
addl $-0xa, %r9d
leal 0x1(%r14), %r8d
cmpl $-0x13, %r9d
jb 0x446c
cmpq %rdx, %rsi
jl 0x446c
testl %edi, %edi
jle 0x44f0
movl %eax, %r15d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
incq %r14
negq %r15
leaq (%r15,%r14), %rax
cmpq $0x1, %rax
jne 0x44dc
movl $0x2e, %edi
callq 0x2040
movsbl -0x2(%rsp,%r14), %edi
callq 0x2040
decq %r14
cmpq $0x1, %r14
jg 0x44c8
testl %ebx, %ebx
je 0x456f
movl $0x65, %edi
callq 0x2040
testl %ebx, %ebx
js 0x450e
movl $0x2b, %edi
callq 0x2040
jmp 0x451a
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 0x4526
movl %r14d, %eax
movsbl (%rsp,%rax), %edi
callq 0x2040
decq %r14
leal 0x2(%r14), %eax
cmpl $0x1, %eax
jg 0x4557
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x3f90(%rip), %rdi      # 0x8510
jmp 0x425a