#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 exp(double);
double log(double);
void exp_spaced_spaced_vector2(double *v, double lower, double upper, int n) {
  double expMin = exp(lower);
  double expMax = exp(upper);
  double delta = (expMax - expMin) / (n - 1);
  double accDelta = 0;
  for (int i = 0; i < n; ++i) {
    v[i] = log(expMin + accDelta);
    accDelta += delta;
  }
}


x86 assembly (clang, -O0):
<exp_spaced_spaced_vector2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c8 <exp_spaced_spaced_vector2+0xa8>
movsd  -0x28(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
call   1040 <log@plt>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1183 <exp_spaced_spaced_vector2+0x63>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exp_spaced_spaced_vector2>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
movsd  %xmm1,0x8(%rsp)
mov    %rdi,%r15
call   1030 <exp@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
test   %r14d,%r14d
jle    11b0 <exp_spaced_spaced_vector2+0x90>
movapd %xmm0,%xmm1
subsd  0x10(%rsp),%xmm1
lea    -0x1(%r14),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    %r14d,%r14d
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
call   1040 <log@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,(%r15,%rbx,8)
addsd  0x18(%rsp),%xmm1
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <exp_spaced_spaced_vector2+0x60>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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