#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(int);
int log(double);
void genInLogspace(double maxval, double minratio, int nvals, double *out) {
  int i;
  double minval;
  minval = maxval * minratio;
  out[0] = maxval;
  for (i = 1; i < nvals; i++)
    out[i] =
        exp((log(maxval) * (nvals - i - 1) + log(minval) * i) / (nvals - 1));
}


x86 assembly (clang, -O0):
<genInLogspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c1 <genInLogspace+0xa1>
movsd  -0x8(%rbp),%xmm0
call   1040 <log@plt>
mov    -0x14(%rbp),%ecx
sub    -0x24(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x34(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   -0x24(%rbp),%ecx
add    %ecx,%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <exp@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115c <genInLogspace+0x3c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genInLogspace>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm0,(%rsi)
cmp    $0x2,%edi
jl     11af <genInLogspace+0x8f>
mov    %rsi,%r14
mov    %edi,%r13d
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    -0x1(%r13),%r15d
mov    %edi,%r12d
add    $0xfffffffe,%r13d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0x10(%rsp),%xmm0
call   1040 <log@plt>
mov    %eax,%ebp
imul   %r13d,%ebp
movsd  0x8(%rsp),%xmm0
call   1040 <log@plt>
imul   %ebx,%eax
add    %ebp,%eax
cltd
idiv   %r15d
mov    %eax,%edi
call   1030 <exp@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
add    $0xffffffff,%r13d
cmp    %rbx,%r12
jne    1170 <genInLogspace+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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