#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int int32_t;

/* Variables and functions */
scalar_t__ INFINITY;
float log_approx(float val) {
  union {
    float f;
    int32_t i;
  } valu;
  float exp, addcst, x;
  valu.f = val;
  exp = valu.i >> 23;
  addcst = val > 0 ? -89.970756366f : -(float)INFINITY;
  valu.i = (valu.i & 0x7FFFFF) | 0x3F800000;
  x = valu.f;
  return x * (3.529304993f +
              x * (-2.461222105f +
                   x * (1.130626167f +
                        x * (-0.288739945f + x * 3.110401639e-2f)))) +
         (addcst + 0.69314718055995f * exp);
}


x86 assembly (clang, -O0):
<log_approx>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x17,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1145 <log_approx+0x45>
movss  0xec5(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1163 <log_approx+0x63>
mov    0x2e9c(%rip),%rax
cvtsi2ssq (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x7fffff,%eax
or     $0x3f800000,%eax
mov    %eax,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
movss  -0x14(%rbp),%xmm3
movss  -0x14(%rbp),%xmm4
movss  0xe6c(%rip),%xmm5
mulss  %xmm5,%xmm4
movss  0xe64(%rip),%xmm5
addss  %xmm5,%xmm4
mulss  %xmm4,%xmm3
movss  0xe4c(%rip),%xmm4
addss  %xmm4,%xmm3
mulss  %xmm3,%xmm1
movss  0xe38(%rip),%xmm3
addss  %xmm3,%xmm1
mulss  %xmm1,%xmm2
movss  0xe24(%rip),%xmm1
addss  %xmm1,%xmm2
movss  -0x10(%rbp),%xmm3
movss  -0xc(%rbp),%xmm1
movss  0xe0a(%rip),%xmm4
mulss  %xmm4,%xmm1
addss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_approx>:
movd   %xmm0,%eax
mov    %eax,%ecx
sar    $0x17,%ecx
cvtsi2ss %ecx,%xmm1
mov    0x2ed4(%rip),%rcx
cvtsi2ssq (%rcx),%xmm3
xorps  0xee0(%rip),%xmm3
xorps  %xmm2,%xmm2
cmpltss %xmm0,%xmm2
movss  0xee0(%rip),%xmm4
andps  %xmm2,%xmm4
and    $0x7fffff,%eax
or     $0x3f800000,%eax
movd   %eax,%xmm5
movss  0xecb(%rip),%xmm0
mulss  %xmm5,%xmm0
addss  0xec3(%rip),%xmm0
andnps %xmm3,%xmm2
mulss  %xmm5,%xmm0
addss  0xeb8(%rip),%xmm0
mulss  %xmm5,%xmm0
addss  0xeb0(%rip),%xmm0
mulss  %xmm5,%xmm0
addss  0xea8(%rip),%xmm0
mulss  0xea4(%rip),%xmm1
orps   %xmm4,%xmm2
addss  %xmm2,%xmm1
mulss  %xmm5,%xmm0
addss  %xmm1,%xmm0
ret

LLVM IR (-O0):
%union.anon = type { float }
@INFINITY = global i64 0
define float @log_approx(float %0) {
%2 = alloca float
%3 = alloca %union.anon
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %2
%7 = load float, float* %2
%8 = bitcast %union.anon* %3 to float*
store float %7, float* %8
%9 = bitcast %union.anon* %3 to i32*
%10 = load i32, i32* %9
%11 = ashr i32 %10, 23
%12 = sitofp i32 %11 to float
store float %12, float* %4
%13 = load float, float* %2
%14 = fcmp ogt float %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %1
br label %20
16: ; preds = %1
%17 = load i64, i64* @INFINITY
%18 = sitofp i64 %17 to float
%19 = fneg float %18
br label %20
20: ; preds = %16, %15
%21 = phi float [ 0xC0567E20E0000000, %15 ], [ %19, %16 ]
store float %21, float* %5
%22 = bitcast %union.anon* %3 to i32*
%23 = load i32, i32* %22
%24 = and i32 %23, 8388607
%25 = or i32 %24, 1065353216
%26 = bitcast %union.anon* %3 to i32*
store i32 %25, i32* %26
%27 = bitcast %union.anon* %3 to float*
%28 = load float, float* %27
store float %28, float* %6
%29 = load float, float* %6
%30 = load float, float* %6
%31 = load float, float* %6
%32 = load float, float* %6
%33 = load float, float* %6
%34 = call float @llvm.fmuladd.f32(float %33, float 0x3F9FD9BB40000000, float 0xBFD27AB720000000)
%35 = call float @llvm.fmuladd.f32(float %32, float %34, float 0x3FF2170B80000000)
%36 = call float @llvm.fmuladd.f32(float %31, float %35, float 0xC003B09540000000)
%37 = call float @llvm.fmuladd.f32(float %30, float %36, float 0x400C3C0440000000)
%38 = load float, float* %5
%39 = load float, float* %4
%40 = call float @llvm.fmuladd.f32(float 0x3FE62E4300000000, float %39, float %38)
%41 = call float @llvm.fmuladd.f32(float %29, float %37, float %40)
ret float %41
}

LLVM IR (-O2):
@INFINITY = global i64 0
define float @log_approx(float %0) {
%2 = bitcast float %0 to i32
%3 = ashr i32 %2, 23
%4 = sitofp i32 %3 to float
%5 = fcmp ogt float %0, 0.000000e+00
%6 = load i64, i64* @INFINITY
%7 = sitofp i64 %6 to float
%8 = fneg float %7
%9 = select i1 %5, float 0xC0567E20E0000000, float %8
%10 = and i32 %2, 8388607
%11 = or i32 %10, 1065353216
%12 = bitcast i32 %11 to float
%13 = tail call float @llvm.fmuladd.f32(float %12, float 0x3F9FD9BB40000000, float 0xBFD27AB720000000)
%14 = tail call float @llvm.fmuladd.f32(float %12, float %13, float 0x3FF2170B80000000)
%15 = tail call float @llvm.fmuladd.f32(float %12, float %14, float 0xC003B09540000000)
%16 = tail call float @llvm.fmuladd.f32(float %12, float %15, float 0x400C3C0440000000)
%17 = tail call float @llvm.fmuladd.f32(float %4, float 0x3FE62E4300000000, float %9)
%18 = tail call float @llvm.fmuladd.f32(float %12, float %16, float %17)
ret float %18
}