double log(x)
double x;
{
  typedef union {
    double d;
    unsigned u[4];
  } DBL;
  double y, z, z2, p;
  unsigned ex;
  int ix;
  DBL *xp, *yp;
  xp = (DBL *)&x;
  if (xp->d <= 0.0)
    return (y);
  y = 0.0;
  yp = (DBL *)&y;
  yp->u[3] = xp->u[3] & ~0100017;
  ix = (yp->u[3] >> 4) - 1023;
  if ((xp->d - yp->d) == 0.0)
    return (.693147180559945 * (double)ix);
  xp->u[3] -= ++ix << 4;
  xp->d *= 1.4142135623730950488;
  z = (xp->d - 1.0) / (xp->d + 1.0);
  z2 = z * z;
  y = z * (2.000000000046727 +
           z2 * (0.666666635059382 +
                 z2 * (0.4000059794795 +
                       z2 * (0.28525381498 + z2 * 0.2376245609))));
  y = y + .693147180559945 * ((double)ix - 0.5);
  return (yp->d);
}


x86 assembly (clang, -O0):
<log>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     1131 <log+0x31>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12af <log+0x1af>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    0xc(%rax),%ecx
and    $0xffff7ff0,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%eax
shr    $0x4,%eax
sub    $0x3ff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
subsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a5 <log+0xa5>
jp     11a5 <log+0xa5>
cvtsi2sdl -0x38(%rbp),%xmm1
movsd  0xe69(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12af <log+0x1af>
mov    -0x38(%rbp),%edx
add    $0x1,%edx
mov    %edx,-0x38(%rbp)
shl    $0x4,%edx
mov    -0x40(%rbp),%rax
mov    0xc(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0xc(%rax)
mov    -0x40(%rbp),%rax
movsd  0xe77(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe57(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  0xe47(%rip),%xmm1
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movsd  0xdfa(%rip),%xmm5
mulsd  %xmm5,%xmm4
movsd  0xdf6(%rip),%xmm5
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm3
movsd  0xdd6(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xdbe(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xda6(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x38(%rbp),%xmm0
movsd  0xd7f(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xd6b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<log>:
ret

LLVM IR (-O0):
%union.DBL = type { double, [8 x i8] }
define double @log(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca %union.DBL*
%11 = alloca %union.DBL*
store double %0, double* %3
%12 = bitcast double* %3 to %union.DBL*
store %union.DBL* %12, %union.DBL** %10
%13 = load %union.DBL*, %union.DBL** %10
%14 = bitcast %union.DBL* %13 to double*
%15 = load double, double* %14
%16 = fcmp ole double %15, 0.000000e+00
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = load double, double* %4
store double %18, double* %2
br label %90
19: ; preds = %1
store double 0.000000e+00, double* %4
%20 = bitcast double* %4 to %union.DBL*
store %union.DBL* %20, %union.DBL** %11
%21 = load %union.DBL*, %union.DBL** %10
%22 = bitcast %union.DBL* %21 to [4 x i32]*
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %22, i64 0, i64 3
%24 = load i32, i32* %23
%25 = and i32 %24, -32784
%26 = load %union.DBL*, %union.DBL** %11
%27 = bitcast %union.DBL* %26 to [4 x i32]*
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %27, i64 0, i64 3
store i32 %25, i32* %28
%29 = load %union.DBL*, %union.DBL** %11
%30 = bitcast %union.DBL* %29 to [4 x i32]*
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %30, i64 0, i64 3
%32 = load i32, i32* %31
%33 = lshr i32 %32, 4
%34 = sub i32 %33, 1023
store i32 %34, i32* %9
%35 = load %union.DBL*, %union.DBL** %10
%36 = bitcast %union.DBL* %35 to double*
%37 = load double, double* %36
%38 = load %union.DBL*, %union.DBL** %11
%39 = bitcast %union.DBL* %38 to double*
%40 = load double, double* %39
%41 = fsub double %37, %40
%42 = fcmp oeq double %41, 0.000000e+00
br i1 %42, label %43, label %47
43: ; preds = %19
%44 = load i32, i32* %9
%45 = sitofp i32 %44 to double
%46 = fmul double 0x3FE62E42FEFA39EC, %45
store double %46, double* %2
br label %90
47: ; preds = %19
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
%50 = shl i32 %49, 4
%51 = load %union.DBL*, %union.DBL** %10
%52 = bitcast %union.DBL* %51 to [4 x i32]*
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %52, i64 0, i64 3
%54 = load i32, i32* %53
%55 = sub i32 %54, %50
store i32 %55, i32* %53
%56 = load %union.DBL*, %union.DBL** %10
%57 = bitcast %union.DBL* %56 to double*
%58 = load double, double* %57
%59 = fmul double %58, 0x3FF6A09E667F3BCD
store double %59, double* %57
%60 = load %union.DBL*, %union.DBL** %10
%61 = bitcast %union.DBL* %60 to double*
%62 = load double, double* %61
%63 = fsub double %62, 1.000000e+00
%64 = load %union.DBL*, %union.DBL** %10
%65 = bitcast %union.DBL* %64 to double*
%66 = load double, double* %65
%67 = fadd double %66, 1.000000e+00
%68 = fdiv double %63, %67
store double %68, double* %5
%69 = load double, double* %5
%70 = load double, double* %5
%71 = fmul double %69, %70
store double %71, double* %6
%72 = load double, double* %5
%73 = load double, double* %6
%74 = load double, double* %6
%75 = load double, double* %6
%76 = load double, double* %6
%77 = call double @llvm.fmuladd.f64(double %76, double 0x3FCE6A7B4AE55BAE, double 0x3FD2419937997E52)
%78 = call double @llvm.fmuladd.f64(double %75, double %77, double 0x3FD999B2AE0468DA)
%79 = call double @llvm.fmuladd.f64(double %74, double %78, double 0x3FE55555445D42DE)
%80 = call double @llvm.fmuladd.f64(double %73, double %79, double 0x4000000000019B04)
%81 = fmul double %72, %80
store double %81, double* %4
%82 = load double, double* %4
%83 = load i32, i32* %9
%84 = sitofp i32 %83 to double
%85 = fsub double %84, 5.000000e-01
%86 = call double @llvm.fmuladd.f64(double 0x3FE62E42FEFA39EC, double %85, double %82)
store double %86, double* %4
%87 = load %union.DBL*, %union.DBL** %11
%88 = bitcast %union.DBL* %87 to double*
%89 = load double, double* %88
store double %89, double* %2
br label %90
90: ; preds = %47, %43, %17
%91 = load double, double* %2
ret double %91
}

LLVM IR (-O2):
%union.DBL = type { double, [8 x i8] }
define double @log(double %0) {
ret double undef
}