#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 */
int /*<<< orphan*/ createTrajectory(double, double, double, double *);
int devrand();
double *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ setall(long, long);
int main(int argc, const char *argv[]) {
  double freq, t, dt, N, alpha, s;
  int i, j;
  double sum = 0;
  long seed1, seed2;
  double *currentTraj;
  seed1 = (long)(devrand() % 2147483399);
  seed2 = (long)(devrand() % 2147483399);
  setall(seed1, seed2);
  currentTraj = malloc(sizeof(double) * 10000000);
  N = 20000;
  dt = 1.0 / (400.0 * N);
  s = 0.0002;
  alpha = 2 * N * s;
  createTrajectory(N, alpha, dt, currentTraj);
  i = 0;
  while (currentTraj[i] > (1.0 / (2 * N))) {
    printf("%lf\n", currentTraj[i++]);
  }
  printf("%d\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1050 <devrand@plt>
mov    $0x7fffff07,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1050 <devrand@plt>
mov    $0x7fffff07,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1060 <setall@plt>
mov    $0x4c4b400,%edi
call   1040 <malloc@plt>
mov    %rax,-0x68(%rbp)
movsd  0xe63(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe4e(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
movsd  0xe39(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe20(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe0b(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
mov    -0x68(%rbp),%rdi
call   1070 <createTrajectory@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xdc8(%rip),%xmm2
mulsd  -0x30(%rbp),%xmm2
movsd  0xdcb(%rip),%xmm1
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    127b <main+0x12b>
mov    -0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%esi
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
jmp    1223 <main+0xd3>
mov    -0x44(%rbp),%esi
lea    0xda8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <devrand@plt>
cltq
imul   $0x4000007d,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x3d,%rcx
add    %edx,%ecx
imul   $0x7fffff07,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%r14
xor    %eax,%eax
call   1050 <devrand@plt>
cltq
imul   $0x4000007d,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x3d,%rcx
add    %edx,%ecx
imul   $0x7fffff07,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rsi
mov    %r14,%rdi
call   1060 <setall@plt>
mov    $0x4c4b400,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
movsd  0xe38(%rip),%xmm0
movsd  0xe38(%rip),%xmm1
movsd  0xe38(%rip),%xmm2
mov    %rax,%rdi
call   1070 <createTrajectory@plt>
movsd  (%r14),%xmm0
ucomisd 0xe2b(%rip),%xmm0
jbe    1224 <main+0xd4>
xor    %r12d,%r12d
lea    0xe27(%rip),%r15
nopl   0x0(%rax)
mov    %r12,%rbx
add    $0x1,%r12
cvttsd2si %xmm0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
movsd  0x8(%r14,%rbx,8),%xmm0
ucomisd 0xdf6(%rip),%xmm0
ja     1200 <main+0xb0>
lea    0xdfa(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca i64
%16 = alloca i64
%17 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %14
%18 = call i32 (...) @devrand()
%19 = srem i32 %18, 2147483399
%20 = sext i32 %19 to i64
store i64 %20, i64* %15
%21 = call i32 (...) @devrand()
%22 = srem i32 %21, 2147483399
%23 = sext i32 %22 to i64
store i64 %23, i64* %16
%24 = load i64, i64* %15
%25 = load i64, i64* %16
%26 = call i32 @setall(i64 %24, i64 %25)
%27 = call double* @malloc(i32 80000000)
store double* %27, double** %17
store double 2.000000e+04, double* %9
%28 = load double, double* %9
%29 = fmul double 4.000000e+02, %28
%30 = fdiv double 1.000000e+00, %29
store double %30, double* %8
store double 2.000000e-04, double* %11
%31 = load double, double* %9
%32 = fmul double 2.000000e+00, %31
%33 = load double, double* %11
%34 = fmul double %32, %33
store double %34, double* %10
%35 = load double, double* %9
%36 = load double, double* %10
%37 = load double, double* %8
%38 = load double*, double** %17
%39 = call i32 @createTrajectory(double %35, double %36, double %37, double* %38)
store i32 0, i32* %12
br label %40
40: ; preds = %50, %2
%41 = load double*, double** %17
%42 = load i32, i32* %12
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = load double, double* %9
%47 = fmul double 2.000000e+00, %46
%48 = fdiv double 1.000000e+00, %47
%49 = fcmp ogt double %45, %48
br i1 %49, label %50, label %59
50: ; preds = %40
%51 = load double*, double** %17
%52 = load i32, i32* %12
%53 = add nsw i32 %52, 1
store i32 %53, i32* %12
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds double, double* %51, i64 %54
%56 = load double, double* %55
%57 = fptosi double %56 to i32
%58 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %57)
br label %40
59: ; preds = %40
%60 = load i32, i32* %12
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @devrand()
%4 = srem i32 %3, 2147483399
%5 = sext i32 %4 to i64
%6 = tail call i32 (...) @devrand()
%7 = srem i32 %6, 2147483399
%8 = sext i32 %7 to i64
%9 = tail call i32 @setall(i64 %5, i64 %8)
%10 = tail call double* @malloc(i32 80000000)
%11 = tail call i32 @createTrajectory(double 2.000000e+04, double 8.000000e+00, double 1.250000e-07, double* %10)
%12 = load double, double* %10
%13 = fcmp ogt double %12, 2.500000e-05
br i1 %13, label %14, label %25
14: ; preds = %2, %14
%15 = phi i64 [ %17, %14 ], [ 0, %2 ]
%16 = phi double [ %21, %14 ], [ %12, %2 ]
%17 = add nuw i64 %15, 1
%18 = fptosi double %16 to i32
%19 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds double, double* %10, i64 %17
%21 = load double, double* %20
%22 = fcmp ogt double %21, 2.500000e-05
br i1 %22, label %14, label %23
23: ; preds = %14
%24 = trunc i64 %17 to i32
br label %25
25: ; preds = %23, %2
%26 = phi i32 [ 0, %2 ], [ %24, %23 ]
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret i32 0
}