#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 */
int sprintf(char *, char *, ...);
int Printfloat4(char *s, float f) {
  int k;
  if (*(unsigned int *)&f == 0x7F800000L)
    k = sprintf(s, "+INF 7F800000");
  else if (*(unsigned int *)&f == 0xFF800000L)
    k = sprintf(s, "-INF FF800000");
  else if ((*(unsigned int *)&f & 0xFF800000L) == 0x7F800000L)
    k = sprintf(s,
                "+NAN "
                "0x%08x",
                *(unsigned int *)&f);
  else if ((*(unsigned int *)&f & 0xFF800000L) == 0xFF800000L)
    k = sprintf(s,
                "-NAN "
                "0x%08x",
                *(unsigned int *)&f);
  else
    k = sprintf(s, "%#.7g", f);
  return k;
}


x86 assembly (clang, -O0):
<Printfloat4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    $0x7f800000,%rax
jne    114a <Printfloat4+0x3a>
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x10(%rbp)
jmp    1216 <Printfloat4+0x106>
mov    -0xc(%rbp),%eax
mov    $0xff800000,%ecx
cmp    %rcx,%rax
jne    1175 <Printfloat4+0x65>
mov    -0x8(%rbp),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x10(%rbp)
jmp    1211 <Printfloat4+0x101>
mov    -0xc(%rbp),%eax
movabs $0xff800000,%rcx
and    %rcx,%rax
cmp    $0x7f800000,%rax
jne    11ae <Printfloat4+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x10(%rbp)
jmp    120c <Printfloat4+0xfc>
mov    -0xc(%rbp),%eax
movabs $0xff800000,%rcx
and    %rcx,%rax
mov    $0xff800000,%ecx
cmp    %rcx,%rax
jne    11e9 <Printfloat4+0xd9>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x10(%rbp)
jmp    1207 <Printfloat4+0xf7>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe37(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
mov    %eax,-0x10(%rbp)
jmp    120c <Printfloat4+0xfc>
jmp    1211 <Printfloat4+0x101>
jmp    1216 <Printfloat4+0x106>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Printfloat4>:
movd   %xmm0,%edx
cmp    $0xff800000,%edx
je     113e <Printfloat4+0x2e>
cmp    $0x7f800000,%edx
jne    115f <Printfloat4+0x4f>
movabs $0x30303030303846,%rax
mov    %rax,0x6(%rdi)
movabs $0x38463720464e492b,%rax
37 46 38
jmp    1156 <Printfloat4+0x46>
movabs $0x30303030303846,%rax
mov    %rax,0x6(%rdi)
movabs $0x38464620464e492d,%rax
46 46 38
mov    %rax,(%rdi)
mov    $0xd,%eax
ret
mov    %edx,%eax
and    $0xff800000,%eax
cmp    $0x7f800000,%eax
jne    117b <Printfloat4+0x6b>
lea    0xea8(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
cmp    $0xff800000,%edx
jb     1191 <Printfloat4+0x81>
lea    0xe9e(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe98(%rip),%rsi
mov    $0x1,%al
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"+INF 7F800000\00"
@.str.1 = [14 x i8] c"-INF FF800000\00"
@.str.2 = [12 x i8] c"+NAN 0x%08x\00"
@.str.3 = [12 x i8] c"-NAN 0x%08x\00"
@.str.4 = [6 x i8] c"%#.7g\00"
define i32 @Printfloat4(i8* %0, float %1) {
%3 = alloca i8*
%4 = alloca float
%5 = alloca i32
store i8* %0, i8** %3
store float %1, float* %4
%6 = bitcast float* %4 to i32*
%7 = load i32, i32* %6
%8 = zext i32 %7 to i64
%9 = icmp eq i64 %8, 2139095040
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %5
br label %51
13: ; preds = %2
%14 = bitcast float* %4 to i32*
%15 = load i32, i32* %14
%16 = zext i32 %15 to i64
%17 = icmp eq i64 %16, 4286578688
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 %20, i32* %5
br label %50
21: ; preds = %13
%22 = bitcast float* %4 to i32*
%23 = load i32, i32* %22
%24 = zext i32 %23 to i64
%25 = and i64 %24, 4286578688
%26 = icmp eq i64 %25, 2139095040
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = bitcast float* %4 to i32*
%30 = load i32, i32* %29
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %30)
store i32 %31, i32* %5
br label %49
32: ; preds = %21
%33 = bitcast float* %4 to i32*
%34 = load i32, i32* %33
%35 = zext i32 %34 to i64
%36 = and i64 %35, 4286578688
%37 = icmp eq i64 %36, 4286578688
br i1 %37, label %38, label %43
38: ; preds = %32
%39 = load i8*, i8** %3
%40 = bitcast float* %4 to i32*
%41 = load i32, i32* %40
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %41)
store i32 %42, i32* %5
br label %48
43: ; preds = %32
%44 = load i8*, i8** %3
%45 = load float, float* %4
%46 = fpext float %45 to double
%47 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %46)
store i32 %47, i32* %5
br label %48
48: ; preds = %43, %38
br label %49
49: ; preds = %48, %27
br label %50
50: ; preds = %49, %18
br label %51
51: ; preds = %50, %10
%52 = load i32, i32* %5
ret i32 %52
}

LLVM IR (-O2):
@.str = [14 x i8] c"+INF 7F800000\00"
@.str.1 = [14 x i8] c"-INF FF800000\00"
@.str.2 = [12 x i8] c"+NAN 0x%08x\00"
@.str.3 = [12 x i8] c"-NAN 0x%08x\00"
@.str.4 = [6 x i8] c"%#.7g\00"
define i32 @Printfloat4(i8* nocapture writeonly %0, float %1) {
%3 = bitcast float %1 to i32
switch i32 %3, label %6 [
i32 2139095040, label %4
i32 -8388608, label %5
]
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(14) %0, i8* align 1 dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 14, i1 false)
br label %18
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(14) %0, i8* align 1 dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 14, i1 false)
br label %18
6: ; preds = %2
%7 = and i32 %3, -8388608
%8 = icmp eq i32 %7, 2139095040
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %3)
br label %18
11: ; preds = %6
%12 = icmp ugt i32 %3, -8388609
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %3)
br label %18
15: ; preds = %11
%16 = fpext float %1 to double
%17 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %16)
br label %18
18: ; preds = %5, %13, %15, %9, %4
%19 = phi i32 [ 13, %4 ], [ 13, %5 ], [ %10, %9 ], [ %14, %13 ], [ %17, %15 ]
ret i32 %19
}