#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 avgEnergy(double);
double avgMagnetization(double);
double heatCapacity(double);
double partitionFunc(double);
int /*<<< orphan*/ print_to_file(double **);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j;
  double beta;
  double dT;
  double Z, avgM, C, avgE;
  double data_array[1000][8];
  dT = (double)((100.0 - 0.1) / 1000);
  printf("dT: %f\n", dT);
  for (i = 1; i <= 1000; i++) {
    data_array[i][1] = 100.0 - (i * dT);
    printf("Temp %d: %f\n", i, data_array[i][1]);
  }
  for (j = 0; j <= 1000; j++) {
    beta = 1.0 / data_array[j][1];
    avgE = avgEnergy(beta);
    avgM = avgMagnetization(beta);
    C = heatCapacity(beta);
    Z = partitionFunc(beta);
    data_array[j][2] = avgE;
    data_array[j][3] = avgE / 1;
    data_array[j][4] = avgM;
    data_array[j][5] = avgM / 1;
    data_array[j][6] = C;
    data_array[j][7] = C / 1;
    data_array[j][8] = Z;
  }
  print_to_file(data_array);
  printf("End of program!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfa40,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jg     1224 <main+0xc4>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe3d(%rip),%xmm1
addsd  %xmm1,%xmm0
movslq -0x8(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1199 <main+0x39>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jg     138e <main+0x22e>
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  0xdb6(%rip),%xmm0
divsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <avgEnergy@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <avgMagnetization@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <heatCapacity@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <partitionFunc@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm0
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xd47(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x30(%rbp),%xmm0
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x30(%rbp),%xmm0
movsd  0xd03(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x38(%rbp),%xmm0
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  0xcbf(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x28(%rbp),%xmm0
movslq -0xc(%rbp),%rcx
lea    -0xfa40(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movsd  %xmm0,0x40(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    122b <main+0xcb>
lea    -0xfa40(%rbp),%rdi
call   1080 <print_to_file@plt>
lea    0xc8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xfa40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xfa20,%rsp
lea    0xeae(%rip),%rdi
movsd  0xe86(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%ebp
mov    $0x48,%ebx
lea    0xe96(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe59(%rip),%xmm0
addsd  0xe59(%rip),%xmm0
movsd  %xmm0,0x20(%rsp,%rbx,1)
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x40,%rbx
cmp    $0xfa48,%rbx
jne    11a0 <main+0x40>
mov    $0x40,%ebx
xchg   %ax,%ax
movsd  0xe30(%rip),%xmm0
divsd  -0x18(%rsp,%rbx,1),%xmm0
movsd  %xmm0,(%rsp)
call   1070 <avgEnergy@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1030 <avgMagnetization@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1060 <heatCapacity@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1050 <partitionFunc@plt>
movsd  0x18(%rsp),%xmm1
movsd  %xmm1,-0x10(%rsp,%rbx,1)
movsd  %xmm1,-0x8(%rsp,%rbx,1)
movsd  0x10(%rsp),%xmm1
movsd  %xmm1,(%rsp,%rbx,1)
movsd  %xmm1,0x8(%rsp,%rbx,1)
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp,%rbx,1)
movsd  %xmm1,0x18(%rsp,%rbx,1)
movsd  %xmm0,0x20(%rsp,%rbx,1)
add    $0x40,%rbx
cmp    $0xfa80,%rbx
jne    11e0 <main+0x80>
lea    0x20(%rsp),%rdi
call   1080 <print_to_file@plt>
lea    0xdb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xfa20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"dT: %f\0A\00"
@.str.1 = [13 x i8] c"Temp %d: %f\0A\00"
@.str.2 = [16 x i8] c"End of program!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [1000 x [8 x double]]
store i32 0, i32* %1
store double 9.990000e-02, double* %5
%11 = load double, double* %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %11)
store i32 1, i32* %2
br label %13
13: ; preds = %33, %0
%14 = load i32, i32* %2
%15 = icmp sle i32 %14, 1000
br i1 %15, label %16, label %36
16: ; preds = %13
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to double
%19 = load double, double* %5
%20 = fneg double %18
%21 = call double @llvm.fmuladd.f64(double %20, double %19, double 1.000000e+02)
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %23
%25 = getelementptr inbounds [8 x double], [8 x double]* %24, i64 0, i64 1
store double %21, double* %25
%26 = load i32, i32* %2
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %28
%30 = getelementptr inbounds [8 x double], [8 x double]* %29, i64 0, i64 1
%31 = load double, double* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %26, double %31)
br label %33
33: ; preds = %16
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %13
36: ; preds = %13
store i32 0, i32* %3
br label %37
37: ; preds = %93, %36
%38 = load i32, i32* %3
%39 = icmp sle i32 %38, 1000
br i1 %39, label %40, label %96
40: ; preds = %37
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %42
%44 = getelementptr inbounds [8 x double], [8 x double]* %43, i64 0, i64 1
%45 = load double, double* %44
%46 = fdiv double 1.000000e+00, %45
store double %46, double* %4
%47 = load double, double* %4
%48 = call double @avgEnergy(double %47)
store double %48, double* %9
%49 = load double, double* %4
%50 = call double @avgMagnetization(double %49)
store double %50, double* %7
%51 = load double, double* %4
%52 = call double @heatCapacity(double %51)
store double %52, double* %8
%53 = load double, double* %4
%54 = call double @partitionFunc(double %53)
store double %54, double* %6
%55 = load double, double* %9
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %57
%59 = getelementptr inbounds [8 x double], [8 x double]* %58, i64 0, i64 2
store double %55, double* %59
%60 = load double, double* %9
%61 = fdiv double %60, 1.000000e+00
%62 = load i32, i32* %3
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %63
%65 = getelementptr inbounds [8 x double], [8 x double]* %64, i64 0, i64 3
store double %61, double* %65
%66 = load double, double* %7
%67 = load i32, i32* %3
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %68
%70 = getelementptr inbounds [8 x double], [8 x double]* %69, i64 0, i64 4
store double %66, double* %70
%71 = load double, double* %7
%72 = fdiv double %71, 1.000000e+00
%73 = load i32, i32* %3
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %74
%76 = getelementptr inbounds [8 x double], [8 x double]* %75, i64 0, i64 5
store double %72, double* %76
%77 = load double, double* %8
%78 = load i32, i32* %3
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %79
%81 = getelementptr inbounds [8 x double], [8 x double]* %80, i64 0, i64 6
store double %77, double* %81
%82 = load double, double* %8
%83 = fdiv double %82, 1.000000e+00
%84 = load i32, i32* %3
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %85
%87 = getelementptr inbounds [8 x double], [8 x double]* %86, i64 0, i64 7
store double %83, double* %87
%88 = load double, double* %6
%89 = load i32, i32* %3
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 %90
%92 = getelementptr inbounds [8 x double], [8 x double]* %91, i64 0, i64 8
store double %88, double* %92
br label %93
93: ; preds = %40
%94 = load i32, i32* %3
%95 = add nsw i32 %94, 1
store i32 %95, i32* %3
br label %37
96: ; preds = %37
%97 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %10, i64 0, i64 0
%98 = bitcast [8 x double]* %97 to double**
%99 = call i32 @print_to_file(double** %98)
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"dT: %f\0A\00"
@.str.1 = [13 x i8] c"Temp %d: %f\0A\00"
@.str.2 = [16 x i8] c"End of program!\00"
define i32 @main() {
%1 = alloca [1000 x [8 x double]]
%2 = bitcast [1000 x [8 x double]]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 9.990000e-02)
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 1, %0 ], [ %12, %4 ]
%6 = trunc i64 %5 to i32
%7 = sitofp i32 %6 to double
%8 = fneg double %7
%9 = tail call double @llvm.fmuladd.f64(double %8, double 9.990000e-02, double 1.000000e+02)
%10 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %5, i64 1
store double %9, double* %10
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %6, double %9)
%12 = add nuw nsw i64 %5, 1
%13 = icmp eq i64 %12, 1001
br i1 %13, label %14, label %4
14: ; preds = %4, %14
%15 = phi i64 [ %30, %14 ], [ 0, %4 ]
%16 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 1
%17 = load double, double* %16
%18 = fdiv double 1.000000e+00, %17
%19 = tail call double @avgEnergy(double %18)
%20 = tail call double @avgMagnetization(double %18)
%21 = tail call double @heatCapacity(double %18)
%22 = tail call double @partitionFunc(double %18)
%23 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 2
store double %19, double* %23
%24 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 3
store double %19, double* %24
%25 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 4
store double %20, double* %25
%26 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 5
store double %20, double* %26
%27 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 6
store double %21, double* %27
%28 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 7
store double %21, double* %28
%29 = getelementptr inbounds [1000 x [8 x double]], [1000 x [8 x double]]* %1, i64 0, i64 %15, i64 8
store double %22, double* %29
%30 = add nuw nsw i64 %15, 1
%31 = icmp eq i64 %30, 1001
br i1 %31, label %32, label %14
32: ; preds = %14
%33 = bitcast [1000 x [8 x double]]* %1 to double**
%34 = call i32 @print_to_file(double** %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}