#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 *compute_correlation(double **, int, int, int);
double **get_sample_paths(int, int, int, int, double, double);
double pow(double, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_paths_to_csv(char *, double **, int, int);
int /*<<< orphan*/ write_to_csv(char *, double *, int);
int main() {
  int n_rand = 10;
  double eps = 0.01;
  double omega_eps = 0.25;
  double omega = omega_eps / eps;
  double kappa = 0.25 * pow(eps, 2) * pow(omega, 2);
  double g = (1 - kappa) / (1 + kappa);
  int n_burn = 10000;
  double D = 1.5;
  int nt = 1000;
  int n_paths = 40000;
  int n_sweeps = 100;
  double path_min = -10.0;
  double path_max = 10.0;
  int tau_eps_max = 15;
  int te_0 = nt / 2;
  srand(time(NULL));
  rand();
  char *pathfile_name = "sample_paths.csv";
  double **paths;
  paths = get_sample_paths(n_paths, nt, n_sweeps, n_burn, g, D);
  write_paths_to_csv(pathfile_name, paths, n_paths, nt);
  printf("Done!\n");
  double *correlations = compute_correlation(paths, n_paths, te_0, tau_eps_max);
  char *outfile_name = "correlations.dat";
  write_to_csv(outfile_name, correlations, tau_eps_max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   10a0 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe34(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   10a0 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdf5(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xde8(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x2710,-0x34(%rbp)
movsd  0xdc3(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x3e8,-0x44(%rbp)
movl   $0x9c40,-0x48(%rbp)
movl   $0x64,-0x4c(%rbp)
movsd  0xd99(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xd84(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0xf,-0x64(%rbp)
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x68(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    $0x0,%al
call   10b0 <rand@plt>
lea    0xd7c(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    -0x48(%rbp),%edi
mov    -0x44(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x34(%rbp),%ecx
movsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1060 <get_sample_paths@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x48(%rbp),%edx
mov    -0x44(%rbp),%ecx
call   1030 <write_paths_to_csv@plt>
lea    0xd50(%rip),%rdi
call   1050 <printf@plt>
mov    -0x78(%rbp),%rdi
mov    -0x48(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x64(%rbp),%ecx
call   1040 <compute_correlation@plt>
mov    %rax,-0x80(%rbp)
lea    0xd35(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x64(%rbp),%edx
call   1090 <write_to_csv@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movsd  0xe63(%rip),%xmm0
mov    $0x2,%edi
call   10a0 <pow@plt>
mulsd  0xe59(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe53(%rip),%xmm0
mov    $0x2,%edi
call   10a0 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0xe43(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
xor    %eax,%eax
call   10b0 <rand@plt>
movsd  0xe18(%rip),%xmm1
mov    $0x9c40,%edi
mov    $0x3e8,%esi
mov    $0x64,%edx
mov    $0x2710,%ecx
movsd  0x8(%rsp),%xmm0
call   1060 <get_sample_paths@plt>
mov    %rax,%rbx
lea    0xdf7(%rip),%rdi
mov    %rax,%rsi
mov    $0x9c40,%edx
mov    $0x3e8,%ecx
call   1030 <write_paths_to_csv@plt>
lea    0xe00(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    $0x9c40,%esi
mov    $0x1f4,%edx
mov    $0xf,%ecx
call   1040 <compute_correlation@plt>
lea    0xdcc(%rip),%rdi
mov    %rax,%rsi
mov    $0xf,%edx
call   1090 <write_to_csv@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"sample_paths.csv\00"
@.str.1 = [7 x i8] c"Done!\0A\00"
@.str.2 = [17 x i8] c"correlations.dat\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca double**
%19 = alloca double*
%20 = alloca i8*
store i32 0, i32* %1
store i32 10, i32* %2
store double 1.000000e-02, double* %3
store double 2.500000e-01, double* %4
%21 = load double, double* %4
%22 = load double, double* %3
%23 = fdiv double %21, %22
store double %23, double* %5
%24 = load double, double* %3
%25 = call double @pow(double %24, i32 2)
%26 = fmul double 2.500000e-01, %25
%27 = load double, double* %5
%28 = call double @pow(double %27, i32 2)
%29 = fmul double %26, %28
store double %29, double* %6
%30 = load double, double* %6
%31 = fsub double 1.000000e+00, %30
%32 = load double, double* %6
%33 = fadd double 1.000000e+00, %32
%34 = fdiv double %31, %33
store double %34, double* %7
store i32 10000, i32* %8
store double 1.500000e+00, double* %9
store i32 1000, i32* %10
store i32 40000, i32* %11
store i32 100, i32* %12
store double -1.000000e+01, double* %13
store double 1.000000e+01, double* %14
store i32 15, i32* %15
%35 = load i32, i32* %10
%36 = sdiv i32 %35, 2
store i32 %36, i32* %16
%37 = call i32 @time(i32* null)
%38 = call i32 @srand(i32 %37)
%39 = call i32 (...) @rand()
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %17
%40 = load i32, i32* %11
%41 = load i32, i32* %10
%42 = load i32, i32* %12
%43 = load i32, i32* %8
%44 = load double, double* %7
%45 = load double, double* %9
%46 = call double** @get_sample_paths(i32 %40, i32 %41, i32 %42, i32 %43, double %44, double %45)
store double** %46, double*** %18
%47 = load i8*, i8** %17
%48 = load double**, double*** %18
%49 = load i32, i32* %11
%50 = load i32, i32* %10
%51 = call i32 @write_paths_to_csv(i8* %47, double** %48, i32 %49, i32 %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%53 = load double**, double*** %18
%54 = load i32, i32* %11
%55 = load i32, i32* %16
%56 = load i32, i32* %15
%57 = call double* @compute_correlation(double** %53, i32 %54, i32 %55, i32 %56)
store double* %57, double** %19
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %20
%58 = load i8*, i8** %20
%59 = load double*, double** %19
%60 = load i32, i32* %15
%61 = call i32 @write_to_csv(i8* %58, double* %59, i32 %60)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"sample_paths.csv\00"
@.str.2 = [17 x i8] c"correlations.dat\00"
@str = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = tail call double @pow(double 1.000000e-02, i32 2)
%2 = fmul double %1, 2.500000e-01
%3 = tail call double @pow(double 2.500000e+01, i32 2)
%4 = fmul double %2, %3
%5 = fsub double 1.000000e+00, %4
%6 = fadd double %4, 1.000000e+00
%7 = fdiv double %5, %6
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
%10 = tail call i32 (...) @rand()
%11 = tail call double** @get_sample_paths(i32 40000, i32 1000, i32 100, i32 10000, double %7, double 1.500000e+00)
%12 = tail call i32 @write_paths_to_csv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double** %11, i32 40000, i32 1000)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%14 = tail call double* @compute_correlation(double** %11, i32 40000, i32 500, i32 15)
%15 = tail call i32 @write_to_csv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double* %14, i32 15)
ret i32 0
}