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


x86 assembly (clang, -O0):
<E1_eq3_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1212 <E1_eq3_r+0x102>
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <mpos@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ff <E1_eq3_r+0xef>
mov    -0x2c(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1030 <mpos@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm1
movsd  0xe32(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1192 <E1_eq3_r+0x82>
jmp    1204 <E1_eq3_r+0xf4>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1136 <E1_eq3_r+0x26>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<E1_eq3_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    11da <E1_eq3_r+0xca>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%r13d
xor    %eax,%eax
xorpd  %xmm0,%xmm0
jmp    114d <E1_eq3_r+0x3d>
nopw   0x0(%rax,%rax,1)
mov    0x14(%rsp),%eax
cmp    %r13d,%eax
je     11de <E1_eq3_r+0xce>
mov    %eax,%ebx
movsd  %xmm0,0x8(%rsp)
mov    %eax,%edi
mov    %eax,%esi
call   1030 <mpos@plt>
cltq
movsd  (%r12,%rax,8),%xmm0
addsd  (%r14,%rax,8),%xmm0
mulsd  (%r15,%rax,8),%xmm0
addsd  0x8(%rsp),%xmm0
lea    0x1(%rbx),%ebp
cmp    %r13d,%ebp
mov    %ebp,0x14(%rsp)
jge    1140 <E1_eq3_r+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <mpos@plt>
cltq
movsd  (%r12,%rax,8),%xmm0
addsd  (%r14,%rax,8),%xmm0
addsd  %xmm0,%xmm0
mulsd  (%r15,%rax,8),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    1190 <E1_eq3_r+0x80>
jmp    1140 <E1_eq3_r+0x30>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @E1_eq3_r(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store double 0.000000e+00, double* %9
store i32 0, i32* %10
br label %14
14: ; preds = %73, %4
%15 = load i32, i32* %10
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %76
18: ; preds = %14
%19 = load i32, i32* %10
%20 = load i32, i32* %10
%21 = call i32 @mpos(i32 %19, i32 %20)
store i32 %21, i32* %11
%22 = load double*, double** %6
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double*, double** %8
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = fadd double %26, %31
%33 = load double*, double** %7
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load double, double* %9
%39 = call double @llvm.fmuladd.f64(double %32, double %37, double %38)
store double %39, double* %9
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %12
br label %42
42: ; preds = %69, %18
%43 = load i32, i32* %12
%44 = load i32, i32* %5
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %72
46: ; preds = %42
%47 = load i32, i32* %10
%48 = load i32, i32* %12
%49 = call i32 @mpos(i32 %47, i32 %48)
store i32 %49, i32* %13
%50 = load double*, double** %6
%51 = load i32, i32* %13
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = load double, double* %53
%55 = load double*, double** %8
%56 = load i32, i32* %13
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
%60 = fadd double %54, %59
%61 = fmul double 2.000000e+00, %60
%62 = load double*, double** %7
%63 = load i32, i32* %13
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = load double, double* %9
%68 = call double @llvm.fmuladd.f64(double %61, double %66, double %67)
store double %68, double* %9
br label %69
69: ; preds = %46
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
store i32 %71, i32* %12
br label %42
72: ; preds = %42
br label %73
73: ; preds = %72
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %14
76: ; preds = %14
%77 = load double, double* %9
ret double %77
}

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