#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 */
double log(double);
double _p3dPunThresholding_entropy(double *h, int a) {
  if (h[a] > 0.0)
    return -(h[a] * log((double)h[a]));
  return 0.0;
}


x86 assembly (clang, -O0):
<_p3dPunThresholding_entropy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    118a <_p3dPunThresholding_entropy+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1192 <_p3dPunThresholding_entropy+0x82>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_p3dPunThresholding_entropy>:
sub    $0x18,%rsp
movslq %esi,%rax
movsd  (%rdi,%rax,8),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    1149 <_p3dPunThresholding_entropy+0x39>
movapd %xmm1,%xmm0
movapd %xmm1,(%rsp)
call   1030 <log@plt>
movapd (%rsp),%xmm1
xorpd  0xebf(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @_p3dPunThresholding_entropy(double* %0, i32 %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
%6 = load double*, double** %4
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds double, double* %6, i64 %8
%10 = load double, double* %9
%11 = fcmp ogt double %10, 0.000000e+00
br i1 %11, label %12, label %26
12: ; preds = %2
%13 = load double*, double** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = call double @log(double %22)
%24 = fmul double %17, %23
%25 = fneg double %24
store double %25, double* %3
br label %27
26: ; preds = %2
store double 0.000000e+00, double* %3
br label %27
27: ; preds = %26, %12
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
define double @_p3dPunThresholding_entropy(double* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds double, double* %0, i64 %3
%5 = load double, double* %4
%6 = fcmp ogt double %5, 0.000000e+00
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = tail call double @log(double %5)
%9 = fneg double %5
%10 = fmul double %8, %9
br label %11
11: ; preds = %2, %7
%12 = phi double [ %10, %7 ], [ 0.000000e+00, %2 ]
ret double %12
}