#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 mean(double *, int);
scalar_t__ pow(double, int);
double nse_c(double *obs, double *sim, int n) {
  double m = mean(obs, n);
  int t;
  double e1 = 0;
  double e2 = 0;
  for (t = 0; t < n; t++) {
    e1 += pow(obs[t] - sim[t], 2);
    e2 += pow(obs[t] - m, 2);
  }
  if (e1 == 0) {
    return 1;
  } else {
    return 1 - e1 / e2;
  }
}


x86 assembly (clang, -O0):
<nse_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <mean@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d3 <nse_c+0xb3>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <nse_c+0x3b>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11fd <nse_c+0xdd>
jp     11fd <nse_c+0xdd>
movsd  0xe0d(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1218 <nse_c+0xf8>
movsd  -0x38(%rbp),%xmm1
divsd  -0x40(%rbp),%xmm1
movsd  0xdf1(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nse_c>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%esi
call   1040 <mean@plt>
movapd %xmm0,%xmm1
movsd  0xeb9(%rip),%xmm0
test   %ebp,%ebp
jle    12ce <nse_c+0x1ae>
mov    %ebp,%r15d
cmp    $0x1,%ebp
movsd  %xmm1,0x18(%rsp)
jne    1172 <nse_c+0x52>
xorpd  %xmm2,%xmm2
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    1244 <nse_c+0x124>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm2,%xmm2
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
nopl   0x0(%rax)
movsd  %xmm2,0x10(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  (%r14,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  0x18(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
subsd  0x8(%r14,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
subsd  0x18(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
addsd  0x10(%rsp),%xmm2
add    $0x2,%rbp
cmp    %rbp,%r12
jne    1190 <nse_c+0x70>
test   $0x1,%r15b
je     12a4 <nse_c+0x184>
movsd  (%rbx,%rbp,8),%xmm0
subsd  (%r14,%rbp,8),%xmm0
mov    $0x2,%edi
movsd  %xmm2,0x10(%rsp)
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  0x18(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  0x10(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movsd  0xd46(%rip),%xmm0
jne    12be <nse_c+0x19e>
jnp    12ce <nse_c+0x1ae>
divsd  %xmm2,%xmm1
movsd  0xd36(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @nse_c(double* %0, double* %1, i32 %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
%12 = load double*, double** %5
%13 = load i32, i32* %7
%14 = call double @mean(double* %12, i32 %13)
store double %14, double* %8
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store i32 0, i32* %9
br label %15
15: ; preds = %46, %3
%16 = load i32, i32* %9
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %49
19: ; preds = %15
%20 = load double*, double** %5
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %6
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fsub double %24, %29
%31 = call i64 @pow(double %30, i32 2)
%32 = sitofp i64 %31 to double
%33 = load double, double* %10
%34 = fadd double %33, %32
store double %34, double* %10
%35 = load double*, double** %5
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = load double, double* %8
%41 = fsub double %39, %40
%42 = call i64 @pow(double %41, i32 2)
%43 = sitofp i64 %42 to double
%44 = load double, double* %11
%45 = fadd double %44, %43
store double %45, double* %11
br label %46
46: ; preds = %19
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %15
49: ; preds = %15
%50 = load double, double* %10
%51 = fcmp oeq double %50, 0.000000e+00
br i1 %51, label %52, label %53
52: ; preds = %49
store double 1.000000e+00, double* %4
br label %58
53: ; preds = %49
%54 = load double, double* %10
%55 = load double, double* %11
%56 = fdiv double %54, %55
%57 = fsub double 1.000000e+00, %56
store double %57, double* %4
br label %58
58: ; preds = %53, %52
%59 = load double, double* %4
ret double %59
}

LLVM IR (-O2):
define double @nse_c(double* %0, double* nocapture %1, i32 %2) {
%4 = tail call double @mean(double* %0, i32 %2)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %75
6: ; preds = %3
%7 = zext i32 %2 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %2, 1
br i1 %9, label %47, label %10
10: ; preds = %6
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %44, %12 ]
%14 = phi double [ 0.000000e+00, %10 ], [ %43, %12 ]
%15 = phi double [ 0.000000e+00, %10 ], [ %38, %12 ]
%16 = phi i64 [ 0, %10 ], [ %45, %12 ]
%17 = getelementptr inbounds double, double* %0, i64 %13
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %1, i64 %13
%20 = load double, double* %19
%21 = fsub double %18, %20
%22 = tail call i64 @pow(double %21, i32 2)
%23 = sitofp i64 %22 to double
%24 = fadd double %15, %23
%25 = load double, double* %17
%26 = fsub double %25, %4
%27 = tail call i64 @pow(double %26, i32 2)
%28 = sitofp i64 %27 to double
%29 = fadd double %14, %28
%30 = or i64 %13, 1
%31 = getelementptr inbounds double, double* %0, i64 %30
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %1, i64 %30
%34 = load double, double* %33
%35 = fsub double %32, %34
%36 = tail call i64 @pow(double %35, i32 2)
%37 = sitofp i64 %36 to double
%38 = fadd double %24, %37
%39 = load double, double* %31
%40 = fsub double %39, %4
%41 = tail call i64 @pow(double %40, i32 2)
%42 = sitofp i64 %41 to double
%43 = fadd double %29, %42
%44 = add nuw nsw i64 %13, 2
%45 = add i64 %16, 2
%46 = icmp eq i64 %45, %11
br i1 %46, label %47, label %12
47: ; preds = %12, %6
%48 = phi double [ undef, %6 ], [ %38, %12 ]
%49 = phi double [ undef, %6 ], [ %43, %12 ]
%50 = phi i64 [ 0, %6 ], [ %44, %12 ]
%51 = phi double [ 0.000000e+00, %6 ], [ %43, %12 ]
%52 = phi double [ 0.000000e+00, %6 ], [ %38, %12 ]
%53 = icmp eq i64 %8, 0
br i1 %53, label %68, label %54
54: ; preds = %47
%55 = getelementptr inbounds double, double* %0, i64 %50
%56 = load double, double* %55
%57 = getelementptr inbounds double, double* %1, i64 %50
%58 = load double, double* %57
%59 = fsub double %56, %58
%60 = tail call i64 @pow(double %59, i32 2)
%61 = sitofp i64 %60 to double
%62 = fadd double %52, %61
%63 = load double, double* %55
%64 = fsub double %63, %4
%65 = tail call i64 @pow(double %64, i32 2)
%66 = sitofp i64 %65 to double
%67 = fadd double %51, %66
br label %68
68: ; preds = %47, %54
%69 = phi double [ %48, %47 ], [ %62, %54 ]
%70 = phi double [ %49, %47 ], [ %67, %54 ]
%71 = fcmp oeq double %69, 0.000000e+00
br i1 %71, label %75, label %72
72: ; preds = %68
%73 = fdiv double %69, %70
%74 = fsub double 1.000000e+00, %73
br label %75
75: ; preds = %3, %68, %72
%76 = phi double [ %74, %72 ], [ 1.000000e+00, %68 ], [ 1.000000e+00, %3 ]
ret double %76
}