#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 */
unsigned int get_exp(unsigned int);
unsigned int get_frac(unsigned int);
unsigned int get_sign(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
float u2f(unsigned int);
void show_float(unsigned uf) {
  float f = u2f(uf);
  unsigned exp = get_exp(uf);
  unsigned frac = get_frac(uf);
  unsigned sign = get_sign(uf);
  printf("\nFloating point value %.10g\n", f);
  printf("Bit Representation 0x%.8x, sign = %x, exponent = 0x%.2x, fraction = "
         "0x%.6x\n",
         uf, sign, exp, frac);
  if (exp == ((1 << 8) - 1)) {
    if (frac == 0) {
      printf("%cInfinity\n", sign ? '-' : '+');
    } else
      printf("Not-A-Number\n");
  } else {
    int denorm = (exp == 0);
    int uexp = denorm ? 1 - ((1 << (8 - 1)) - 1) : exp - ((1 << (8 - 1)) - 1);
    int mantissa = denorm ? frac : frac + (1 << 23);
    float fman = (float)mantissa / (float)(1 << 23);
    printf("%s.  %c%.10f X 2^(%d)\n", denorm ? "Denormalized" : "Normalized",
           sign ? '-' : '+', fman, uexp);
  }
}


x86 assembly (clang, -O0):
<show_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <u2f@plt>
movss  %xmm0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <get_exp@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <get_frac@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <get_sign@plt>
mov    %eax,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xff,-0xc(%rbp)
jne    120b <show_float+0xbb>
cmpl   $0x0,-0x10(%rbp)
jne    11f8 <show_float+0xa8>
mov    -0x14(%rbp),%ecx
mov    $0x2b,%esi
mov    $0x2d,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1206 <show_float+0xb6>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c1 <show_float+0x171>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1231 <show_float+0xe1>
mov    $0xffffff82,%eax
mov    %eax,-0x28(%rbp)
jmp    123a <show_float+0xea>
mov    -0xc(%rbp),%eax
sub    $0x7f,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1255 <show_float+0x105>
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1260 <show_float+0x110>
mov    -0x10(%rbp),%eax
add    $0x800000,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cvtsi2ssl -0x20(%rbp),%xmm0
movss  0xd8d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%ecx
lea    0xe25(%rip),%rsi
lea    0xe11(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x14(%rbp),%ecx
mov    $0x2b,%edx
mov    $0x2d,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x1c(%rbp),%ecx
lea    0xdcd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_float>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1060 <u2f@plt>
movss  %xmm0,0x4(%rsp)
mov    %ebx,%edi
call   1080 <get_exp@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <get_frac@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   1070 <get_sign@plt>
mov    %eax,%r14d
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe71(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xff,%ebp
jne    11e4 <show_float+0x84>
test   %r15d,%r15d
je     1245 <show_float+0xe5>
lea    0xed3(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
lea    -0x7f(%rbp),%eax
lea    0x800000(%r15),%edx
test   %ebp,%ebp
cmove  %r15d,%edx
mov    $0xffffff82,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %edx,%xmm0
cmovne %eax,%ecx
mulss  0xdf5(%rip),%xmm0
lea    0xe7e(%rip),%rax
lea    0xe84(%rip),%rsi
cmove  %rax,%rsi
xor    %eax,%eax
test   %r14d,%r14d
setne  %al
lea    0x2b(%rax,%rax,1),%edx
cvtss2sd %xmm0,%xmm0
lea    0xe45(%rip),%rdi
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>
xor    %eax,%eax
test   %r14d,%r14d
setne  %al
lea    (%rax,%rax,1),%esi
add    $0x2b,%esi
lea    0xe13(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"\0AFloating point value %.10g\0A\00"
@.str.1 = [76 x i8] c"Bit Representation 0x%.8x, sign = %x, exponent = 0x%.2x, fraction = 0x%.6x\0A\00"
@.str.2 = [12 x i8] c"%cInfinity\0A\00"
@.str.3 = [14 x i8] c"Not-A-Number\0A\00"
@.str.4 = [23 x i8] c"%s. %c%.10f X 2^(%d)\0A\00"
@.str.5 = [13 x i8] c"Denormalized\00"
@.str.6 = [11 x i8] c"Normalized\00"
define void @show_float(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
store i32 %0, i32* %2
%11 = load i32, i32* %2
%12 = call float @u2f(i32 %11)
store float %12, float* %3
%13 = load i32, i32* %2
%14 = call i32 @get_exp(i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %2
%16 = call i32 @get_frac(i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %2
%18 = call i32 @get_sign(i32 %17)
store i32 %18, i32* %6
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %20)
%22 = load i32, i32* %2
%23 = load i32, i32* %6
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 255
br i1 %28, label %29, label %41
29: ; preds = %1
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 45, i32 43
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %40
38: ; preds = %29
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %32
br label %77
41: ; preds = %1
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 0
%44 = zext i1 %43 to i32
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %41
br label %51
48: ; preds = %41
%49 = load i32, i32* %4
%50 = sub i32 %49, 127
br label %51
51: ; preds = %48, %47
%52 = phi i32 [ -126, %47 ], [ %50, %48 ]
store i32 %52, i32* %8
%53 = load i32, i32* %7
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = load i32, i32* %5
br label %60
57: ; preds = %51
%58 = load i32, i32* %5
%59 = add i32 %58, 8388608
br label %60
60: ; preds = %57, %55
%61 = phi i32 [ %56, %55 ], [ %59, %57 ]
store i32 %61, i32* %9
%62 = load i32, i32* %9
%63 = sitofp i32 %62 to float
%64 = fdiv float %63, 0x4160000000000000
store float %64, float* %10
%65 = load i32, i32* %7
%66 = icmp ne i32 %65, 0
%67 = zext i1 %66 to i64
%68 = select i1 %66, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0)
%69 = load i32, i32* %6
%70 = icmp ne i32 %69, 0
%71 = zext i1 %70 to i64
%72 = select i1 %70, i32 45, i32 43
%73 = load float, float* %10
%74 = fpext float %73 to double
%75 = load i32, i32* %8
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %68, i32 %72, double %74, i32 %75)
br label %77
77: ; preds = %60, %40
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0AFloating point value %.10g\0A\00"
@.str.1 = [76 x i8] c"Bit Representation 0x%.8x, sign = %x, exponent = 0x%.2x, fraction = 0x%.6x\0A\00"
@.str.2 = [12 x i8] c"%cInfinity\0A\00"
@.str.4 = [23 x i8] c"%s. %c%.10f X 2^(%d)\0A\00"
@.str.5 = [13 x i8] c"Denormalized\00"
@.str.6 = [11 x i8] c"Normalized\00"
@str = [13 x i8] c"Not-A-Number\00"
define void @show_float(i32 %0) {
%2 = tail call float @u2f(i32 %0)
%3 = tail call i32 @get_exp(i32 %0)
%4 = tail call i32 @get_frac(i32 %0)
%5 = tail call i32 @get_sign(i32 %0)
%6 = fpext float %2 to double
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %5, i32 %3, i32 %4)
%9 = icmp eq i32 %3, 255
br i1 %9, label %10, label %18
10: ; preds = %1
%11 = icmp eq i32 %4, 0
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = icmp eq i32 %5, 0
%14 = select i1 %13, i32 43, i32 45
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %31
16: ; preds = %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %31
18: ; preds = %1
%19 = icmp eq i32 %3, 0
%20 = add i32 %3, -127
%21 = select i1 %19, i32 -126, i32 %20
%22 = add i32 %4, 8388608
%23 = select i1 %19, i32 %4, i32 %22
%24 = sitofp i32 %23 to float
%25 = fmul float %24, 0x3E80000000000000
%26 = select i1 %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0)
%27 = icmp eq i32 %5, 0
%28 = select i1 %27, i32 43, i32 45
%29 = fpext float %25 to double
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %26, i32 %28, double %29, i32 %21)
br label %31
31: ; preds = %12, %16, %18
ret void
}