#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 exp(double);
int int_distance2(int *, int *);
void intrapot_torsion_well_test(double(*boltz_ptr), double(*energy_ptr),
                                int(*interaction_hist_ptr),
                                double(*extra_histogram),
                                double(*highest_factor_ptr), double(*well_ptr),
                                double(*tor_ptr), double(nT_ptr),
                                const unsigned int ntorangles, int(**poly_ptr),
                                const unsigned int numberofbeads) {
  int interaction_counter = 0;
  int dist2;
  int bin;
  int extra_counter = 0;
  for (int dim1 = 0; dim1 < (numberofbeads - 4); dim1++) {
    for (int dim2 = dim1 + 4; dim2 < (numberofbeads); dim2++) {
      dist2 = int_distance2(poly_ptr[dim1], poly_ptr[dim2]);
      if (dist2 < 23) {
        interaction_counter += 1;
      }
    }
  }
  interaction_hist_ptr[interaction_counter]++;
  double energy;
  for (int dim1 = 0; dim1 < 10; dim1++) {
    for (int dim2 = 0; dim2 < 10; dim2++) {
      energy = (((double)ntorangles - nT_ptr) * tor_ptr[dim2]) -
               (double)interaction_counter * well_ptr[dim1];
      bin = dim1 * 10 + dim2;
      energy_ptr[bin] = energy;
      boltz_ptr[bin] = exp(-energy);
      if (boltz_ptr[bin] > highest_factor_ptr[bin]) {
        highest_factor_ptr[bin] = boltz_ptr[bin];
      }
    }
  }
}


x86 assembly (clang, -O0):
<intrapot_torsion_well_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x28(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jae    11e7 <intrapot_torsion_well_test+0xc7>
mov    -0x4c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    0x28(%rbp),%eax
jae    11d4 <intrapot_torsion_well_test+0xb4>
mov    0x20(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x20(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <int_distance2@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x17,-0x40(%rbp)
jge    11c1 <intrapot_torsion_well_test+0xa1>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11c6 <intrapot_torsion_well_test+0xa6>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1182 <intrapot_torsion_well_test+0x62>
jmp    11d9 <intrapot_torsion_well_test+0xb9>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1168 <intrapot_torsion_well_test+0x48>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
movl   $0x0,-0x5c(%rbp)
cmpl   $0xa,-0x5c(%rbp)
jge    1314 <intrapot_torsion_well_test+0x1f4>
movl   $0x0,-0x60(%rbp)
cmpl   $0xa,-0x60(%rbp)
jge    1301 <intrapot_torsion_well_test+0x1e1>
mov    0x18(%rbp),%eax
cvtsi2sd %rax,%xmm0
subsd  -0x38(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
cvtsi2sdl -0x3c(%rbp),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
imul   $0xa,-0x5c(%rbp),%eax
add    -0x60(%rbp),%eax
mov    %eax,-0x44(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <exp@plt>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    12ee <intrapot_torsion_well_test+0x1ce>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12f3 <intrapot_torsion_well_test+0x1d3>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1210 <intrapot_torsion_well_test+0xf0>
jmp    1306 <intrapot_torsion_well_test+0x1e6>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11ff <intrapot_torsion_well_test+0xdf>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intrapot_torsion_well_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm0,0x38(%rsp)
mov    %r9,0x40(%rsp)
mov    %r8,0x18(%rsp)
mov    %rdx,0x30(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,0x20(%rsp)
mov    0x98(%rsp),%ecx
mov    %ecx,%eax
add    $0xfffffffc,%eax
je     11d4 <intrapot_torsion_well_test+0xb4>
mov    0x90(%rsp),%rbp
mov    %ecx,%r12d
mov    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
mov    %r12,0x10(%rsp)
mov    %rbp,%r14
xor    %r13d,%r13d
jmp    1193 <intrapot_torsion_well_test+0x73>
nopl   (%rax)
add    $0x1,%r15
add    $0x8,%r14
add    $0xffffffffffffffff,%r12
cmp    0x8(%rsp),%r15
je     11d7 <intrapot_torsion_well_test+0xb7>
lea    0x4(%r15),%rax
cmp    0x10(%rsp),%rax
jae    1180 <intrapot_torsion_well_test+0x60>
mov    $0x4,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%rbp,%r15,8),%rdi
mov    (%r14,%rbx,8),%rsi
call   1030 <int_distance2@plt>
xor    %ecx,%ecx
cmp    $0x17,%eax
setl   %cl
add    %ecx,%r13d
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    11b0 <intrapot_torsion_well_test+0x90>
jmp    1180 <intrapot_torsion_well_test+0x60>
xor    %r13d,%r13d
movslq %r13d,%rax
mov    0x30(%rsp),%rcx
addl   $0x1,(%rcx,%rax,4)
mov    0x88(%rsp),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
subsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %r15d,%r15d
mov    0x40(%rsp),%r13
mov    0x28(%rsp),%r12
mov    0x20(%rsp),%r14
mov    0x18(%rsp),%rbp
jmp    1246 <intrapot_torsion_well_test+0x126>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15
add    $0x50,%rbp
add    $0x50,%r14
add    $0x50,%r12
cmp    $0xa,%r15
je     12a7 <intrapot_torsion_well_test+0x187>
xor    %ebx,%ebx
jmp    125a <intrapot_torsion_well_test+0x13a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0xa,%rbx
je     1230 <intrapot_torsion_well_test+0x110>
movsd  0x0(%r13,%r15,8),%xmm1
mulsd  0x8(%rsp),%xmm1
mov    0x80(%rsp),%rax
movsd  (%rax,%rbx,8),%xmm0
mulsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
xorpd  0xd74(%rip),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,(%r14,%rbx,8)
ucomisd 0x0(%rbp,%rbx,8),%xmm0
jbe    1250 <intrapot_torsion_well_test+0x130>
movsd  %xmm0,0x0(%rbp,%rbx,8)
jmp    1250 <intrapot_torsion_well_test+0x130>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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