double log(x)
double x;
{
  int exp;
  static double coeff[] = {
      0.0000000000, 0.9999964239,  -0.4998741238, 0.3317990258,  -0.2407338084,
      0.1676540711, -0.0953293897, 0.0360884937,  -0.0064535442,
  };
  if (x <= 0.0)
    return 0.0;
  x = frexp(x, &exp) * 2.0 - 1.0;
  exp--;
  x = eval_poly(x, coeff, sizeof coeff / sizeof coeff[0] - 1);
  return x + 0.69314718055995 * exp;
}


x86 assembly (clang, -O0):
<log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1148 <log+0x28>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b4 <log+0x94>
movsd  -0x10(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
call   1040 <frexp@plt>
addsd  %xmm0,%xmm0
movsd  0xea6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0x2ec0(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%al
call   1030 <eval_poly@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe59(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log>:
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    117f <log+0x5f>
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1040 <frexp@plt>
addsd  %xmm0,%xmm0
addsd  0xebb(%rip),%xmm0
mov    0xc(%rsp),%ebx
add    $0xffffffff,%ebx
lea    0x2eed(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%al
call   1030 <eval_poly@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe93(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret
xorpd  %xmm0,%xmm0
ret

LLVM IR (-O0):
@log.coeff = internal global [9 x double] [double 0.000000e+00, double 0x3FEFFFF880188EF9, double 0xBFDFFDF009759C25, double 0x3FD53C31FB29F656, double 0xBFCED05D8D0F4CC3, double 0x3FC575B048353795, double 0xBFB86781C31BF08D, double 0x3FA27A30E8682450, double 0xBF7A6F0814844307]
define double @log(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp ole double %5, 0.000000e+00
br i1 %6, label %7, label %8
7: ; preds = %1
store double 0.000000e+00, double* %2
br label %21
8: ; preds = %1
%9 = load double, double* %3
%10 = call double @frexp(double %9, i32* %4)
%11 = call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double -1.000000e+00)
store double %11, double* %3
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = load double, double* %3
%15 = call i32 (double, double*, i64, ...) bitcast (i32 (...)* @eval_poly to i32 (double, double*, i64, ...)*)(double %14, double* getelementptr inbounds ([9 x double], [9 x double]* @log.coeff, i64 0, i64 0), i64 8)
%16 = sitofp i32 %15 to double
store double %16, double* %3
%17 = load double, double* %3
%18 = load i32, i32* %4
%19 = sitofp i32 %18 to double
%20 = call double @llvm.fmuladd.f64(double 0x3FE62E42FEFA3A19, double %19, double %17)
store double %20, double* %2
br label %21
21: ; preds = %8, %7
%22 = load double, double* %2
ret double %22
}

LLVM IR (-O2):
@log.coeff = internal global [9 x double] [double 0.000000e+00, double 0x3FEFFFF880188EF9, double 0xBFDFFDF009759C25, double 0x3FD53C31FB29F656, double 0xBFCED05D8D0F4CC3, double 0x3FC575B048353795, double 0xBFB86781C31BF08D, double 0x3FA27A30E8682450, double 0xBF7A6F0814844307]
define double @log(double %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = fcmp ugt double %0, 0.000000e+00
br i1 %4, label %5, label %14
5: ; preds = %1
%6 = call double @frexp(double %0, i32* %2)
%7 = tail call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double -1.000000e+00)
%8 = load i32, i32* %2
%9 = add nsw i32 %8, -1
%10 = tail call i32 (double, double*, i64, ...) bitcast (i32 (...)* @eval_poly to i32 (double, double*, i64, ...)*)(double %7, double* getelementptr inbounds ([9 x double], [9 x double]* @log.coeff, i64 0, i64 0), i64 8)
%11 = sitofp i32 %10 to double
%12 = sitofp i32 %9 to double
%13 = tail call double @llvm.fmuladd.f64(double %12, double 0x3FE62E42FEFA3A19, double %11)
br label %14
14: ; preds = %1, %5
%15 = phi double [ %13, %5 ], [ 0.000000e+00, %1 ]
ret double %15
}