#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 */
float dcn_bw_log(float a, float b) {
  int *const exp_ptr = (int *)(&a);
  int x = *exp_ptr;
  const int log_2 = ((x >> 23) & 255) - 128;
  x &= ~(255 << 23);
  x += 127 << 23;
  *exp_ptr = x;
  a = ((-1.0f / 3) * a + 2) * a - 2.0f / 3;
  if (b > 2.00001 || b < 1.99999)
    return (a + log_2) / dcn_bw_log(b, 2);
  else
    return (a + log_2);
}


x86 assembly (clang, -O0):
<dcn_bw_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x17,%eax
and    $0xff,%eax
sub    $0x80,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x807fffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x3f800000,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x8(%rbp),%xmm0
movss  0xea2(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe9a(%rip),%xmm1
addss  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe7d(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe53(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11d2 <dcn_bw_log+0xc2>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe40(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    120d <dcn_bw_log+0xfd>
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe26(%rip),%xmm1
call   1030 <dcn_bw_log@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1220 <dcn_bw_log+0x110>
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcn_bw_log>:
movd   %xmm0,%eax
mov    %eax,%ecx
shr    $0x17,%ecx
movzbl %cl,%ecx
and    $0x807fffff,%eax
or     $0x3f800000,%eax
movd   %eax,%xmm0
movss  0xede(%rip),%xmm3
mulss  %xmm0,%xmm3
addss  0xed6(%rip),%xmm3
add    $0xffffff80,%ecx
mulss  %xmm0,%xmm3
addss  0xecb(%rip),%xmm3
cvtss2sd %xmm1,%xmm2
ucomisd 0xec7(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
addss  %xmm3,%xmm0
ja     1165 <dcn_bw_log+0x65>
movsd  0xeba(%rip),%xmm3
ucomisd %xmm2,%xmm3
ja     1165 <dcn_bw_log+0x65>
ret
movd   %xmm1,%eax
mov    %eax,%ecx
shr    $0x17,%ecx
movzbl %cl,%ecx
add    $0xffffff80,%ecx
and    $0x807fffff,%eax
or     $0x3f800000,%eax
movd   %eax,%xmm1
movss  0xe76(%rip),%xmm2
mulss  %xmm1,%xmm2
addss  0xe6e(%rip),%xmm2
mulss  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
addss  0xe5f(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @dcn_bw_log(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store float %0, float* %4
store float %1, float* %5
%9 = bitcast float* %4 to i32*
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = ashr i32 %12, 23
%14 = and i32 %13, 255
%15 = sub nsw i32 %14, 128
store i32 %15, i32* %8
%16 = load i32, i32* %7
%17 = and i32 %16, -2139095041
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1065353216
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = load i32*, i32** %6
store i32 %20, i32* %21
%22 = load float, float* %4
%23 = call float @llvm.fmuladd.f32(float 0xBFD5555560000000, float %22, float 2.000000e+00)
%24 = load float, float* %4
%25 = call float @llvm.fmuladd.f32(float %23, float %24, float 0xBFE5555560000000)
store float %25, float* %4
%26 = load float, float* %5
%27 = fpext float %26 to double
%28 = fcmp ogt double %27, 2.000010e+00
br i1 %28, label %33, label %29
29: ; preds = %2
%30 = load float, float* %5
%31 = fpext float %30 to double
%32 = fcmp olt double %31, 1.999990e+00
br i1 %32, label %33, label %41
33: ; preds = %29, %2
%34 = load float, float* %4
%35 = load i32, i32* %8
%36 = sitofp i32 %35 to float
%37 = fadd float %34, %36
%38 = load float, float* %5
%39 = call float @dcn_bw_log(float %38, float 2.000000e+00)
%40 = fdiv float %37, %39
store float %40, float* %3
br label %46
41: ; preds = %29
%42 = load float, float* %4
%43 = load i32, i32* %8
%44 = sitofp i32 %43 to float
%45 = fadd float %42, %44
store float %45, float* %3
br label %46
46: ; preds = %41, %33
%47 = load float, float* %3
ret float %47
}

LLVM IR (-O2):
define float @dcn_bw_log(float %0, float %1) {
%3 = bitcast float %0 to i32
%4 = lshr i32 %3, 23
%5 = and i32 %4, 255
%6 = add nsw i32 %5, -128
%7 = and i32 %3, -2139095041
%8 = or i32 %7, 1065353216
%9 = bitcast i32 %8 to float
%10 = tail call float @llvm.fmuladd.f32(float %9, float 0xBFD5555560000000, float 2.000000e+00)
%11 = tail call float @llvm.fmuladd.f32(float %10, float %9, float 0xBFE5555560000000)
%12 = fpext float %1 to double
%13 = fcmp ogt double %12, 2.000010e+00
%14 = fcmp olt double %12, 1.999990e+00
%15 = or i1 %13, %14
%16 = sitofp i32 %6 to float
%17 = fadd float %11, %16
br i1 %15, label %18, label %31
18: ; preds = %2
%19 = bitcast float %1 to i32
%20 = lshr i32 %19, 23
%21 = and i32 %20, 255
%22 = add nsw i32 %21, -128
%23 = and i32 %19, -2139095041
%24 = or i32 %23, 1065353216
%25 = bitcast i32 %24 to float
%26 = tail call float @llvm.fmuladd.f32(float %25, float 0xBFD5555560000000, float 2.000000e+00)
%27 = tail call float @llvm.fmuladd.f32(float %26, float %25, float 0xBFE5555560000000)
%28 = sitofp i32 %22 to float
%29 = fadd float %27, %28
%30 = fdiv float %17, %29
br label %31
31: ; preds = %2, %18
%32 = phi float [ %30, %18 ], [ %17, %2 ]
ret float %32
}