#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 floor(double);
void linspace(double min, double max, int n, double *result) {
  int iterator = 0;
  int i;
  double temp;
  for (i = 0; i <= n - 2; i++) {
    temp = min + i * (max - min) / (floor((double)n) - 1);
    result[iterator] = temp;
    iterator += 1;
  }
  result[iterator] = max;
  return;
}


x86 assembly (clang, -O0):
<linspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     11bb <linspace+0xab>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
call   1030 <floor@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1137 <linspace+0x27>
movsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linspace>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
cmp    $0x2,%edi
jge    112b <linspace+0x1b>
xor    %r14d,%r14d
jmp    1261 <linspace+0x151>
mov    %edi,%r14d
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
cvtsi2sd %edi,%xmm3
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
jne    1161 <linspace+0x51>
xor    %ebx,%ebx
test   $0x1,%r14b
jne    1223 <linspace+0x113>
jmp    1261 <linspace+0x151>
mov    %r14d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
movsd  %xmm2,(%rsp)
movsd  %xmm3,0x20(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm3,%xmm0
call   1030 <floor@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,(%r15,%rbx,8)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <floor@plt>
movsd  0x20(%rsp),%xmm3
movsd  (%rsp),%xmm2
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r15,%rbx,8)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1180 <linspace+0x70>
movsd  0x18(%rsp),%xmm1
test   $0x1,%r14b
je     1261 <linspace+0x151>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movapd %xmm3,%xmm0
call   1030 <floor@plt>
movsd  0x18(%rsp),%xmm1
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp),%xmm2
divsd  %xmm0,%xmm2
addsd  0x10(%rsp),%xmm2
movsd  %xmm2,(%r15,%rbx,8)
movsd  %xmm1,(%r15,%r14,8)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @linspace(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 i32
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
store double* %3, double** %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %12
12: ; preds = %39, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %7
%15 = sub nsw i32 %14, 2
%16 = icmp sle i32 %13, %15
br i1 %16, label %17, label %42
17: ; preds = %12
%18 = load double, double* %5
%19 = load i32, i32* %10
%20 = sitofp i32 %19 to double
%21 = load double, double* %6
%22 = load double, double* %5
%23 = fsub double %21, %22
%24 = fmul double %20, %23
%25 = load i32, i32* %7
%26 = sitofp i32 %25 to double
%27 = call i32 @floor(double %26)
%28 = sub nsw i32 %27, 1
%29 = sitofp i32 %28 to double
%30 = fdiv double %24, %29
%31 = fadd double %18, %30
store double %31, double* %11
%32 = load double, double* %11
%33 = load double*, double** %8
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %39
39: ; preds = %17
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %10
br label %12
42: ; preds = %12
%43 = load double, double* %6
%44 = load double*, double** %8
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
ret void
}

LLVM IR (-O2):
define void @linspace(double %0, double %1, i32 %2, double* nocapture writeonly %3) {
%5 = icmp slt i32 %2, 2
br i1 %5, label %55, label %6
6: ; preds = %4
%7 = fsub double %1, %0
%8 = sitofp i32 %2 to double
%9 = add nsw i32 %2, -1
%10 = zext i32 %9 to i64
%11 = and i64 %10, 1
%12 = icmp eq i32 %9, 1
br i1 %12, label %40, label %13
13: ; preds = %6
%14 = and i64 %10, 4294967294
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %37, %15 ]
%17 = phi i64 [ 0, %13 ], [ %38, %15 ]
%18 = trunc i64 %16 to i32
%19 = sitofp i32 %18 to double
%20 = fmul double %7, %19
%21 = tail call i32 @floor(double %8)
%22 = add nsw i32 %21, -1
%23 = sitofp i32 %22 to double
%24 = fdiv double %20, %23
%25 = fadd double %24, %0
%26 = getelementptr inbounds double, double* %3, i64 %16
store double %25, double* %26
%27 = or i64 %16, 1
%28 = trunc i64 %27 to i32
%29 = sitofp i32 %28 to double
%30 = fmul double %7, %29
%31 = tail call i32 @floor(double %8)
%32 = add nsw i32 %31, -1
%33 = sitofp i32 %32 to double
%34 = fdiv double %30, %33
%35 = fadd double %34, %0
%36 = getelementptr inbounds double, double* %3, i64 %27
store double %35, double* %36
%37 = add nuw nsw i64 %16, 2
%38 = add i64 %17, 2
%39 = icmp eq i64 %38, %14
br i1 %39, label %40, label %15
40: ; preds = %15, %6
%41 = phi i64 [ 0, %6 ], [ %37, %15 ]
%42 = icmp eq i64 %11, 0
br i1 %42, label %53, label %43
43: ; preds = %40
%44 = trunc i64 %41 to i32
%45 = sitofp i32 %44 to double
%46 = fmul double %7, %45
%47 = tail call i32 @floor(double %8)
%48 = add nsw i32 %47, -1
%49 = sitofp i32 %48 to double
%50 = fdiv double %46, %49
%51 = fadd double %50, %0
%52 = getelementptr inbounds double, double* %3, i64 %41
store double %51, double* %52
br label %53
53: ; preds = %40, %43
%54 = zext i32 %9 to i64
br label %55
55: ; preds = %4, %53
%56 = phi i64 [ %54, %53 ], [ 0, %4 ]
%57 = getelementptr inbounds double, double* %3, i64 %56
store double %1, double* %57
ret void
}