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


x86 assembly (clang, -O0):
<allocateLongVector>:
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 <allocateLongVector+0x2d>
mov    $0x0,%al
call   1040 <memoryCheck@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117e <allocateLongVector+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <allocateLongVector+0x34>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocateLongVector>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1165 <allocateLongVector+0x35>
test   %ebp,%ebp
jle    115b <allocateLongVector+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 <allocateLongVector+0x1b>
jmp    115b <allocateLongVector+0x2b>

LLVM IR (-O0):
define i64* @allocateLongVector(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64*
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i64 @calloc(i32 %5, i32 8)
%7 = inttoptr i64 %6 to i64*
store i64* %7, i64** %4
%8 = icmp eq i64* %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 i64*, i64** %4
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i64, i64* %17, i64 %19
store i64 0, i64* %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 i64*, i64** %4
ret i64* %25
}

LLVM IR (-O2):
define i64* @allocateLongVector(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 i64*
ret i64* %13
}