double *logspace(double a, double b, int n, double u[]) {
  double c;
  int i;
  if (n < 2 || u == 0)
    return (void *)0;
  c = (b - a) / (n - 1);
  for (i = 0; i < n - 1; ++i)
    u[i] = pow(10., a + i * c);
  u[n - 1] = pow(10., b);
  return u;
}


x86 assembly (clang, -O0):
<logspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %rsi,-0x28(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jl     113e <logspace+0x2e>
cmpq   $0x0,-0x28(%rbp)
jne    114b <logspace+0x3b>
movq   $0x0,-0x8(%rbp)
jmp    11eb <logspace+0xdb>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11bf <logspace+0xaf>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe61(%rip),%xmm0
call   1030 <pow@plt>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116f <logspace+0x5f>
movsd  -0x18(%rbp),%xmm1
movsd  0xe34(%rip),%xmm0
call   1030 <pow@plt>
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logspace>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
cmp    $0x2,%edi
jl     123c <logspace+0x12c>
mov    %rsi,%r15
test   %rsi,%rsi
je     123c <logspace+0x12c>
mov    %edi,%r14d
movapd %xmm0,%xmm2
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm3
add    $0xffffffff,%r14d
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
divsd  %xmm0,%xmm3
cmp    $0x1,%r14d
movsd  %xmm1,(%rsp)
jne    116d <logspace+0x5d>
xor    %ebx,%ebx
test   $0x1,%r14b
jne    11fc <logspace+0xec>
jmp    1223 <logspace+0x113>
mov    %r14d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe59(%rip),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,(%r15,%rbx,8)
lea    0x1(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  0xe30(%rip),%xmm0
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
movsd  %xmm0,0x8(%r15,%rbx,8)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1190 <logspace+0x80>
movsd  (%rsp),%xmm1
test   $0x1,%r14b
je     1223 <logspace+0x113>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xded(%rip),%xmm0
call   1030 <pow@plt>
movsd  (%rsp),%xmm1
movsd  %xmm0,(%r15,%rbx,8)
movsd  0xdd5(%rip),%xmm0
call   1030 <pow@plt>
movslq %r14d,%rax
movsd  %xmm0,(%r15,%rax,8)
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @logspace(double %0, double %1, i32 %2, double* %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double*
%10 = alloca double
%11 = alloca i32
store double %0, double* %6
store double %1, double* %7
store i32 %2, i32* %8
store double* %3, double** %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %12, 2
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = load double*, double** %9
%16 = icmp eq double* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14, %4
store double* null, double** %5
br label %54
18: ; preds = %14
%19 = load double, double* %7
%20 = load double, double* %6
%21 = fsub double %19, %20
%22 = load i32, i32* %8
%23 = sub nsw i32 %22, 1
%24 = sitofp i32 %23 to double
%25 = fdiv double %21, %24
store double %25, double* %10
store i32 0, i32* %11
br label %26
26: ; preds = %42, %18
%27 = load i32, i32* %11
%28 = load i32, i32* %8
%29 = sub nsw i32 %28, 1
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %45
31: ; preds = %26
%32 = load double, double* %6
%33 = load i32, i32* %11
%34 = sitofp i32 %33 to double
%35 = load double, double* %10
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %32)
%37 = call double @pow(double 1.000000e+01, double %36)
%38 = load double*, double** %9
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
br label %42
42: ; preds = %31
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
br label %26
45: ; preds = %26
%46 = load double, double* %7
%47 = call double @pow(double 1.000000e+01, double %46)
%48 = load double*, double** %9
%49 = load i32, i32* %8
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %48, i64 %51
store double %47, double* %52
%53 = load double*, double** %9
store double* %53, double** %5
br label %54
54: ; preds = %45, %17
%55 = load double*, double** %5
ret double* %55
}

LLVM IR (-O2):
define double* @logspace(double %0, double %1, i32 %2, double* writeonly %3) {
%5 = icmp slt i32 %2, 2
%6 = icmp eq double* %3, null
%7 = or i1 %5, %6
br i1 %7, label %48, label %8
8: ; preds = %4
%9 = fsub double %1, %0
%10 = add nsw i32 %2, -1
%11 = sitofp i32 %10 to double
%12 = fdiv double %9, %11
%13 = zext i32 %10 to i64
%14 = and i64 %13, 1
%15 = icmp eq i32 %10, 1
br i1 %15, label %35, label %16
16: ; preds = %8
%17 = and i64 %13, 4294967294
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %32, %18 ]
%20 = phi i64 [ 0, %16 ], [ %33, %18 ]
%21 = trunc i64 %19 to i32
%22 = sitofp i32 %21 to double
%23 = tail call double @llvm.fmuladd.f64(double %22, double %12, double %0)
%24 = tail call double @pow(double 1.000000e+01, double %23)
%25 = getelementptr inbounds double, double* %3, i64 %19
store double %24, double* %25
%26 = or i64 %19, 1
%27 = trunc i64 %26 to i32
%28 = sitofp i32 %27 to double
%29 = tail call double @llvm.fmuladd.f64(double %28, double %12, double %0)
%30 = tail call double @pow(double 1.000000e+01, double %29)
%31 = getelementptr inbounds double, double* %3, i64 %26
store double %30, double* %31
%32 = add nuw nsw i64 %19, 2
%33 = add i64 %20, 2
%34 = icmp eq i64 %33, %17
br i1 %34, label %35, label %18
35: ; preds = %18, %8
%36 = phi i64 [ 0, %8 ], [ %32, %18 ]
%37 = icmp eq i64 %14, 0
br i1 %37, label %44, label %38
38: ; preds = %35
%39 = trunc i64 %36 to i32
%40 = sitofp i32 %39 to double
%41 = tail call double @llvm.fmuladd.f64(double %40, double %12, double %0)
%42 = tail call double @pow(double 1.000000e+01, double %41)
%43 = getelementptr inbounds double, double* %3, i64 %36
store double %42, double* %43
br label %44
44: ; preds = %35, %38
%45 = tail call double @pow(double 1.000000e+01, double %1)
%46 = sext i32 %10 to i64
%47 = getelementptr inbounds double, double* %3, i64 %46
store double %45, double* %47
br label %48
48: ; preds = %4, %44
%49 = phi double* [ %3, %44 ], [ null, %4 ]
ret double* %49
}