#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 */

/* Variables and functions */
int /*<<< orphan*/ fabsf(float);
float frexpf(int /*<<< orphan*/, int *);
float log2f_approx(float X) {
  int E;
  const float F = frexpf(fabsf(X), &E);
  float Y = 1.23149591368684f;
  Y *= F;
  Y += -4.11852516267426f;
  Y *= F;
  Y += 6.02197014179219f;
  Y *= F;
  Y += -3.13396450166353f;
  Y += E;
  return Y;
}


x86 assembly (clang, -O0):
<log2f_approx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabsf@plt>
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1040 <frexpf@plt>
movss  %xmm0,-0xc(%rbp)
movss  0xebd(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe9d(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe78(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe53(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log2f_approx>:
push   %rax
call   1030 <fabsf@plt>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1040 <frexpf@plt>
movss  0xec6(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xebe(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xeb6(%rip),%xmm1
mulss  %xmm1,%xmm0
addss  0xeae(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x4(%rsp),%xmm1
addss  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @log2f_approx(float %0) {
%2 = alloca float
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store float %0, float* %2
%6 = load float, float* %2
%7 = call i32 @fabsf(float %6)
%8 = call float @frexpf(i32 %7, i32* %3)
store float %8, float* %4
store float 0x3FF3B43500000000, float* %5
%9 = load float, float* %4
%10 = load float, float* %5
%11 = fmul float %10, %9
store float %11, float* %5
%12 = load float, float* %5
%13 = fadd float %12, 0xC010795EA0000000
store float %13, float* %5
%14 = load float, float* %4
%15 = load float, float* %5
%16 = fmul float %15, %14
store float %16, float* %5
%17 = load float, float* %5
%18 = fadd float %17, 0x4018167F60000000
store float %18, float* %5
%19 = load float, float* %4
%20 = load float, float* %5
%21 = fmul float %20, %19
store float %21, float* %5
%22 = load float, float* %5
%23 = fadd float %22, 0xC009125C00000000
store float %23, float* %5
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to float
%26 = load float, float* %5
%27 = fadd float %26, %25
store float %27, float* %5
%28 = load float, float* %5
ret float %28
}

LLVM IR (-O2):
define float @log2f_approx(float %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @fabsf(float %0)
%5 = call float @frexpf(i32 %4, i32* %2)
%6 = fmul float %5, 0x3FF3B43500000000
%7 = fadd float %6, 0xC010795EA0000000
%8 = fmul float %5, %7
%9 = fadd float %8, 0x4018167F60000000
%10 = fmul float %5, %9
%11 = fadd float %10, 0xC009125C00000000
%12 = load i32, i32* %2
%13 = sitofp i32 %12 to float
%14 = fadd float %11, %13
ret float %14
}