#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 optpath2(double);
void mk_optpath_data1(int n, double rr[], double tt[], double (*pf)(double)) {
  double z, dz = 2.0 / (n - 1);
  int i;
  for (i = 0; i < n; i++) {
    z = i * dz;
    rr[i] = pf(z);
    tt[i] = optpath2(rr[i]);
  }
}


x86 assembly (clang, -O0):
<mk_optpath_data1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xec7(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a9 <mk_optpath_data1+0x99>
cvtsi2sdl -0x34(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
call   *%rax
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <optpath2@plt>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1149 <mk_optpath_data1+0x39>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk_optpath_data1>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    117a <mk_optpath_data1+0x6a>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
lea    -0x1(%rdi),%eax
cvtsi2sd %eax,%xmm0
movsd  0xec7(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %edi,%r13d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
call   *%r14
movsd  %xmm0,(%r12,%rbx,8)
call   1030 <optpath2@plt>
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1150 <mk_optpath_data1+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @mk_optpath_data1(i32 %0, double* nocapture writeonly %1, double* nocapture writeonly %2, double (double)* nocapture %3) {
%5 = add nsw i32 %0, -1
%6 = sitofp i32 %5 to double
%7 = fdiv double 2.000000e+00, %6
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %22
9: ; preds = %4
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %20, %11 ]
%13 = trunc i64 %12 to i32
%14 = sitofp i32 %13 to double
%15 = fmul double %7, %14
%16 = tail call double %3(double %15)
%17 = getelementptr inbounds double, double* %1, i64 %12
store double %16, double* %17
%18 = tail call double @optpath2(double %16)
%19 = getelementptr inbounds double, double* %2, i64 %12
store double %18, double* %19
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %11, %4
ret void
}