#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) {
  void *F = &f;
  int k;
  if (*(unsigned int *)F == (unsigned int)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    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x7f800000,(%rax)
jne    1153 <Printfloat4+0x43>
mov    -0x8(%rbp),%rdi
lea    0xebc(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    122e <Printfloat4+0x11e>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    $0xff800000,%ecx
cmp    %rcx,%rax
jne    1181 <Printfloat4+0x71>
mov    -0x8(%rbp),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1229 <Printfloat4+0x119>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
movabs $0xff800000,%rcx
and    %rcx,%rax
cmp    $0x7f800000,%rax
jne    11c0 <Printfloat4+0xb0>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1224 <Printfloat4+0x114>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
movabs $0xff800000,%rcx
and    %rcx,%rax
mov    $0xff800000,%ecx
cmp    %rcx,%rax
jne    1201 <Printfloat4+0xf1>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    121f <Printfloat4+0x10f>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1f(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1224 <Printfloat4+0x114>
jmp    1229 <Printfloat4+0x119>
jmp    122e <Printfloat4+0x11e>
mov    -0x1c(%rbp),%eax
add    $0x20,%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 i8*
%6 = alloca i32
store i8* %0, i8** %3
store float %1, float* %4
%7 = bitcast float* %4 to i8*
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 2139095040
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %6
br label %58
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = bitcast i8* %16 to i32*
%18 = load i32, i32* %17
%19 = zext i32 %18 to i64
%20 = icmp eq i64 %19, 4286578688
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 %23, i32* %6
br label %57
24: ; preds = %15
%25 = load i8*, i8** %5
%26 = bitcast i8* %25 to i32*
%27 = load i32, i32* %26
%28 = zext i32 %27 to i64
%29 = and i64 %28, 4286578688
%30 = icmp eq i64 %29, 2139095040
br i1 %30, label %31, label %37
31: ; preds = %24
%32 = load i8*, i8** %3
%33 = load i8*, i8** %5
%34 = bitcast i8* %33 to i32*
%35 = load i32, i32* %34
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %35)
store i32 %36, i32* %6
br label %56
37: ; preds = %24
%38 = load i8*, i8** %5
%39 = bitcast i8* %38 to i32*
%40 = load i32, i32* %39
%41 = zext i32 %40 to i64
%42 = and i64 %41, 4286578688
%43 = icmp eq i64 %42, 4286578688
br i1 %43, label %44, label %50
44: ; preds = %37
%45 = load i8*, i8** %3
%46 = load i8*, i8** %5
%47 = bitcast i8* %46 to i32*
%48 = load i32, i32* %47
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %48)
store i32 %49, i32* %6
br label %55
50: ; preds = %37
%51 = load i8*, i8** %3
%52 = load float, float* %4
%53 = fpext float %52 to double
%54 = call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %53)
store i32 %54, i32* %6
br label %55
55: ; preds = %50, %44
br label %56
56: ; preds = %55, %31
br label %57
57: ; preds = %56, %21
br label %58
58: ; preds = %57, %12
%59 = load i32, i32* %6
ret i32 %59
}

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
}