#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 /*<<< orphan*/ __m128i;
typedef int /*<<< orphan*/ __m128;

/* Variables and functions */
int /*<<< orphan*/ _mm_add_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_and_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_castps_si128(int /*<<< orphan*/);
int /*<<< orphan*/ _mm_castsi128_ps(int /*<<< orphan*/);
int /*<<< orphan*/ _mm_cvtepi32_ps(int /*<<< orphan*/);
int /*<<< orphan*/ _mm_mul_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_or_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_set1_epi32(int);
int /*<<< orphan*/ _mm_set1_ps(float);
int /*<<< orphan*/ _mm_srli_epi32(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_sub_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_sub_ps(int /*<<< orphan*/, int /*<<< orphan*/);
__m128 _mm_log2_ps(__m128 x) {
  __m128i expmask = _mm_set1_epi32(0x7f800000);
  __m128i mantmask = _mm_set1_epi32(0x007fffff);
  __m128 one = _mm_set1_ps(1.0f);
  __m128i i = _mm_castps_si128(x);
  __m128 exp = _mm_cvtepi32_ps(_mm_sub_epi32(
      _mm_srli_epi32(_mm_and_si128(i, expmask), 23), _mm_set1_epi32(127)));
  __m128 mant = _mm_or_ps(_mm_castsi128_ps(_mm_and_si128(i, mantmask)), one);
  __m128 logmant;
  logmant = _mm_add_ps(
      _mm_mul_ps(
          _mm_add_ps(
              _mm_mul_ps(
                  _mm_add_ps(
                      _mm_mul_ps(
                          _mm_add_ps(
                              _mm_mul_ps(_mm_set1_ps(0.0596515482674574969533f),
                                         mant),
                              _mm_set1_ps(-0.465725644288844778798f)),
                          mant),
                      _mm_set1_ps(1.48116647521213171641f)),
                  mant),
              _mm_set1_ps(-2.52074962577807006663f)),
          mant),
      _mm_set1_ps(2.8882704548164776201f));
  logmant = _mm_mul_ps(logmant, _mm_sub_ps(mant, one));
  return _mm_add_ps(logmant, exp);
}


x86 assembly (clang, -O0):
<_mm_log2_ps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x7f800000,%edi
call   1090 <_mm_set1_epi32@plt>
mov    %eax,-0x8(%rbp)
mov    $0x7fffff,%edi
call   1090 <_mm_set1_epi32@plt>
mov    %eax,-0xc(%rbp)
movss  0xe27(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <_mm_castps_si128@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
call   10e0 <_mm_and_si128@plt>
mov    %eax,%edi
mov    $0x17,%esi
call   10d0 <_mm_srli_epi32@plt>
mov    %eax,-0x38(%rbp)
mov    $0x7f,%edi
call   1090 <_mm_set1_epi32@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_sub_epi32@plt>
mov    %eax,%edi
call   1030 <_mm_cvtepi32_ps@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
call   10e0 <_mm_and_si128@plt>
mov    %eax,%edi
call   1050 <_mm_castsi128_ps@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%esi
call   10c0 <_mm_or_ps@plt>
mov    %eax,-0x1c(%rbp)
movss  0xdb1(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,-0x34(%rbp)
movss  0xd93(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,-0x30(%rbp)
movss  0xd6b(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,-0x2c(%rbp)
movss  0xd43(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,-0x28(%rbp)
movss  0xd1b(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1080 <_mm_sub_ps@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
call   10b0 <_mm_add_ps@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mm_log2_ps>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
mov    $0x7f800000,%edi
call   1090 <_mm_set1_epi32@plt>
mov    %eax,%ebp
mov    $0x7fffff,%edi
call   1090 <_mm_set1_epi32@plt>
mov    %eax,%r12d
movss  0xe15(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   1040 <_mm_castps_si128@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %ebp,%esi
call   10e0 <_mm_and_si128@plt>
mov    %eax,%edi
mov    $0x17,%esi
call   10d0 <_mm_srli_epi32@plt>
mov    %eax,%ebp
mov    $0x7f,%edi
call   1090 <_mm_set1_epi32@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_sub_epi32@plt>
mov    %eax,%edi
call   1030 <_mm_cvtepi32_ps@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    %r12d,%esi
call   10e0 <_mm_and_si128@plt>
mov    %eax,%edi
call   1050 <_mm_castsi128_ps@plt>
mov    %eax,%edi
mov    %r15d,%esi
call   10c0 <_mm_or_ps@plt>
mov    %eax,%ebp
movss  0xdaf(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,%ebx
movss  0xd9b(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,%ebx
movss  0xd7e(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,%ebx
movss  0xd61(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,%ebx
movss  0xd44(%rip),%xmm0
call   10a0 <_mm_set1_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10b0 <_mm_add_ps@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r15d,%esi
call   1080 <_mm_sub_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <_mm_mul_ps@plt>
mov    %eax,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <_mm_add_ps@plt>

LLVM IR (-O0):
define i32 @_mm_log2_ps(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %2
%10 = call i32 @_mm_set1_epi32(i32 2139095040)
store i32 %10, i32* %3
%11 = call i32 @_mm_set1_epi32(i32 8388607)
store i32 %11, i32* %4
%12 = call i32 @_mm_set1_ps(float 1.000000e+00)
store i32 %12, i32* %5
%13 = load i32, i32* %2
%14 = call i32 @_mm_castps_si128(i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = call i32 @_mm_and_si128(i32 %15, i32 %16)
%18 = call i32 @_mm_srli_epi32(i32 %17, i32 23)
%19 = call i32 @_mm_set1_epi32(i32 127)
%20 = call i32 @_mm_sub_epi32(i32 %18, i32 %19)
%21 = call i32 @_mm_cvtepi32_ps(i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = call i32 @_mm_and_si128(i32 %22, i32 %23)
%25 = call i32 @_mm_castsi128_ps(i32 %24)
%26 = load i32, i32* %5
%27 = call i32 @_mm_or_ps(i32 %25, i32 %26)
store i32 %27, i32* %8
%28 = call i32 @_mm_set1_ps(float 0x3FAE8AA5E0000000)
%29 = load i32, i32* %8
%30 = call i32 @_mm_mul_ps(i32 %28, i32 %29)
%31 = call i32 @_mm_set1_ps(float 0xBFDDCE72E0000000)
%32 = call i32 @_mm_add_ps(i32 %30, i32 %31)
%33 = load i32, i32* %8
%34 = call i32 @_mm_mul_ps(i32 %32, i32 %33)
%35 = call i32 @_mm_set1_ps(float 0x3FF7B2DBA0000000)
%36 = call i32 @_mm_add_ps(i32 %34, i32 %35)
%37 = load i32, i32* %8
%38 = call i32 @_mm_mul_ps(i32 %36, i32 %37)
%39 = call i32 @_mm_set1_ps(float 0xC0042A7EC0000000)
%40 = call i32 @_mm_add_ps(i32 %38, i32 %39)
%41 = load i32, i32* %8
%42 = call i32 @_mm_mul_ps(i32 %40, i32 %41)
%43 = call i32 @_mm_set1_ps(float 0x40071B2D80000000)
%44 = call i32 @_mm_add_ps(i32 %42, i32 %43)
store i32 %44, i32* %9
%45 = load i32, i32* %9
%46 = load i32, i32* %8
%47 = load i32, i32* %5
%48 = call i32 @_mm_sub_ps(i32 %46, i32 %47)
%49 = call i32 @_mm_mul_ps(i32 %45, i32 %48)
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = load i32, i32* %7
%52 = call i32 @_mm_add_ps(i32 %50, i32 %51)
ret i32 %52
}

LLVM IR (-O2):
define i32 @_mm_log2_ps(i32 %0) {
%2 = tail call i32 @_mm_set1_epi32(i32 2139095040)
%3 = tail call i32 @_mm_set1_epi32(i32 8388607)
%4 = tail call i32 @_mm_set1_ps(float 1.000000e+00)
%5 = tail call i32 @_mm_castps_si128(i32 %0)
%6 = tail call i32 @_mm_and_si128(i32 %5, i32 %2)
%7 = tail call i32 @_mm_srli_epi32(i32 %6, i32 23)
%8 = tail call i32 @_mm_set1_epi32(i32 127)
%9 = tail call i32 @_mm_sub_epi32(i32 %7, i32 %8)
%10 = tail call i32 @_mm_cvtepi32_ps(i32 %9)
%11 = tail call i32 @_mm_and_si128(i32 %5, i32 %3)
%12 = tail call i32 @_mm_castsi128_ps(i32 %11)
%13 = tail call i32 @_mm_or_ps(i32 %12, i32 %4)
%14 = tail call i32 @_mm_set1_ps(float 0x3FAE8AA5E0000000)
%15 = tail call i32 @_mm_mul_ps(i32 %14, i32 %13)
%16 = tail call i32 @_mm_set1_ps(float 0xBFDDCE72E0000000)
%17 = tail call i32 @_mm_add_ps(i32 %15, i32 %16)
%18 = tail call i32 @_mm_mul_ps(i32 %17, i32 %13)
%19 = tail call i32 @_mm_set1_ps(float 0x3FF7B2DBA0000000)
%20 = tail call i32 @_mm_add_ps(i32 %18, i32 %19)
%21 = tail call i32 @_mm_mul_ps(i32 %20, i32 %13)
%22 = tail call i32 @_mm_set1_ps(float 0xC0042A7EC0000000)
%23 = tail call i32 @_mm_add_ps(i32 %21, i32 %22)
%24 = tail call i32 @_mm_mul_ps(i32 %23, i32 %13)
%25 = tail call i32 @_mm_set1_ps(float 0x40071B2D80000000)
%26 = tail call i32 @_mm_add_ps(i32 %24, i32 %25)
%27 = tail call i32 @_mm_sub_ps(i32 %13, i32 %4)
%28 = tail call i32 @_mm_mul_ps(i32 %26, i32 %27)
%29 = tail call i32 @_mm_add_ps(i32 %28, i32 %10)
ret i32 %29
}