#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 genicSelectionStochasticForwards(double, double, double);
void createTrajectory(int N, double alpha, double dt,
                      double *currentTrajectory) {
  float freq = ((2 * N) - 1.0) / (2 * N);
  int i = 0;
  while (freq > (1.0 / (2 * N))) {
    freq = 1.0 - genicSelectionStochasticForwards(dt, (1.0 - freq), alpha);
    currentTrajectory[i++] = freq;
  }
}


x86 assembly (clang, -O0):
<createTrajectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xec5(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe88(%rip),%xmm1
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11e7 <createTrajectory+0xd7>
movsd  -0x18(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe64(%rip),%xmm1
subsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
call   1030 <genicSelectionStochasticForwards@plt>
movaps %xmm0,%xmm1
movsd  0xe4b(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    115d <createTrajectory+0x4d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createTrajectory>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm1,%xmm3
movaps %xmm0,%xmm2
add    %edi,%edi
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
movsd  0xed3(%rip),%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
movsd  0xec7(%rip),%xmm4
movapd %xmm4,%xmm5
divsd  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
ucomisd %xmm5,%xmm0
jbe    11bc <createTrajectory+0xac>
mov    %rsi,%rbx
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm5,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
movapd %xmm4,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
call   1030 <genicSelectionStochasticForwards@plt>
movsd  0x8(%rsp),%xmm5
movsd  0xe79(%rip),%xmm4
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movapd %xmm4,%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rbx)
add    $0x8,%rbx
ucomisd %xmm5,%xmm0
ja     1170 <createTrajectory+0x60>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @createTrajectory(i32 %0, double %1, double %2, double* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca float
%10 = alloca i32
store i32 %0, i32* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%11 = load i32, i32* %5
%12 = mul nsw i32 2, %11
%13 = sitofp i32 %12 to double
%14 = fsub double %13, 1.000000e+00
%15 = load i32, i32* %5
%16 = mul nsw i32 2, %15
%17 = sitofp i32 %16 to double
%18 = fdiv double %14, %17
%19 = fptrunc double %18 to float
store float %19, float* %9
store i32 0, i32* %10
br label %20
20: ; preds = %28, %4
%21 = load float, float* %9
%22 = fpext float %21 to double
%23 = load i32, i32* %5
%24 = mul nsw i32 2, %23
%25 = sitofp i32 %24 to double
%26 = fdiv double 1.000000e+00, %25
%27 = fcmp ogt double %22, %26
br i1 %27, label %28, label %44
28: ; preds = %20
%29 = load double, double* %7
%30 = load float, float* %9
%31 = fpext float %30 to double
%32 = fsub double 1.000000e+00, %31
%33 = load double, double* %6
%34 = call double @genicSelectionStochasticForwards(double %29, double %32, double %33)
%35 = fsub double 1.000000e+00, %34
%36 = fptrunc double %35 to float
store float %36, float* %9
%37 = load float, float* %9
%38 = fpext float %37 to double
%39 = load double*, double** %8
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %10
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
store double %38, double* %43
br label %20
44: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @createTrajectory(i32 %0, double %1, double %2, double* nocapture writeonly %3) {
%5 = shl nsw i32 %0, 1
%6 = sitofp i32 %5 to double
%7 = fadd double %6, -1.000000e+00
%8 = fdiv double %7, %6
%9 = fptrunc double %8 to float
%10 = fdiv double 1.000000e+00, %6
%11 = fpext float %9 to double
%12 = fcmp olt double %10, %11
br i1 %12, label %13, label %24
13: ; preds = %4, %13
%14 = phi i64 [ %21, %13 ], [ 0, %4 ]
%15 = phi double [ %20, %13 ], [ %11, %4 ]
%16 = fsub double 1.000000e+00, %15
%17 = tail call double @genicSelectionStochasticForwards(double %2, double %16, double %1)
%18 = fsub double 1.000000e+00, %17
%19 = fptrunc double %18 to float
%20 = fpext float %19 to double
%21 = add nuw i64 %14, 1
%22 = getelementptr inbounds double, double* %3, i64 %14
store double %20, double* %22
%23 = fcmp olt double %10, %20
br i1 %23, label %13, label %24
24: ; preds = %13, %4
ret void
}