#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 *dvector(int);
double exp(double);
double log(double);
double *log_spaced_spaced_vector(double lower, double upper, int n) {
  double *v = dvector(n);
  double logMin = log(lower);
  double logMax = log(upper);
  double delta = (logMax - logMin) / (n - 1);
  double accDelta = 0;
  for (int i = 0; i < n; ++i) {
    v[i] = exp(logMin + accDelta);
    accDelta += delta;
  }
  return v;
}


x86 assembly (clang, -O0):
<log_spaced_spaced_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <dvector@plt>
mov    %rax,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    -0x14(%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    -0x14(%rbp),%eax
jge    11e0 <log_spaced_spaced_vector+0xb0>
movsd  -0x28(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
call   1030 <exp@plt>
mov    -0x20(%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    119b <log_spaced_spaced_vector+0x6b>
mov    -0x20(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_spaced_spaced_vector>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%r14d
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1040 <dvector@plt>
mov    %rax,%r15
movsd  0x8(%rsp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
test   %r14d,%r14d
jle    11d0 <log_spaced_spaced_vector+0xa0>
movapd %xmm0,%xmm1
subsd  0x8(%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)
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  0x10(%rsp),%xmm1
movsd  %xmm0,(%r15,%rbx,8)
addsd  0x18(%rsp),%xmm1
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11a0 <log_spaced_spaced_vector+0x70>
mov    %r15,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double* @log_spaced_spaced_vector(double %0, double %1, i32 %2) {
%4 = tail call double* @dvector(i32 %2)
%5 = tail call double @log(double %0)
%6 = tail call double @log(double %1)
%7 = fsub double %6, %5
%8 = add nsw i32 %2, -1
%9 = sitofp i32 %8 to double
%10 = fdiv double %7, %9
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = zext i32 %2 to i64
br label %15
14: ; preds = %15, %3
ret double* %4
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 @exp(double %18)
%20 = getelementptr inbounds double, double* %4, 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
}