float ieee_to_real(x, iflg)
char *x;
int *iflg;
{
  float xx;
  long *ll, xl;
  int i;
  char *cb;
  for (i = 0, cb = (char *)&xx; i < 4; i++)
    *cb++ = x[i];
  ll = (long *)&xx;
  *iflg = 0;
  xl = *ll;
  if ((xl & 0x7F800000) == 0x7F800000) {
    *iflg = 1;
    (*ll) = 0x7F800000;
  } else if ((xl & 0x7F800000) == 0) {
    xx = 0.0;
    return (xx);
  }
  return (xx);
}


x86 assembly (clang, -O0):
<ieee_to_real>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x1c(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    114f <ieee_to_real+0x4f>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x40(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x40(%rbp)
mov    %cl,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    111b <ieee_to_real+0x1b>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0x7f800000,%rax
cmp    $0x7f800000,%rax
jne    119c <ieee_to_real+0x9c>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rax
movq   $0x7f800000,(%rax)
jmp    11cc <ieee_to_real+0xcc>
mov    -0x30(%rbp),%rax
and    $0x7f800000,%rax
cmp    $0x0,%rax
jne    11c7 <ieee_to_real+0xc7>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d6 <ieee_to_real+0xd6>
jmp    11cc <ieee_to_real+0xcc>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ieee_to_real>:
movd   (%rdi),%xmm0
movd   %xmm0,-0x8(%rsp)
movl   $0x0,(%rsi)
mov    -0x8(%rsp),%rcx
mov    %rcx,%rax
and    $0x7f800000,%rax
je     1133 <ieee_to_real+0x33>
movd   %ecx,%xmm0
cmp    $0x7f800000,%rax
jne    1137 <ieee_to_real+0x37>
movl   $0x1,(%rsi)
ret
pxor   %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @ieee_to_real(i8* %0, i32* %1) {
%3 = alloca float
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca float
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 0, i32* %9
%11 = bitcast float* %6 to i8*
store i8* %11, i8** %10
br label %12
12: ; preds = %23, %2
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = load i8*, i8** %10
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %10
store i8 %20, i8* %21
br label %23
23: ; preds = %15
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %12
26: ; preds = %12
%27 = bitcast float* %6 to i64*
store i64* %27, i64** %7
%28 = load i32*, i32** %5
store i32 0, i32* %28
%29 = load i64*, i64** %7
%30 = load i64, i64* %29
store i64 %30, i64* %8
%31 = load i64, i64* %8
%32 = and i64 %31, 2139095040
%33 = icmp eq i64 %32, 2139095040
br i1 %33, label %34, label %37
34: ; preds = %26
%35 = load i32*, i32** %5
store i32 1, i32* %35
%36 = load i64*, i64** %7
store i64 2139095040, i64* %36
br label %44
37: ; preds = %26
%38 = load i64, i64* %8
%39 = and i64 %38, 2139095040
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
store float 0.000000e+00, float* %6
%42 = load float, float* %6
store float %42, float* %3
br label %46
43: ; preds = %37
br label %44
44: ; preds = %43, %34
%45 = load float, float* %6
store float %45, float* %3
br label %46
46: ; preds = %44, %41
%47 = load float, float* %3
ret float %47
}

LLVM IR (-O2):
define float @ieee_to_real(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca float
%4 = bitcast float* %3 to i8*
%5 = bitcast i8* %0 to float*
%6 = load float, float* %5
store float %6, float* %3
store i32 0, i32* %1
%7 = bitcast float* %3 to i64*
%8 = load i64, i64* %7
%9 = and i64 %8, 2139095040
%10 = trunc i64 %8 to i32
%11 = bitcast i32 %10 to float
switch i64 %9, label %14 [
i64 2139095040, label %12
i64 0, label %13
]
12: ; preds = %2
store i32 1, i32* %1
br label %14
13: ; preds = %2
br label %14
14: ; preds = %12, %2, %13
%15 = phi float [ 0.000000e+00, %13 ], [ %11, %2 ], [ %11, %12 ]
ret float %15
}