float gem_loge(float number) {
  int *const exp_ptr = ((int *)&number);
  int x = *exp_ptr;
  const int log_2 = ((x >> 23) & 255) - 128;
  x &= ~(255 << 23);
  x += 127 << 23;
  *exp_ptr = x;
  number = ((-1.0f / 3) * number + 2) * number - 2.0f / 3;
  return ((number + log_2) * 0.69314718);
}


x86 assembly (clang, -O0):
<gem_loge>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x17,%eax
and    $0xff,%eax
sub    $0x80,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
and    $0x807fffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x3f800000,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x4(%rbp),%xmm0
movss  0xeb3(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xeab(%rip),%xmm1
addss  %xmm1,%xmm0
movss  -0x4(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe8e(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe63(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<gem_loge>:
movd   %xmm0,%eax
mov    %eax,%ecx
shr    $0x17,%ecx
movzbl %cl,%ecx
add    $0xffffff80,%ecx
and    $0x807fffff,%eax
or     $0x3f800000,%eax
movd   %eax,%xmm0
movss  0xedb(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xed3(%rip),%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
addss  0xec4(%rip),%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xebc(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @gem_loge(float %0) {
%2 = alloca float
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store float %0, float* %2
%6 = bitcast float* %2 to i32*
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = load i32, i32* %7
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = ashr i32 %9, 23
%11 = and i32 %10, 255
%12 = sub nsw i32 %11, 128
store i32 %12, i32* %5
%13 = load i32, i32* %4
%14 = and i32 %13, -2139095041
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1065353216
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = load i32*, i32** %3
store i32 %17, i32* %18
%19 = load float, float* %2
%20 = call float @llvm.fmuladd.f32(float 0xBFD5555560000000, float %19, float 2.000000e+00)
%21 = load float, float* %2
%22 = call float @llvm.fmuladd.f32(float %20, float %21, float 0xBFE5555560000000)
store float %22, float* %2
%23 = load float, float* %2
%24 = load i32, i32* %5
%25 = sitofp i32 %24 to float
%26 = fadd float %23, %25
%27 = fpext float %26 to double
%28 = fmul double %27, 0x3FE62E42FEAD449C
%29 = fptrunc double %28 to float
ret float %29
}

LLVM IR (-O2):
define float @gem_loge(float %0) {
%2 = bitcast float %0 to i32
%3 = lshr i32 %2, 23
%4 = and i32 %3, 255
%5 = add nsw i32 %4, -128
%6 = and i32 %2, -2139095041
%7 = or i32 %6, 1065353216
%8 = bitcast i32 %7 to float
%9 = tail call float @llvm.fmuladd.f32(float %8, float 0xBFD5555560000000, float 2.000000e+00)
%10 = tail call float @llvm.fmuladd.f32(float %9, float %8, float 0xBFE5555560000000)
%11 = sitofp i32 %5 to float
%12 = fadd float %10, %11
%13 = fpext float %12 to double
%14 = fmul double %13, 0x3FE62E42FEAD449C
%15 = fptrunc double %14 to float
ret float %15
}