#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__ calloc(int, int);
int /*<<< orphan*/ memoryCheck();
double *allocateDoubleVector(int n) {
  int i;
  double *vector;
  if ((vector = (double *)calloc(n, sizeof(double))) == NULL)
    memoryCheck();
  for (i = 0; i < n; i++)
    vector[i] = 0.0;
  return vector;
}


x86 assembly (clang, -O0):
<allocateDoubleVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    114d <allocateDoubleVector+0x2d>
mov    $0x0,%al
call   1040 <memoryCheck@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117e <allocateDoubleVector+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <allocateDoubleVector+0x34>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocateDoubleVector>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1165 <allocateDoubleVector+0x35>
test   %ebp,%ebp
jle    115b <allocateDoubleVector+0x2b>
mov    %ebp,%edx
shl    $0x3,%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1050 <memoryCheck@plt>
test   %ebp,%ebp
jg     114b <allocateDoubleVector+0x1b>
jmp    115b <allocateDoubleVector+0x2b>

LLVM IR (-O0):
define double* @allocateDoubleVector(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca double*
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i64 @calloc(i32 %5, i32 8)
%7 = inttoptr i64 %6 to double*
store double* %7, double** %4
%8 = icmp eq double* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 (...) @memoryCheck()
br label %11
11: ; preds = %9, %1
store i32 0, i32* %3
br label %12
12: ; preds = %21, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load double*, double** %4
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
store double 0.000000e+00, double* %20
br label %21
21: ; preds = %16
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %12
24: ; preds = %12
%25 = load double*, double** %4
ret double* %25
}

LLVM IR (-O2):
define double* @allocateDoubleVector(i32 %0) {
%2 = tail call i64 @calloc(i32 %0, i32 8)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (...) @memoryCheck()
br label %7
7: ; preds = %5, %1
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %12
9: ; preds = %7
%10 = zext i32 %0 to i64
%11 = shl nuw nsw i64 %10, 3
br label %12
12: ; preds = %9, %7
%13 = inttoptr i64 %2 to double*
ret double* %13
}