#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*/ assert(int);
float log2f(float);
float plogp(float p) {
  assert(0.0 <= p);
  assert(p <= 1.0);
  if (p == 0.0)
    return 0.0;
  return p * log2f(p);
}


x86 assembly (clang, -O0):
<plogp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xea5(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1195 <plogp+0x75>
jp     1195 <plogp+0x75>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11ba <plogp+0x9a>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <log2f@plt>
movaps %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plogp>:
push   %rax
movss  %xmm0,0x4(%rsp)
xorps  %xmm1,%xmm1
xor    %edi,%edi
ucomiss %xmm1,%xmm0
setae  %dil
call   1030 <assert@plt>
movss  0xec0(%rip),%xmm0
xor    %edi,%edi
ucomiss 0x4(%rsp),%xmm0
setae  %dil
call   1030 <assert@plt>
xorps  %xmm0,%xmm0
movss  0x4(%rsp),%xmm2
ucomiss %xmm0,%xmm2
jne    1162 <plogp+0x42>
jp     1162 <plogp+0x42>
pop    %rax
ret
movaps %xmm2,%xmm0
call   1040 <log2f@plt>
mulss  0x4(%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @plogp(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = fpext float %4 to double
%6 = fcmp ole double 0.000000e+00, %5
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load float, float* %3
%10 = fpext float %9 to double
%11 = fcmp ole double %10, 1.000000e+00
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load float, float* %3
%15 = fpext float %14 to double
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %1
store float 0.000000e+00, float* %2
br label %23
18: ; preds = %1
%19 = load float, float* %3
%20 = load float, float* %3
%21 = call float @log2f(float %20)
%22 = fmul float %19, %21
store float %22, float* %2
br label %23
23: ; preds = %18, %17
%24 = load float, float* %2
ret float %24
}

LLVM IR (-O2):
define float @plogp(float %0) {
%2 = fcmp oge float %0, 0.000000e+00
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = fcmp ole float %0, 1.000000e+00
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = fcmp oeq float %0, 0.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = tail call float @log2f(float %0)
%11 = fmul float %10, %0
br label %12
12: ; preds = %1, %9
%13 = phi float [ %11, %9 ], [ 0.000000e+00, %1 ]
ret float %13
}