#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 heat_capacity(double *, double *, int, double, double, double *,
                     double *);
int /*<<< orphan*/ log_weights(double *, double *, double *, int, double);
double max_array(double *, int);
void heat_capacity_loop(double *El, double *gl, double *wl, double *Cvl,
                        double *Ul, double *U2l, double *Tlist, int N, int nT,
                        double ndof) {
  int i, j;
  double T = 0;
  double wl_max;
  double _U = 0.;
  double _U2 = 0.;
  for (i = 0; i < nT; ++i) {
    T = Tlist[i];
    log_weights(El, gl, wl, N, T);
    wl_max = max_array(wl, N);
    for (j = 0; j < N; ++j) {
      wl[j] -= wl_max;
    }
    Cvl[i] = heat_capacity(El, wl, N, T, ndof, &_U, &_U2);
    Ul[i] = _U;
    U2l[i] = _U2;
  }
}


x86 assembly (clang, -O0):
<heat_capacity_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x20(%rbp),%eax
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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    1263 <heat_capacity_loop+0x133>
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    0x18(%rbp),%ecx
movsd  -0x48(%rbp),%xmm0
call   1040 <log_weights@plt>
mov    -0x18(%rbp),%rdi
mov    0x18(%rbp),%esi
call   1050 <max_array@plt>
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1202 <heat_capacity_loop+0xd2>
movsd  -0x50(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11cd <heat_capacity_loop+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x18(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    -0x58(%rbp),%rcx
lea    -0x60(%rbp),%r8
call   1030 <heat_capacity@plt>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    117e <heat_capacity_loop+0x4e>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heat_capacity_loop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm0,0x58(%rsp)
mov    %r9,0x50(%rsp)
mov    %r8,0x48(%rsp)
mov    %rcx,0x40(%rsp)
mov    %rsi,0x38(%rsp)
mov    0xb0(%rsp),%eax
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
test   %eax,%eax
jle    1347 <heat_capacity_loop+0x217>
mov    %rdx,%rbx
mov    %rdi,%rbp
mov    0xa8(%rsp),%r14d
mov    %eax,%r15d
mov    %r14d,%r12d
mov    %r12d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x30(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x28(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x20(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x18(%rsp)
xor    %r13d,%r13d
jmp    122e <heat_capacity_loop+0xfe>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
movsd  0x60(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1030 <heat_capacity@plt>
mov    0x40(%rsp),%rax
movsd  %xmm0,(%rax,%r13,8)
movsd  0x10(%rsp),%xmm0
mov    0x48(%rsp),%rax
movsd  %xmm0,(%rax,%r13,8)
movsd  0x8(%rsp),%xmm0
mov    0x50(%rsp),%rax
movsd  %xmm0,(%rax,%r13,8)
add    $0x1,%r13
cmp    %r15,%r13
je     1347 <heat_capacity_loop+0x217>
mov    0xa0(%rsp),%rax
movsd  (%rax,%r13,8),%xmm0
mov    %rbp,%rdi
mov    0x38(%rsp),%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
movsd  %xmm0,0x60(%rsp)
call   1040 <log_weights@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <max_array@plt>
test   %r14d,%r14d
jle    11d0 <heat_capacity_loop+0xa0>
cmp    $0x4,%r14d
jae    1280 <heat_capacity_loop+0x150>
xor    %eax,%eax
jmp    1320 <heat_capacity_loop+0x1f0>
cs nopw 0x0(%rax,%rax,1)
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x28(%rsp)
je     133c <heat_capacity_loop+0x20c>
mov    0x18(%rsp),%rcx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rax,8),%xmm2
movupd 0x10(%rbx,%rax,8),%xmm3
movupd 0x20(%rbx,%rax,8),%xmm4
movupd 0x30(%rbx,%rax,8),%xmm5
subpd  %xmm1,%xmm2
subpd  %xmm1,%xmm3
movupd %xmm2,(%rbx,%rax,8)
movupd %xmm3,0x10(%rbx,%rax,8)
subpd  %xmm1,%xmm4
subpd  %xmm1,%xmm5
movupd %xmm4,0x20(%rbx,%rax,8)
movupd %xmm5,0x30(%rbx,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rcx
jne    12a0 <heat_capacity_loop+0x170>
testb  $0x1,0x20(%rsp)
je     130d <heat_capacity_loop+0x1dd>
movupd (%rbx,%rax,8),%xmm2
movupd 0x10(%rbx,%rax,8),%xmm3
subpd  %xmm1,%xmm2
subpd  %xmm1,%xmm3
movupd %xmm2,(%rbx,%rax,8)
movupd %xmm3,0x10(%rbx,%rax,8)
mov    0x30(%rsp),%rcx
mov    %rcx,%rax
cmp    %r12,%rcx
je     11d0 <heat_capacity_loop+0xa0>
xchg   %ax,%ax
movsd  (%rbx,%rax,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rax,8)
add    $0x1,%rax
cmp    %rax,%r12
jne    1320 <heat_capacity_loop+0x1f0>
jmp    11d0 <heat_capacity_loop+0xa0>
xor    %eax,%eax
testb  $0x1,0x20(%rsp)
jne    12ef <heat_capacity_loop+0x1bf>
jmp    130d <heat_capacity_loop+0x1dd>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @heat_capacity_loop(double* %0, double* %1, double* %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5, double* nocapture %6, i32 %7, i32 %8, double %9) {
%11 = alloca double
%12 = alloca double
%13 = bitcast double* %11 to i8*
store double 0.000000e+00, double* %11
%14 = bitcast double* %12 to i8*
store double 0.000000e+00, double* %12
%15 = icmp sgt i32 %8, 0
br i1 %15, label %16, label %102
16: ; preds = %10
%17 = icmp sgt i32 %7, 0
%18 = zext i32 %8 to i64
%19 = zext i32 %7 to i64
%20 = and i64 %19, 4294967292
%21 = add nsw i64 %20, -4
%22 = lshr exact i64 %21, 2
%23 = add nuw nsw i64 %22, 1
%24 = icmp ult i32 %7, 4
%25 = and i64 %19, 4294967292
%26 = and i64 %23, 1
%27 = icmp eq i64 %21, 0
%28 = and i64 %23, 9223372036854775806
%29 = icmp eq i64 %26, 0
%30 = icmp eq i64 %25, %19
br label %31
31: ; preds = %16, %93
%32 = phi i64 [ 0, %16 ], [ %100, %93 ]
%33 = getelementptr inbounds double, double* %6, i64 %32
%34 = load double, double* %33
%35 = call i32 @log_weights(double* %0, double* %1, double* %2, i32 %7, double %34)
%36 = call double @max_array(double* %2, i32 %7)
br i1 %17, label %37, label %93
37: ; preds = %31
br i1 %24, label %84, label %38
38: ; preds = %37
%39 = insertelement <2 x double> poison, double %36, i64 0
%40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> zeroinitializer
%41 = insertelement <2 x double> poison, double %36, i64 0
%42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %27, label %70, label %43
43: ; preds = %38, %43
%44 = phi i64 [ %67, %43 ], [ 0, %38 ]
%45 = phi i64 [ %68, %43 ], [ 0, %38 ]
%46 = getelementptr inbounds double, double* %2, i64 %44
%47 = bitcast double* %46 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = getelementptr inbounds double, double* %46, i64 2
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = fsub <2 x double> %48, %40
%53 = fsub <2 x double> %51, %42
%54 = bitcast double* %46 to <2 x double>*
store <2 x double> %52, <2 x double>* %54
%55 = bitcast double* %49 to <2 x double>*
store <2 x double> %53, <2 x double>* %55
%56 = or i64 %44, 4
%57 = getelementptr inbounds double, double* %2, i64 %56
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %57, i64 2
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = fsub <2 x double> %59, %40
%64 = fsub <2 x double> %62, %42
%65 = bitcast double* %57 to <2 x double>*
store <2 x double> %63, <2 x double>* %65
%66 = bitcast double* %60 to <2 x double>*
store <2 x double> %64, <2 x double>* %66
%67 = add nuw i64 %44, 8
%68 = add i64 %45, 2
%69 = icmp eq i64 %68, %28
br i1 %69, label %70, label %43
70: ; preds = %43, %38
%71 = phi i64 [ 0, %38 ], [ %67, %43 ]
br i1 %29, label %83, label %72
72: ; preds = %70
%73 = getelementptr inbounds double, double* %2, i64 %71
%74 = bitcast double* %73 to <2 x double>*
%75 = load <2 x double>, <2 x double>* %74
%76 = getelementptr inbounds double, double* %73, i64 2
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = fsub <2 x double> %75, %40
%80 = fsub <2 x double> %78, %42
%81 = bitcast double* %73 to <2 x double>*
store <2 x double> %79, <2 x double>* %81
%82 = bitcast double* %76 to <2 x double>*
store <2 x double> %80, <2 x double>* %82
br label %83
83: ; preds = %70, %72
br i1 %30, label %93, label %84
84: ; preds = %37, %83
%85 = phi i64 [ 0, %37 ], [ %25, %83 ]
br label %86
86: ; preds = %84, %86
%87 = phi i64 [ %91, %86 ], [ %85, %84 ]
%88 = getelementptr inbounds double, double* %2, i64 %87
%89 = load double, double* %88
%90 = fsub double %89, %36
store double %90, double* %88
%91 = add nuw nsw i64 %87, 1
%92 = icmp eq i64 %91, %19
br i1 %92, label %93, label %86
93: ; preds = %86, %83, %31
%94 = call double @heat_capacity(double* %0, double* %2, i32 %7, double %34, double %9, double* %11, double* %12)
%95 = getelementptr inbounds double, double* %3, i64 %32
store double %94, double* %95
%96 = load double, double* %11
%97 = getelementptr inbounds double, double* %4, i64 %32
store double %96, double* %97
%98 = load double, double* %12
%99 = getelementptr inbounds double, double* %5, i64 %32
store double %98, double* %99
%100 = add nuw nsw i64 %32, 1
%101 = icmp eq i64 %100, %18
br i1 %101, label %102, label %31
102: ; preds = %93, %10
ret void
}