double ieee_to_dub(zx, iflg)
char *zx;
int *iflg;
{
  unsigned long int ii, jj, x[2];
  char *cx, *cy;
  double xx, yy, zz, sign, *dd, pow();
  int i;
  for (i = 0, cx = zx, cy = (char *)x; i < 8; i++)
    *cy++ = *cx++;
  *iflg = 0;
  if ((x[0] & 0x7FF00000) == 0x7FF00000)
    *iflg = 1;
  else if ((x[0] & 0x7FF00000) == 0) {
    yy = 0.0;
    return (yy);
  }
  dd = (double *)x;
  yy = *dd;
  return (yy);
}


x86 assembly (clang, -O0):
<ieee_to_dub>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpl   $0x8,-0x7c(%rbp)
jge    115d <ieee_to_dub+0x5d>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
mov    (%rax),%cl
mov    -0x50(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x50(%rbp)
mov    %cl,(%rax)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1123 <ieee_to_dub+0x23>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x40(%rbp),%rax
and    $0x7ff00000,%rax
cmp    $0x7ff00000,%rax
jne    118c <ieee_to_dub+0x8c>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11bc <ieee_to_dub+0xbc>
mov    -0x40(%rbp),%rax
and    $0x7ff00000,%rax
cmp    $0x0,%rax
jne    11b7 <ieee_to_dub+0xb7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11db <ieee_to_dub+0xdb>
jmp    11bc <ieee_to_dub+0xbc>
lea    -0x40(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ieee_to_dub>:
mov    (%rdi),%rax
movl   $0x0,(%rsi)
mov    %rax,%rcx
and    $0x7ff00000,%rcx
je     112a <ieee_to_dub+0x2a>
cmp    $0x7ff00000,%rcx
jne    1124 <ieee_to_dub+0x24>
movl   $0x1,(%rsi)
movq   %rax,%xmm0
ret
xorps  %xmm0,%xmm0
ret

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

LLVM IR (-O2):
define double @ieee_to_dub(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = bitcast i8* %0 to i64*
%4 = load i64, i64* %3
store i32 0, i32* %1
%5 = and i64 %4, 2146435072
switch i64 %5, label %7 [
i64 2146435072, label %6
i64 0, label %9
]
6: ; preds = %2
store i32 1, i32* %1
br label %7
7: ; preds = %2, %6
%8 = bitcast i64 %4 to double
br label %9
9: ; preds = %2, %7
%10 = phi double [ %8, %7 ], [ 0.000000e+00, %2 ]
ret double %10
}