#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 */
int /*<<< orphan*/ linspace(double *, int, double, double);
double pow(double, double);
void logspace(double *x, int n, double x_min, double x_max, double base) {
  linspace(x, n, x_min, x_max);
  for (int i = 0; i < n; i++) {
    x[i] = pow(base, x[i]);
  }
}


x86 assembly (clang, -O0):
<logspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <linspace@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1199 <logspace+0x79>
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1040 <pow@plt>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <logspace+0x3b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logspace>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movsd  %xmm2,(%rsp)
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <linspace@plt>
test   %ebp,%ebp
jle    11ed <logspace+0xcd>
mov    %ebp,%r15d
lea    -0x1(%r15),%rax
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    1156 <logspace+0x36>
xor    %ebp,%ebp
jmp    11bf <logspace+0x9f>
and    $0xfffffffc,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax)
movsd  (%rbx,%rbp,8),%xmm1
movsd  (%rsp),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,(%rbx,%rbp,8)
movsd  0x8(%rbx,%rbp,8),%xmm1
movsd  (%rsp),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rbx,%rbp,8)
movsd  0x10(%rbx,%rbp,8),%xmm1
movsd  (%rsp),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,0x10(%rbx,%rbp,8)
movsd  0x18(%rbx,%rbp,8),%xmm1
movsd  (%rsp),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,0x18(%rbx,%rbp,8)
add    $0x4,%rbp
cmp    %rbp,%r15
jne    1160 <logspace+0x40>
test   %r14,%r14
je     11ed <logspace+0xcd>
lea    (%rbx,%rbp,8),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rbp,8),%xmm1
movsd  (%rsp),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11d0 <logspace+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @logspace(double* %0, i32 %1, double %2, double %3, double %4) {
%6 = tail call i32 @linspace(double* %0, i32 %1, double %2, double %3)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = zext i32 %1 to i64
%10 = add nsw i64 %9, -1
%11 = and i64 %9, 3
%12 = icmp ult i64 %10, 3
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = and i64 %9, 4294967292
br label %28
15: ; preds = %28, %8
%16 = phi i64 [ 0, %8 ], [ %46, %28 ]
%17 = icmp eq i64 %11, 0
br i1 %17, label %27, label %18
18: ; preds = %15, %18
%19 = phi i64 [ %24, %18 ], [ %16, %15 ]
%20 = phi i64 [ %25, %18 ], [ 0, %15 ]
%21 = getelementptr inbounds double, double* %0, i64 %19
%22 = load double, double* %21
%23 = tail call double @pow(double %4, double %22)
store double %23, double* %21
%24 = add nuw nsw i64 %19, 1
%25 = add i64 %20, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %27, label %18
27: ; preds = %15, %18, %5
ret void
28: ; preds = %28, %13
%29 = phi i64 [ 0, %13 ], [ %46, %28 ]
%30 = phi i64 [ 0, %13 ], [ %47, %28 ]
%31 = getelementptr inbounds double, double* %0, i64 %29
%32 = load double, double* %31
%33 = tail call double @pow(double %4, double %32)
store double %33, double* %31
%34 = or i64 %29, 1
%35 = getelementptr inbounds double, double* %0, i64 %34
%36 = load double, double* %35
%37 = tail call double @pow(double %4, double %36)
store double %37, double* %35
%38 = or i64 %29, 2
%39 = getelementptr inbounds double, double* %0, i64 %38
%40 = load double, double* %39
%41 = tail call double @pow(double %4, double %40)
store double %41, double* %39
%42 = or i64 %29, 3
%43 = getelementptr inbounds double, double* %0, i64 %42
%44 = load double, double* %43
%45 = tail call double @pow(double %4, double %44)
store double %45, double* %43
%46 = add nuw nsw i64 %29, 4
%47 = add i64 %30, 4
%48 = icmp eq i64 %47, %14
br i1 %48, label %15, label %28
}