#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);
int /*<<< orphan*/ linspace(double *, double, double, int);
double log(double);
void logspace(double array[], double xi, double xf, int n) {
  int i;
  double s = log(xi);
  double f = log(xf);
  linspace(array, s, f, n);
  for (i = 0; i < n; i++) {
    array[i] = exp(array[i]);
  }
}


x86 assembly (clang, -O0):
<logspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mov    -0x1c(%rbp),%esi
call   1040 <linspace@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bd <logspace+0x8d>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <exp@plt>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1184 <logspace+0x54>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logspace>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
movsd  %xmm1,0x8(%rsp)
mov    %rdi,%rbx
call   1050 <log@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
mov    %ebp,%esi
call   1040 <linspace@plt>
test   %ebp,%ebp
jle    1198 <logspace+0x68>
mov    %ebp,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rbx,%rbp,8),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1180 <logspace+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @logspace(double* %0, double %1, double %2, i32 %3) {
%5 = tail call double @log(double %1)
%6 = tail call double @log(double %2)
%7 = tail call i32 @linspace(double* %0, double %5, double %6, i32 %3)
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = zext i32 %3 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %16, %11 ]
%13 = getelementptr inbounds double, double* %0, i64 %12
%14 = load double, double* %13
%15 = tail call double @exp(double %14)
store double %15, double* %13
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %4
ret void
}