#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 */
scalar_t__ malloc(int);
double *allocateVector(int n, double initValue) {
  int i;
  double *vector = (double *)malloc(sizeof(double) * n);
  for (i = 0; i < n; i++)
    vector[i] = initValue;
  return vector;
}


x86 assembly (clang, -O0):
<allocateVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1166 <allocateVector+0x56>
movsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113a <allocateVector+0x2a>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocateVector>:
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,(%rsp)
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1030 <malloc@plt>
movaps (%rsp),%xmm1
test   %ebx,%ebx
jle    122e <allocateVector+0x11e>
mov    %ebx,%ecx
cmp    $0x4,%ebx
jae    1141 <allocateVector+0x31>
xor    %edx,%edx
jmp    1220 <allocateVector+0x110>
mov    %ecx,%edx
and    $0xfffffffc,%edx
movaps %xmm1,%xmm0
movlhps %xmm1,%xmm0
lea    -0x4(%rdx),%rbx
mov    %rbx,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x7,%esi
cmp    $0x1c,%rbx
jae    116a <allocateVector+0x5a>
xor    %ebx,%ebx
jmp    11e1 <allocateVector+0xd1>
and    $0xfffffffffffffff8,%rdi
xor    %ebx,%ebx
movups %xmm0,(%rax,%rbx,8)
movups %xmm0,0x10(%rax,%rbx,8)
movups %xmm0,0x20(%rax,%rbx,8)
movups %xmm0,0x30(%rax,%rbx,8)
movups %xmm0,0x40(%rax,%rbx,8)
movups %xmm0,0x50(%rax,%rbx,8)
movups %xmm0,0x60(%rax,%rbx,8)
movups %xmm0,0x70(%rax,%rbx,8)
movups %xmm0,0x80(%rax,%rbx,8)
movups %xmm0,0x90(%rax,%rbx,8)
movups %xmm0,0xa0(%rax,%rbx,8)
movups %xmm0,0xb0(%rax,%rbx,8)
movups %xmm0,0xc0(%rax,%rbx,8)
movups %xmm0,0xd0(%rax,%rbx,8)
movups %xmm0,0xe0(%rax,%rbx,8)
movups %xmm0,0xf0(%rax,%rbx,8)
add    $0x20,%rbx
add    $0xfffffffffffffff8,%rdi
jne    1170 <allocateVector+0x60>
test   %rsi,%rsi
je     1212 <allocateVector+0x102>
lea    (%rax,%rbx,8),%rdi
add    $0x10,%rdi
shl    $0x5,%rsi
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movups %xmm0,-0x10(%rdi,%rbx,1)
movups %xmm0,(%rdi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%rsi
jne    1200 <allocateVector+0xf0>
cmp    %rcx,%rdx
je     122e <allocateVector+0x11e>
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,(%rax,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1220 <allocateVector+0x110>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double* @allocateVector(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca double*
store i32 %0, i32* %3
store double %1, double* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to double*
store double* %12, double** %6
store i32 0, i32* %5
br label %13
13: ; preds = %23, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load double, double* %4
%19 = load double*, double** %6
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
store double %18, double* %22
br label %23
23: ; preds = %17
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %13
26: ; preds = %13
%27 = load double*, double** %6
ret double* %27
}

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