#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 */
scalar_t__ entropy(double const);
double entropy_full(const double *x, const double *pr, const double eps,
                    const int nx, const int ny, const double flux) {
  register int i;
  double reg = 0;
  for (i = 0; i < nx * ny; ++i) {
    if (x[i] > 0)
      reg += entropy(x[i]);
  }
  return reg;
}


x86 assembly (clang, -O0):
<entropy_full>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    119f <entropy_full+0x8f>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    118c <entropy_full+0x7c>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <entropy@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1191 <entropy_full+0x81>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113f <entropy_full+0x2f>
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<entropy_full>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
imul   %ecx,%edx
test   %edx,%edx
jle    1178 <entropy_full+0x68>
mov    %rdi,%r14
mov    %edx,%r15d
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1149 <entropy_full+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     117c <entropy_full+0x6c>
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jbe    1140 <entropy_full+0x30>
movsd  %xmm1,0x8(%rsp)
call   1030 <entropy@plt>
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
jmp    1140 <entropy_full+0x30>
xorpd  %xmm1,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @entropy_full(double* %0, double* %1, double %2, i32 %3, i32 %4, double %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store double %2, double* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double %5, double* %12
store double 0.000000e+00, double* %14
store i32 0, i32* %13
br label %15
15: ; preds = %39, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %10
%18 = load i32, i32* %11
%19 = mul nsw i32 %17, %18
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %42
21: ; preds = %15
%22 = load double*, double** %7
%23 = load i32, i32* %13
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = fcmp ogt double %26, 0.000000e+00
br i1 %27, label %28, label %38
28: ; preds = %21
%29 = load double*, double** %7
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = call i64 @entropy(double %33)
%35 = sitofp i64 %34 to double
%36 = load double, double* %14
%37 = fadd double %36, %35
store double %37, double* %14
br label %38
38: ; preds = %28, %21
br label %39
39: ; preds = %38
%40 = load i32, i32* %13
%41 = add nsw i32 %40, 1
store i32 %41, i32* %13
br label %15
42: ; preds = %15
%43 = load double, double* %14
ret double %43
}

LLVM IR (-O2):
define double @entropy_full(double* nocapture %0, double* nocapture readnone %1, double %2, i32 %3, i32 %4, double %5) {
%7 = mul i32 %4, %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %21
%12 = phi i64 [ 0, %9 ], [ %23, %21 ]
%13 = phi double [ 0.000000e+00, %9 ], [ %22, %21 ]
%14 = getelementptr inbounds double, double* %0, i64 %12
%15 = load double, double* %14
%16 = fcmp ogt double %15, 0.000000e+00
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = tail call i64 @entropy(double %15)
%19 = sitofp i64 %18 to double
%20 = fadd double %13, %19
br label %21
21: ; preds = %11, %17
%22 = phi double [ %20, %17 ], [ %13, %11 ]
%23 = add nuw nsw i64 %12, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %11
25: ; preds = %21, %6
%26 = phi double [ 0.000000e+00, %6 ], [ %22, %21 ]
ret double %26
}