#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 *malloc(int);
int /*<<< orphan*/ perror(char *);
double *array(double lower, double step, double upper) {
  if (step <= 0) {
    perror("Step size too small");
  } else {
    int i = 0, numsteps = (upper - lower) / step + 1;
    double *someArray = malloc(numsteps * sizeof(double));
    while (i < numsteps) {
      someArray[i] = lower + i * step;
      i++;
    }
    return someArray;
  }
  return 0;
}


x86 assembly (clang, -O0):
<array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1156 <array+0x36>
lea    0xebc(%rip),%rdi
call   1040 <perror@plt>
jmp    11dd <array+0xbd>
movl   $0x0,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11d0 <array+0xb0>
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1192 <array+0x72>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <array+0xc5>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array>:
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm1,%xmm3
jae    12d5 <array+0x1b5>
movapd %xmm0,(%rsp)
subsd  %xmm0,%xmm2
movapd %xmm1,0x10(%rsp)
divsd  %xmm1,%xmm2
addsd  0xeb2(%rip),%xmm2
cvttsd2si %xmm2,%ebx
lea    0x0(,%rbx,8),%edi
call   1030 <malloc@plt>
test   %ebx,%ebx
jle    12bd <array+0x19d>
mov    %ebx,%ecx
cmp    $0x4,%ebx
jae    117f <array+0x5f>
xor    %edx,%edx
movapd 0x10(%rsp),%xmm4
movapd (%rsp),%xmm5
jmp    12a0 <array+0x180>
mov    %ecx,%edx
and    $0xfffffffc,%edx
movapd 0x10(%rsp),%xmm4
movapd %xmm4,%xmm0
unpcklpd %xmm4,%xmm0
movapd (%rsp),%xmm5
movapd %xmm5,%xmm1
unpcklpd %xmm5,%xmm1
lea    -0x4(%rdx),%rsi
mov    %rsi,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rsi,%rsi
je     12c3 <array+0x1a3>
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
movdqa 0xe4a(%rip),%xmm2
xor    %esi,%esi
movdqa 0xe4f(%rip),%xmm8
movdqa 0xe56(%rip),%xmm9
movdqa 0xe5d(%rip),%xmm10
movdqa 0xe65(%rip),%xmm6
nopl   0x0(%rax,%rax,1)
movdqa %xmm2,%xmm7
cvtdq2pd %xmm2,%xmm3
paddd  %xmm8,%xmm7
cvtdq2pd %xmm7,%xmm7
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm0,%xmm7
addpd  %xmm1,%xmm7
movupd %xmm3,(%rax,%rsi,8)
movupd %xmm7,0x10(%rax,%rsi,8)
movdqa %xmm2,%xmm3
paddd  %xmm9,%xmm3
movdqa %xmm2,%xmm7
cvtdq2pd %xmm3,%xmm3
paddd  %xmm10,%xmm7
cvtdq2pd %xmm7,%xmm7
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm0,%xmm7
addpd  %xmm1,%xmm7
movupd %xmm3,0x20(%rax,%rsi,8)
movupd %xmm7,0x30(%rax,%rsi,8)
add    $0x8,%rsi
paddd  %xmm6,%xmm2
add    $0xfffffffffffffffe,%rdi
jne    11f0 <array+0xd0>
test   $0x1,%r8b
je     1291 <array+0x171>
cvtdq2pd %xmm2,%xmm3
paddd  0xdae(%rip),%xmm2
cvtdq2pd %xmm2,%xmm2
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm0,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm3,(%rax,%rsi,8)
movupd %xmm2,0x10(%rax,%rsi,8)
cmp    %rcx,%rdx
je     12bd <array+0x19d>
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm5,%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    12a0 <array+0x180>
add    $0x20,%rsp
pop    %rbx
ret
movdqa 0xd45(%rip),%xmm2
xor    %esi,%esi
test   $0x1,%r8b
jne    1266 <array+0x146>
jmp    1291 <array+0x171>
lea    0xd84(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
jmp    12bd <array+0x19d>

LLVM IR (-O0):
@.str = [20 x i8] c"Step size too small\00"
define double* @array(double %0, double %1, double %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%11 = load double, double* %6
%12 = fcmp ole double %11, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %46
15: ; preds = %3
store i32 0, i32* %8
%16 = load double, double* %7
%17 = load double, double* %5
%18 = fsub double %16, %17
%19 = load double, double* %6
%20 = fdiv double %18, %19
%21 = fadd double %20, 1.000000e+00
%22 = fptosi double %21 to i32
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 8
%26 = trunc i64 %25 to i32
%27 = call double* @malloc(i32 %26)
store double* %27, double** %10
br label %28
28: ; preds = %32, %15
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %44
32: ; preds = %28
%33 = load double, double* %5
%34 = load i32, i32* %8
%35 = sitofp i32 %34 to double
%36 = load double, double* %6
%37 = call double @llvm.fmuladd.f64(double %35, double %36, double %33)
%38 = load double*, double** %10
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %28
44: ; preds = %28
%45 = load double*, double** %10
store double* %45, double** %4
br label %47
46: ; preds = %13
store double* null, double** %4
br label %47
47: ; preds = %46, %44
%48 = load double*, double** %4
ret double* %48
}

LLVM IR (-O2):
@.str = [20 x i8] c"Step size too small\00"
define noalias double* @array(double %0, double %1, double %2) {
%4 = fcmp ugt double %1, 0.000000e+00
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %89
7: ; preds = %3
%8 = fsub double %2, %0
%9 = fdiv double %8, %1
%10 = fadd double %9, 1.000000e+00
%11 = fptosi double %10 to i32
%12 = shl i32 %11, 3
%13 = tail call double* @malloc(i32 %12)
%14 = icmp sgt i32 %11, 0
br i1 %14, label %15, label %89
15: ; preds = %7
%16 = zext i32 %11 to i64
%17 = icmp ult i32 %11, 4
br i1 %17, label %79, label %18
18: ; preds = %15
%19 = and i64 %16, 4294967292
%20 = insertelement <2 x double> poison, double %1, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = insertelement <2 x double> poison, double %0, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = insertelement <2 x double> poison, double %1, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = insertelement <2 x double> poison, double %0, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = add nsw i64 %19, -4
%29 = lshr exact i64 %28, 2
%30 = add nuw nsw i64 %29, 1
%31 = and i64 %30, 1
%32 = icmp eq i64 %28, 0
br i1 %32, label %63, label %33
33: ; preds = %18
%34 = and i64 %30, 9223372036854775806
br label %35
35: ; preds = %35, %33
%36 = phi i64 [ 0, %33 ], [ %59, %35 ]
%37 = phi <2 x i32> [ <i32 0, i32 1>, %33 ], [ %60, %35 ]
%38 = phi i64 [ 0, %33 ], [ %61, %35 ]
%39 = add <2 x i32> %37, <i32 2, i32 2>
%40 = sitofp <2 x i32> %37 to <2 x double>
%41 = sitofp <2 x i32> %39 to <2 x double>
%42 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %40, <2 x double> %21, <2 x double> %23)
%43 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %41, <2 x double> %25, <2 x double> %27)
%44 = getelementptr inbounds double, double* %13, i64 %36
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> %42, <2 x double>* %45
%46 = getelementptr inbounds double, double* %44, i64 2
%47 = bitcast double* %46 to <2 x double>*
store <2 x double> %43, <2 x double>* %47
%48 = or i64 %36, 4
%49 = add <2 x i32> %37, <i32 4, i32 4>
%50 = add <2 x i32> %37, <i32 6, i32 6>
%51 = sitofp <2 x i32> %49 to <2 x double>
%52 = sitofp <2 x i32> %50 to <2 x double>
%53 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %51, <2 x double> %21, <2 x double> %23)
%54 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %25, <2 x double> %27)
%55 = getelementptr inbounds double, double* %13, i64 %48
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> %53, <2 x double>* %56
%57 = getelementptr inbounds double, double* %55, i64 2
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> %54, <2 x double>* %58
%59 = add nuw i64 %36, 8
%60 = add <2 x i32> %37, <i32 8, i32 8>
%61 = add i64 %38, 2
%62 = icmp eq i64 %61, %34
br i1 %62, label %63, label %35
63: ; preds = %35, %18
%64 = phi i64 [ 0, %18 ], [ %59, %35 ]
%65 = phi <2 x i32> [ <i32 0, i32 1>, %18 ], [ %60, %35 ]
%66 = icmp eq i64 %31, 0
br i1 %66, label %77, label %67
67: ; preds = %63
%68 = add <2 x i32> %65, <i32 2, i32 2>
%69 = sitofp <2 x i32> %65 to <2 x double>
%70 = sitofp <2 x i32> %68 to <2 x double>
%71 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %69, <2 x double> %21, <2 x double> %23)
%72 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %70, <2 x double> %25, <2 x double> %27)
%73 = getelementptr inbounds double, double* %13, i64 %64
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %71, <2 x double>* %74
%75 = getelementptr inbounds double, double* %73, i64 2
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %72, <2 x double>* %76
br label %77
77: ; preds = %63, %67
%78 = icmp eq i64 %19, %16
br i1 %78, label %89, label %79
79: ; preds = %15, %77
%80 = phi i64 [ 0, %15 ], [ %19, %77 ]
br label %81
81: ; preds = %79, %81
%82 = phi i64 [ %87, %81 ], [ %80, %79 ]
%83 = trunc i64 %82 to i32
%84 = sitofp i32 %83 to double
%85 = tail call double @llvm.fmuladd.f64(double %84, double %1, double %0)
%86 = getelementptr inbounds double, double* %13, i64 %82
store double %85, double* %86
%87 = add nuw nsw i64 %82, 1
%88 = icmp eq i64 %87, %16
br i1 %88, label %89, label %81
89: ; preds = %81, %77, %7, %5
%90 = phi double* [ null, %5 ], [ %13, %7 ], [ %13, %77 ], [ %13, %81 ]
ret double* %90
}