#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 mpos(int, int);
double E2_eq5_r(int Mo, double *D, double *F2) {
  double E2 = 0.0;
  for (int u = 0; u < Mo; u++) {
    int uu = mpos(u, u);
    E2 += F2[uu] * D[uu];
    for (int v = u + 1; v < Mo; v++) {
      int uv = mpos(u, v);
      E2 += 2.0 * F2[uv] * D[uv];
    }
  }
  return 2.0 * E2;
}


x86 assembly (clang, -O0):
<E2_eq5_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f0 <E2_eq5_r+0xe0>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1030 <mpos@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11dd <E2_eq5_r+0xcd>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <mpos@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  0xe55(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1181 <E2_eq5_r+0x71>
jmp    11e2 <E2_eq5_r+0xd2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <E2_eq5_r+0x22>
movsd  0xe08(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<E2_eq5_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11bd <E2_eq5_r+0xad>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
jmp    1145 <E2_eq5_r+0x35>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r12d,%r13d
je     11c1 <E2_eq5_r+0xb1>
mov    %r13d,%ebx
movsd  %xmm0,(%rsp)
mov    %r13d,%edi
mov    %r13d,%esi
call   1030 <mpos@plt>
cltq
movsd  (%r14,%rax,8),%xmm0
mulsd  (%r15,%rax,8),%xmm0
addsd  (%rsp),%xmm0
lea    0x1(%rbx),%r13d
cmp    %r12d,%r13d
jge    1140 <E2_eq5_r+0x30>
mov    %r13d,%ebp
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <mpos@plt>
cltq
movsd  (%r14,%rax,8),%xmm0
addsd  %xmm0,%xmm0
mulsd  (%r15,%rax,8),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1180 <E2_eq5_r+0x70>
jmp    1140 <E2_eq5_r+0x30>
xorpd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @E2_eq5_r(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
br label %12
12: ; preds = %59, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %62
16: ; preds = %12
%17 = load i32, i32* %8
%18 = load i32, i32* %8
%19 = call i32 @mpos(i32 %17, i32 %18)
store i32 %19, i32* %9
%20 = load double*, double** %6
%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** %5
%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 = load double, double* %7
%31 = call double @llvm.fmuladd.f64(double %24, double %29, double %30)
store double %31, double* %7
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %34
34: ; preds = %55, %16
%35 = load i32, i32* %10
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %58
38: ; preds = %34
%39 = load i32, i32* %8
%40 = load i32, i32* %10
%41 = call i32 @mpos(i32 %39, i32 %40)
store i32 %41, i32* %11
%42 = load double*, double** %6
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = fmul double 2.000000e+00, %46
%48 = load double*, double** %5
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = load double, double* %7
%54 = call double @llvm.fmuladd.f64(double %47, double %52, double %53)
store double %54, double* %7
br label %55
55: ; preds = %38
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %34
58: ; preds = %34
br label %59
59: ; preds = %58
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %12
62: ; preds = %12
%63 = load double, double* %7
%64 = fmul double 2.000000e+00, %63
ret double %64
}

LLVM IR (-O2):
define double @E2_eq5_r(i32 %0, double* nocapture %1, double* nocapture %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %11, label %8
5: ; preds = %23, %11
%6 = phi double [ %20, %11 ], [ %33, %23 ]
%7 = icmp eq i32 %21, %0
br i1 %7, label %8, label %11
8: ; preds = %5, %3
%9 = phi double [ 0.000000e+00, %3 ], [ %6, %5 ]
%10 = fmul double %9, 2.000000e+00
ret double %10
11: ; preds = %3, %5
%12 = phi double [ %6, %5 ], [ 0.000000e+00, %3 ]
%13 = phi i32 [ %21, %5 ], [ 0, %3 ]
%14 = tail call i32 @mpos(i32 %13, i32 %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %2, i64 %15
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 %15
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %17, double %19, double %12)
%21 = add nuw nsw i32 %13, 1
%22 = icmp slt i32 %21, %0
br i1 %22, label %23, label %5
23: ; preds = %11, %23
%24 = phi double [ %33, %23 ], [ %20, %11 ]
%25 = phi i32 [ %34, %23 ], [ %21, %11 ]
%26 = tail call i32 @mpos(i32 %13, i32 %25)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %2, i64 %27
%29 = load double, double* %28
%30 = fmul double %29, 2.000000e+00
%31 = getelementptr inbounds double, double* %1, i64 %27
%32 = load double, double* %31
%33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %24)
%34 = add nuw i32 %25, 1
%35 = icmp eq i32 %34, %0
br i1 %35, label %5, label %23
}