#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 wrap(double, double, double);
extern void _get_umbrella_bias(double *traj, double *umbrella_centers,
                               double *force_constants, double *width,
                               double *half_width, int nsamples, int nthermo,
                               int ndim, double *bias) {
  int i, j, s, k;
  int dd = ndim * ndim, kdd, kdim, sdim;
  double sum, isum, fc;
  for (s = 0; s < nsamples; ++s) {
    sdim = s * ndim;
    for (k = 0; k < nthermo; ++k) {
      sum = 0.0;
      kdd = k * dd;
      kdim = k * ndim;
      for (i = 0; i < ndim; ++i) {
        isum = 0.0;
        for (j = 0; j < ndim; ++j) {
          fc = force_constants[kdd + i * ndim + j];
          if (0.0 == fc)
            continue;
          isum += fc *
                  wrap(traj[sdim + i] - umbrella_centers[kdim + i], width[i],
                       half_width[i]) *
                  wrap(traj[sdim + j] - umbrella_centers[kdim + j], width[j],
                       half_width[j]);
        }
        sum += isum;
      }
      bias[s * nthermo + k] = 0.5 * sum;
    }
  }
}


x86 assembly (clang, -O0):
<_get_umbrella_bias>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    0x18(%rbp),%eax
imul   0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1324 <_get_umbrella_bias+0x214>
mov    -0x38(%rbp),%eax
imul   0x18(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1311 <_get_umbrella_bias+0x201>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
imul   0x18(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    12e0 <_get_umbrella_bias+0x1d0>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    12c3 <_get_umbrella_bias+0x1b3>
mov    -0x18(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    -0x30(%rbp),%edx
imul   0x18(%rbp),%edx
add    %edx,%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x68(%rbp),%xmm0
jne    11fa <_get_umbrella_bias+0xea>
jp     11fa <_get_umbrella_bias+0xea>
jmp    12b5 <_get_umbrella_bias+0x1a5>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
call   1030 <wrap@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
call   1030 <wrap@plt>
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b5 <_get_umbrella_bias+0xa5>
movsd  -0x60(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    119a <_get_umbrella_bias+0x8a>
movsd  0xd18(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    0x20(%rbp),%rax
mov    -0x38(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    116b <_get_umbrella_bias+0x5b>
jmp    1316 <_get_umbrella_bias+0x206>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    114e <_get_umbrella_bias+0x3e>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_umbrella_bias>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %r8,0xa8(%rsp)
mov    %rcx,0xa0(%rsp)
mov    %rsi,0x48(%rsp)
mov    %rdi,0x40(%rsp)
test   %r9d,%r9d
jle    13e1 <_get_umbrella_bias+0x2d1>
movslq 0x108(%rsp),%rax
movslq 0x100(%rsp),%rcx
mov    %r9d,%esi
mov    %rsi,0x58(%rsp)
mov    %rcx,0x50(%rsp)
mov    %ecx,%ecx
mov    %rcx,0x68(%rsp)
mov    %eax,%r12d
lea    0x0(,%rax,8),%rcx
mov    %rcx,0x38(%rsp)
mov    %rax,0x30(%rsp)
imul   %eax,%eax
mov    %rax,0x60(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xorpd  %xmm0,%xmm0
mov    0x40(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    %rdx,0x98(%rsp)
mov    0xa0(%rsp),%rbx
mov    0xa8(%rsp),%r15
jmp    11eb <_get_umbrella_bias+0xdb>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%rcx
add    $0x1,%rcx
mov    0x18(%rsp),%rax
add    0x38(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    %rcx,%rax
mov    %rcx,0x10(%rsp)
cmp    0x58(%rsp),%rcx
je     13e1 <_get_umbrella_bias+0x2d1>
cmpl   $0x0,0x100(%rsp)
jle    11c0 <_get_umbrella_bias+0xb0>
mov    0x10(%rsp),%rax
mov    %rax,%rcx
imul   0x30(%rsp),%rcx
mov    %rcx,0x88(%rsp)
imul   0x50(%rsp),%rax
mov    %rax,0x70(%rsp)
xor    %r13d,%r13d
mov    0x48(%rsp),%rax
mov    %rax,0x20(%rsp)
xor    %edi,%edi
jmp    128d <_get_umbrella_bias+0x17d>
nopw   0x0(%rax,%rax,1)
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm1
mulsd  0xdb8(%rip),%xmm1
mov    0x70(%rsp),%rax
mov    0x78(%rsp),%rdi
add    %rdi,%rax
mov    0x110(%rsp),%rcx
movsd  %xmm1,(%rcx,%rax,8)
add    $0x1,%rdi
mov    0x20(%rsp),%rax
add    0x38(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x80(%rsp),%r13
add    0x60(%rsp),%r13
cmp    0x68(%rsp),%rdi
je     11c0 <_get_umbrella_bias+0xb0>
cmpl   $0x0,0x108(%rsp)
mov    %r13,0x80(%rsp)
mov    %rdi,0x78(%rsp)
jle    1230 <_get_umbrella_bias+0x120>
imul   0x30(%rsp),%rdi
mov    %rdi,0x90(%rsp)
xorps  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r13,%rdi
xor    %r13d,%r13d
jmp    12f0 <_get_umbrella_bias+0x1e0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x8(%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%r13
add    %r12,%rdi
cmp    %r12,%r13
je     123a <_get_umbrella_bias+0x12a>
mov    0x88(%rsp),%rax
add    %r13,%rax
mov    %rax,0xb8(%rsp)
mov    0x90(%rsp),%rax
add    %r13,%rax
mov    %rax,0xb0(%rsp)
xor    %r14d,%r14d
xorpd  %xmm2,%xmm2
jmp    1329 <_get_umbrella_bias+0x219>
nop
add    $0x1,%r14
cmp    %r14,%r12
je     12d0 <_get_umbrella_bias+0x1c0>
lea    (%rdi,%r14,1),%eax
cltq
movsd  (%rdx,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jne    133c <_get_umbrella_bias+0x22c>
jnp    1320 <_get_umbrella_bias+0x210>
mov    0x40(%rsp),%rax
mov    0xb8(%rsp),%rbp
movsd  (%rax,%rbp,8),%xmm0
mov    0x48(%rsp),%rax
mov    0xb0(%rsp),%rbp
subsd  (%rax,%rbp,8),%xmm0
movsd  %xmm1,0x28(%rsp)
movsd  (%rbx,%r13,8),%xmm1
movsd  %xmm2,0xc0(%rsp)
movsd  (%r15,%r13,8),%xmm2
mov    %rdi,%rbp
call   1030 <wrap@plt>
movsd  0x28(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rsp)
mov    0x18(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
mov    0x20(%rsp),%rax
subsd  (%rax,%r14,8),%xmm0
movsd  (%rbx,%r14,8),%xmm1
movsd  (%r15,%r14,8),%xmm2
call   1030 <wrap@plt>
movsd  0xc0(%rsp),%xmm2
mov    %rbp,%rdi
mov    0x98(%rsp),%rdx
mulsd  0x28(%rsp),%xmm0
addsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
jmp    1320 <_get_umbrella_bias+0x210>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_get_umbrella_bias(double* %0, double* %1, double* %2, double* %3, double* %4, i32 %5, i32 %6, i32 %7, double* %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca double
%28 = alloca double
%29 = alloca double
store double* %0, double** %10
store double* %1, double** %11
store double* %2, double** %12
store double* %3, double** %13
store double* %4, double** %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store double* %8, double** %18
%30 = load i32, i32* %17
%31 = load i32, i32* %17
%32 = mul nsw i32 %30, %31
store i32 %32, i32* %23
store i32 0, i32* %21
br label %33
33: ; preds = %158, %9
%34 = load i32, i32* %21
%35 = load i32, i32* %15
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %161
37: ; preds = %33
%38 = load i32, i32* %21
%39 = load i32, i32* %17
%40 = mul nsw i32 %38, %39
store i32 %40, i32* %26
store i32 0, i32* %22
br label %41
41: ; preds = %154, %37
%42 = load i32, i32* %22
%43 = load i32, i32* %16
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %157
45: ; preds = %41
store double 0.000000e+00, double* %27
%46 = load i32, i32* %22
%47 = load i32, i32* %23
%48 = mul nsw i32 %46, %47
store i32 %48, i32* %24
%49 = load i32, i32* %22
%50 = load i32, i32* %17
%51 = mul nsw i32 %49, %50
store i32 %51, i32* %25
store i32 0, i32* %19
br label %52
52: ; preds = %140, %45
%53 = load i32, i32* %19
%54 = load i32, i32* %17
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %143
56: ; preds = %52
store double 0.000000e+00, double* %28
store i32 0, i32* %20
br label %57
57: ; preds = %133, %56
%58 = load i32, i32* %20
%59 = load i32, i32* %17
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %136
61: ; preds = %57
%62 = load double*, double** %12
%63 = load i32, i32* %24
%64 = load i32, i32* %19
%65 = load i32, i32* %17
%66 = mul nsw i32 %64, %65
%67 = add nsw i32 %63, %66
%68 = load i32, i32* %20
%69 = add nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %62, i64 %70
%72 = load double, double* %71
store double %72, double* %29
%73 = load double, double* %29
%74 = fcmp oeq double 0.000000e+00, %73
br i1 %74, label %75, label %76
75: ; preds = %61
br label %133
76: ; preds = %61
%77 = load double, double* %29
%78 = load double*, double** %10
%79 = load i32, i32* %26
%80 = load i32, i32* %19
%81 = add nsw i32 %79, %80
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %78, i64 %82
%84 = load double, double* %83
%85 = load double*, double** %11
%86 = load i32, i32* %25
%87 = load i32, i32* %19
%88 = add nsw i32 %86, %87
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %85, i64 %89
%91 = load double, double* %90
%92 = fsub double %84, %91
%93 = load double*, double** %13
%94 = load i32, i32* %19
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = load double*, double** %14
%99 = load i32, i32* %19
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
%102 = load double, double* %101
%103 = call double @wrap(double %92, double %97, double %102)
%104 = fmul double %77, %103
%105 = load double*, double** %10
%106 = load i32, i32* %26
%107 = load i32, i32* %20
%108 = add nsw i32 %106, %107
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double, double* %105, i64 %109
%111 = load double, double* %110
%112 = load double*, double** %11
%113 = load i32, i32* %25
%114 = load i32, i32* %20
%115 = add nsw i32 %113, %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %112, i64 %116
%118 = load double, double* %117
%119 = fsub double %111, %118
%120 = load double*, double** %13
%121 = load i32, i32* %20
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %120, i64 %122
%124 = load double, double* %123
%125 = load double*, double** %14
%126 = load i32, i32* %20
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %125, i64 %127
%129 = load double, double* %128
%130 = call double @wrap(double %119, double %124, double %129)
%131 = load double, double* %28
%132 = call double @llvm.fmuladd.f64(double %104, double %130, double %131)
store double %132, double* %28
br label %133
133: ; preds = %76, %75
%134 = load i32, i32* %20
%135 = add nsw i32 %134, 1
store i32 %135, i32* %20
br label %57
136: ; preds = %57
%137 = load double, double* %28
%138 = load double, double* %27
%139 = fadd double %138, %137
store double %139, double* %27
br label %140
140: ; preds = %136
%141 = load i32, i32* %19
%142 = add nsw i32 %141, 1
store i32 %142, i32* %19
br label %52
143: ; preds = %52
%144 = load double, double* %27
%145 = fmul double 5.000000e-01, %144
%146 = load double*, double** %18
%147 = load i32, i32* %21
%148 = load i32, i32* %16
%149 = mul nsw i32 %147, %148
%150 = load i32, i32* %22
%151 = add nsw i32 %149, %150
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %146, i64 %152
store double %145, double* %153
br label %154
154: ; preds = %143
%155 = load i32, i32* %22
%156 = add nsw i32 %155, 1
store i32 %156, i32* %22
br label %41
157: ; preds = %41
br label %158
158: ; preds = %157
%159 = load i32, i32* %21
%160 = add nsw i32 %159, 1
store i32 %160, i32* %21
br label %33
161: ; preds = %33
ret void
}

LLVM IR (-O2):
define void @_get_umbrella_bias(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, i32 %5, i32 %6, i32 %7, double* nocapture writeonly %8) {
%10 = icmp sgt i32 %5, 0
br i1 %10, label %11, label %89
11: ; preds = %9
%12 = icmp sgt i32 %6, 0
%13 = icmp sgt i32 %7, 0
%14 = sext i32 %7 to i64
%15 = sext i32 %6 to i64
%16 = zext i32 %5 to i64
%17 = zext i32 %6 to i64
%18 = zext i32 %7 to i64
br label %19
19: ; preds = %11, %86
%20 = phi i64 [ 0, %11 ], [ %87, %86 ]
%21 = mul nsw i64 %20, %14
br i1 %12, label %22, label %86
22: ; preds = %19
%23 = mul nsw i64 %20, %15
br label %24
24: ; preds = %22, %79
%25 = phi i64 [ 0, %22 ], [ %84, %79 ]
%26 = trunc i64 %25 to i32
%27 = mul i32 %26, %7
%28 = mul nsw i64 %25, %14
br i1 %13, label %29, label %79
29: ; preds = %24, %75
%30 = phi i64 [ %77, %75 ], [ 0, %24 ]
%31 = phi double [ %76, %75 ], [ 0.000000e+00, %24 ]
%32 = trunc i64 %30 to i32
%33 = add i32 %27, %32
%34 = mul i32 %33, %7
%35 = add nsw i64 %30, %21
%36 = getelementptr inbounds double, double* %0, i64 %35
%37 = add nsw i64 %30, %28
%38 = getelementptr inbounds double, double* %1, i64 %37
%39 = getelementptr inbounds double, double* %3, i64 %30
%40 = getelementptr inbounds double, double* %4, i64 %30
br label %41
41: ; preds = %29, %71
%42 = phi i64 [ 0, %29 ], [ %73, %71 ]
%43 = phi double [ 0.000000e+00, %29 ], [ %72, %71 ]
%44 = trunc i64 %42 to i32
%45 = add i32 %34, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %2, i64 %46
%48 = load double, double* %47
%49 = fcmp oeq double %48, 0.000000e+00
br i1 %49, label %71, label %50
50: ; preds = %41
%51 = load double, double* %36
%52 = load double, double* %38
%53 = fsub double %51, %52
%54 = load double, double* %39
%55 = load double, double* %40
%56 = tail call double @wrap(double %53, double %54, double %55)
%57 = fmul double %48, %56
%58 = add nsw i64 %42, %21
%59 = getelementptr inbounds double, double* %0, i64 %58
%60 = load double, double* %59
%61 = add nsw i64 %42, %28
%62 = getelementptr inbounds double, double* %1, i64 %61
%63 = load double, double* %62
%64 = fsub double %60, %63
%65 = getelementptr inbounds double, double* %3, i64 %42
%66 = load double, double* %65
%67 = getelementptr inbounds double, double* %4, i64 %42
%68 = load double, double* %67
%69 = tail call double @wrap(double %64, double %66, double %68)
%70 = tail call double @llvm.fmuladd.f64(double %57, double %69, double %43)
br label %71
71: ; preds = %41, %50
%72 = phi double [ %43, %41 ], [ %70, %50 ]
%73 = add nuw nsw i64 %42, 1
%74 = icmp eq i64 %73, %18
br i1 %74, label %75, label %41
75: ; preds = %71
%76 = fadd double %31, %72
%77 = add nuw nsw i64 %30, 1
%78 = icmp eq i64 %77, %18
br i1 %78, label %79, label %29
79: ; preds = %75, %24
%80 = phi double [ 0.000000e+00, %24 ], [ %76, %75 ]
%81 = fmul double %80, 5.000000e-01
%82 = add nsw i64 %25, %23
%83 = getelementptr inbounds double, double* %8, i64 %82
store double %81, double* %83
%84 = add nuw nsw i64 %25, 1
%85 = icmp eq i64 %84, %17
br i1 %85, label %86, label %24
86: ; preds = %79, %19
%87 = add nuw nsw i64 %20, 1
%88 = icmp eq i64 %87, %16
br i1 %88, label %89, label %19
89: ; preds = %86, %9
ret void
}