#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
float fabs(float);
scalar_t__ isinff(float);
scalar_t__ isnanf(float);
float modff(float, float *);
char *float_format(float aFloat) {
  float fInt;
  float fAbsFloat = fabs(aFloat);
  float fFrac = modff(aFloat, &fInt);
  float fAbsFrac = fabs(fFrac);
  if (isnanf(aFloat)) {
    return "    NAN";
  } else if (isinff(aFloat)) {
    return "    INF";
  } else if (fAbsFloat > 10000000) {
    return "%1.4e";
  } else if (fAbsFrac < 0.00001) {
    return "%7.0f";
  } else if (fAbsFloat >= 100000) {
    return "%.0f";
  } else if (fAbsFloat >= 10000) {
    return "%.1f";
  } else if (fAbsFloat >= 1000) {
    return "%.2f";
  } else if (fAbsFloat >= 100) {
    return "%.3f";
  } else if (fAbsFloat >= 10) {
    return "%.4f";
  } else if (fAbsFloat >= 0.001) {
    return "%.5f";
  } else if (fAbsFloat < 1.0e-10) {
    return "%5.1f";
  } else {
    return "%8.8f";
  }
}


x86 assembly (clang, -O0):
<float_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1050 <fabs@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
call   1030 <modff@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1050 <fabs@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <isnanf@plt>
cmp    $0x0,%rax
je     11a2 <float_format+0x62>
lea    0xe97(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0xc(%rbp),%xmm0
call   1060 <isinff@plt>
cmp    $0x0,%rax
je     11c6 <float_format+0x86>
lea    0xe7b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
movss  0xe2d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11ec <float_format+0xac>
lea    0xe5d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe1b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1217 <float_format+0xd7>
lea    0xe38(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
movss  0xde0(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     123d <float_format+0xfd>
lea    0xe18(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
movss  0xdbe(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1263 <float_format+0x123>
lea    0xdf7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
movss  0xd9c(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1289 <float_format+0x149>
lea    0xdd6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
movss  0xd7a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     12af <float_format+0x16f>
lea    0xdb5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
movss  0xd58(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     12d5 <float_format+0x195>
lea    0xd94(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd3a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1300 <float_format+0x1c0>
lea    0xd6e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd17(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    132b <float_format+0x1eb>
lea    0xd48(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <float_format+0x1f6>
lea    0xd3e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<float_format>:
sub    $0x38,%rsp
movaps %xmm0,(%rsp)
lea    0x1c(%rsp),%rdi
call   1030 <modff@plt>
movaps %xmm0,0x20(%rsp)
movaps (%rsp),%xmm0
call   1040 <isnanf@plt>
test   %rax,%rax
je     1161 <float_format+0x31>
lea    0xee4(%rip),%rax
add    $0x38,%rsp
ret
movaps (%rsp),%xmm0
call   1050 <isinff@plt>
test   %rax,%rax
je     117b <float_format+0x4b>
lea    0xed2(%rip),%rax
add    $0x38,%rsp
ret
movaps 0xe7e(%rip),%xmm0
movaps (%rsp),%xmm2
andps  %xmm0,%xmm2
ucomiss 0xe80(%rip),%xmm2
jbe    119e <float_format+0x6e>
lea    0xeb7(%rip),%rax
add    $0x38,%rsp
ret
movaps 0x20(%rsp),%xmm1
andps  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  0xe73(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11c7 <float_format+0x97>
lea    0xe94(%rip),%rax
add    $0x38,%rsp
ret
ucomiss 0xe46(%rip),%xmm2
jae    1228 <float_format+0xf8>
ucomiss 0xe41(%rip),%xmm2
jae    1234 <float_format+0x104>
ucomiss 0xe3c(%rip),%xmm2
jae    1240 <float_format+0x110>
ucomiss 0xe37(%rip),%xmm2
jae    124c <float_format+0x11c>
ucomiss 0xe32(%rip),%xmm2
jae    1258 <float_format+0x128>
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
ucomisd 0xe2d(%rip),%xmm0
jae    1264 <float_format+0x134>
movsd  0xe2b(%rip),%xmm1
ucomisd %xmm0,%xmm1
lea    0xe62(%rip),%rcx
lea    0xe61(%rip),%rax
cmova  %rcx,%rax
add    $0x38,%rsp
ret
lea    0xe2d(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe26(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe1f(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe18(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe11(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe0a(%rip),%rax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c" NAN\00"
@.str.1 = [8 x i8] c" INF\00"
@.str.2 = [6 x i8] c"%1.4e\00"
@.str.3 = [6 x i8] c"%7.0f\00"
@.str.4 = [5 x i8] c"%.0f\00"
@.str.5 = [5 x i8] c"%.1f\00"
@.str.6 = [5 x i8] c"%.2f\00"
@.str.7 = [5 x i8] c"%.3f\00"
@.str.8 = [5 x i8] c"%.4f\00"
@.str.9 = [5 x i8] c"%.5f\00"
@.str.10 = [6 x i8] c"%5.1f\00"
@.str.11 = [6 x i8] c"%8.8f\00"
define i8* @float_format(float %0) {
%2 = alloca i8*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %3
%8 = load float, float* %3
%9 = call float @fabs(float %8)
store float %9, float* %5
%10 = load float, float* %3
%11 = call float @modff(float %10, float* %4)
store float %11, float* %6
%12 = load float, float* %6
%13 = call float @fabs(float %12)
store float %13, float* %7
%14 = load float, float* %3
%15 = call i64 @isnanf(float %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
br label %63
18: ; preds = %1
%19 = load float, float* %3
%20 = call i64 @isinff(float %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %63
23: ; preds = %18
%24 = load float, float* %5
%25 = fcmp ogt float %24, 1.000000e+07
br i1 %25, label %26, label %27
26: ; preds = %23
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %63
27: ; preds = %23
%28 = load float, float* %7
%29 = fpext float %28 to double
%30 = fcmp olt double %29, 1.000000e-05
br i1 %30, label %31, label %32
31: ; preds = %27
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %63
32: ; preds = %27
%33 = load float, float* %5
%34 = fcmp oge float %33, 1.000000e+05
br i1 %34, label %35, label %36
35: ; preds = %32
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %63
36: ; preds = %32
%37 = load float, float* %5
%38 = fcmp oge float %37, 1.000000e+04
br i1 %38, label %39, label %40
39: ; preds = %36
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %63
40: ; preds = %36
%41 = load float, float* %5
%42 = fcmp oge float %41, 1.000000e+03
br i1 %42, label %43, label %44
43: ; preds = %40
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %63
44: ; preds = %40
%45 = load float, float* %5
%46 = fcmp oge float %45, 1.000000e+02
br i1 %46, label %47, label %48
47: ; preds = %44
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %63
48: ; preds = %44
%49 = load float, float* %5
%50 = fcmp oge float %49, 1.000000e+01
br i1 %50, label %51, label %52
51: ; preds = %48
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %63
52: ; preds = %48
%53 = load float, float* %5
%54 = fpext float %53 to double
%55 = fcmp oge double %54, 1.000000e-03
br i1 %55, label %56, label %57
56: ; preds = %52
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %63
57: ; preds = %52
%58 = load float, float* %5
%59 = fpext float %58 to double
%60 = fcmp olt double %59, 1.000000e-10
br i1 %60, label %61, label %62
61: ; preds = %57
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %63
62: ; preds = %57
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %63
63: ; preds = %62, %61, %56, %51, %47, %43, %39, %35, %31, %26, %22, %17
%64 = load i8*, i8** %2
ret i8* %64
}

LLVM IR (-O2):
@.str = [8 x i8] c" NAN\00"
@.str.1 = [8 x i8] c" INF\00"
@.str.2 = [6 x i8] c"%1.4e\00"
@.str.3 = [6 x i8] c"%7.0f\00"
@.str.4 = [5 x i8] c"%.0f\00"
@.str.5 = [5 x i8] c"%.1f\00"
@.str.6 = [5 x i8] c"%.2f\00"
@.str.7 = [5 x i8] c"%.3f\00"
@.str.8 = [5 x i8] c"%.4f\00"
@.str.9 = [5 x i8] c"%.5f\00"
@.str.10 = [6 x i8] c"%5.1f\00"
@.str.11 = [6 x i8] c"%8.8f\00"
define i8* @float_format(float %0) {
%2 = alloca float
%3 = bitcast float* %2 to i8*
%4 = tail call float @llvm.fabs.f32(float %0)
%5 = call float @modff(float %0, float* %2)
%6 = tail call float @llvm.fabs.f32(float %5)
%7 = tail call i64 @isnanf(float %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %1
%10 = tail call i64 @isinff(float %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = fcmp ogt float %4, 1.000000e+07
br i1 %13, label %33, label %14
14: ; preds = %12
%15 = fpext float %6 to double
%16 = fcmp olt double %15, 1.000000e-05
br i1 %16, label %33, label %17
17: ; preds = %14
%18 = fcmp ult float %4, 1.000000e+05
br i1 %18, label %19, label %33
19: ; preds = %17
%20 = fcmp ult float %4, 1.000000e+04
br i1 %20, label %21, label %33
21: ; preds = %19
%22 = fcmp ult float %4, 1.000000e+03
br i1 %22, label %23, label %33
23: ; preds = %21
%24 = fcmp ult float %4, 1.000000e+02
br i1 %24, label %25, label %33
25: ; preds = %23
%26 = fcmp ult float %4, 1.000000e+01
br i1 %26, label %27, label %33
27: ; preds = %25
%28 = fpext float %4 to double
%29 = fcmp ult double %28, 1.000000e-03
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = fcmp olt double %28, 1.000000e-10
%32 = select i1 %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0)
br label %33
33: ; preds = %30, %27, %25, %23, %21, %19, %17, %14, %12, %9, %1
%34 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %17 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %19 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %21 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %23 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), %25 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), %27 ], [ %32, %30 ]
ret i8* %34
}