#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 >= 1000000) {
    return "%.0f";
  } else if (fAbsFloat >= 100000) {
    return "%7.0f";
  } else if (fAbsFloat >= 10000) {
    return "%7.1f";
  } else if (fAbsFloat >= 1000) {
    return "%7.2f";
  } else if (fAbsFloat >= 100) {
    return "%7.3f";
  } else if (fAbsFloat >= 10) {
    return "%7.4f";
  } else if (fAbsFloat >= 0.001) {
    return "%7.5f";
  } else if (fAbsFloat < 1.0e-10) {
    return "%5.1f";
  } else {
    return "%7.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    0xe9f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0xc(%rbp),%xmm0
call   1060 <isinff@plt>
cmp    $0x0,%rax
je     11c6 <float_format+0x86>
lea    0xe83(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
movss  0xe2d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11ec <float_format+0xac>
lea    0xe65(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe23(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1217 <float_format+0xd7>
lea    0xe40(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
movss  0xde0(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     123d <float_format+0xfd>
lea    0xe20(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
movss  0xdbe(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1263 <float_format+0x123>
lea    0xdf4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
movss  0xd9c(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1289 <float_format+0x149>
lea    0xdd9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
movss  0xd7a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     12af <float_format+0x16f>
lea    0xdb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
movss  0xd58(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     12d5 <float_format+0x195>
lea    0xd99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
movss  0xd36(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     12fb <float_format+0x1bb>
lea    0xd79(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd1c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1326 <float_format+0x1e6>
lea    0xd54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xcf9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1351 <float_format+0x211>
lea    0xd2f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    135c <float_format+0x21c>
lea    0xd25(%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    0xeec(%rip),%rax
add    $0x38,%rsp
ret
movaps (%rsp),%xmm0
call   1050 <isinff@plt>
test   %rax,%rax
je     117b <float_format+0x4b>
lea    0xeda(%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    0xebf(%rip),%rax
add    $0x38,%rsp
ret
movaps 0x20(%rsp),%xmm1
andps  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xeaa(%rip),%rax
movsd  0xe74(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11c7 <float_format+0x97>
add    $0x38,%rsp
ret
ucomiss 0xe46(%rip),%xmm2
jae    1231 <float_format+0x101>
ucomiss 0xe41(%rip),%xmm2
jae    11c2 <float_format+0x92>
ucomiss 0xe3c(%rip),%xmm2
jae    123d <float_format+0x10d>
ucomiss 0xe37(%rip),%xmm2
jae    1249 <float_format+0x119>
ucomiss 0xe32(%rip),%xmm2
jae    1255 <float_format+0x125>
ucomiss 0xe2d(%rip),%xmm2
jae    1261 <float_format+0x131>
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
ucomisd 0xe2c(%rip),%xmm0
jae    126d <float_format+0x13d>
movsd  0xe2a(%rip),%xmm1
ucomisd %xmm0,%xmm1
lea    0xe66(%rip),%rcx
lea    0xe65(%rip),%rax
cmova  %rcx,%rax
add    $0x38,%rsp
ret
lea    0xe2c(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe25(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe1f(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe19(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe13(%rip),%rax
add    $0x38,%rsp
ret
lea    0xe0d(%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 = [6 x i8] c"%7.1f\00"
@.str.6 = [6 x i8] c"%7.2f\00"
@.str.7 = [6 x i8] c"%7.3f\00"
@.str.8 = [6 x i8] c"%7.4f\00"
@.str.9 = [6 x i8] c"%7.5f\00"
@.str.10 = [6 x i8] c"%5.1f\00"
@.str.11 = [6 x i8] c"%7.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 %67
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 %67
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 %67
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 %67
32: ; preds = %27
%33 = load float, float* %5
%34 = fcmp oge float %33, 1.000000e+06
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 %67
36: ; preds = %32
%37 = load float, float* %5
%38 = fcmp oge float %37, 1.000000e+05
br i1 %38, label %39, label %40
39: ; preds = %36
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %67
40: ; preds = %36
%41 = load float, float* %5
%42 = fcmp oge float %41, 1.000000e+04
br i1 %42, label %43, label %44
43: ; preds = %40
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %67
44: ; preds = %40
%45 = load float, float* %5
%46 = fcmp oge float %45, 1.000000e+03
br i1 %46, label %47, label %48
47: ; preds = %44
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %67
48: ; preds = %44
%49 = load float, float* %5
%50 = fcmp oge float %49, 1.000000e+02
br i1 %50, label %51, label %52
51: ; preds = %48
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %67
52: ; preds = %48
%53 = load float, float* %5
%54 = fcmp oge float %53, 1.000000e+01
br i1 %54, label %55, label %56
55: ; preds = %52
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %67
56: ; preds = %52
%57 = load float, float* %5
%58 = fpext float %57 to double
%59 = fcmp oge double %58, 1.000000e-03
br i1 %59, label %60, label %61
60: ; preds = %56
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %67
61: ; preds = %56
%62 = load float, float* %5
%63 = fpext float %62 to double
%64 = fcmp olt double %63, 1.000000e-10
br i1 %64, label %65, label %66
65: ; preds = %61
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %67
66: ; preds = %61
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %67
67: ; preds = %66, %65, %60, %55, %51, %47, %43, %39, %35, %31, %26, %22, %17
%68 = load i8*, i8** %2
ret i8* %68
}

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 = [6 x i8] c"%7.1f\00"
@.str.6 = [6 x i8] c"%7.2f\00"
@.str.7 = [6 x i8] c"%7.3f\00"
@.str.8 = [6 x i8] c"%7.4f\00"
@.str.9 = [6 x i8] c"%7.5f\00"
@.str.10 = [6 x i8] c"%5.1f\00"
@.str.11 = [6 x i8] c"%7.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 %35
9: ; preds = %1
%10 = tail call i64 @isinff(float %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %35
12: ; preds = %9
%13 = fcmp ogt float %4, 1.000000e+07
br i1 %13, label %35, label %14
14: ; preds = %12
%15 = fpext float %6 to double
%16 = fcmp olt double %15, 1.000000e-05
br i1 %16, label %35, label %17
17: ; preds = %14
%18 = fcmp ult float %4, 1.000000e+06
br i1 %18, label %19, label %35
19: ; preds = %17
%20 = fcmp ult float %4, 1.000000e+05
br i1 %20, label %21, label %35
21: ; preds = %19
%22 = fcmp ult float %4, 1.000000e+04
br i1 %22, label %23, label %35
23: ; preds = %21
%24 = fcmp ult float %4, 1.000000e+03
br i1 %24, label %25, label %35
25: ; preds = %23
%26 = fcmp ult float %4, 1.000000e+02
br i1 %26, label %27, label %35
27: ; preds = %25
%28 = fcmp ult float %4, 1.000000e+01
br i1 %28, label %29, label %35
29: ; preds = %27
%30 = fpext float %4 to double
%31 = fcmp ult double %30, 1.000000e-03
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = fcmp olt double %30, 1.000000e-10
%34 = select i1 %33, 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 %35
35: ; preds = %32, %29, %27, %25, %23, %21, %19, %17, %14, %12, %9, %1
%36 = 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 ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %19 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %21 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %23 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %25 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %27 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), %29 ], [ %34, %32 ]
ret i8* %36
}