#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
unsigned char *createBitVector(int sizeInBits) {
  int sizeInBytes = sizeInBits / 8 + 1;
  unsigned char *vector =
      (unsigned char *)malloc(sizeInBytes * sizeof(unsigned char *));
  if (vector == NULL) {
    fprintf(stderr, "Memory alloc error\n");
    exit(EXIT_FAILURE);
  }
  for (int i = 0; i < sizeInBytes; i++) {
    vector[i] = 0;
  }
  return vector;
}


x86 assembly (clang, -O0):
<createBitVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118d <createBitVector+0x5d>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ba <createBitVector+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1194 <createBitVector+0x64>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createBitVector>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0x7(%rbx),%ebp
test   %edi,%edi
cmovns %edi,%ebp
mov    %ebp,%edi
and    $0xfffffff8,%edi
add    $0x8,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1183 <createBitVector+0x43>
mov    %rax,%r14
cmp    $0xfffffff9,%ebx
jl     117b <createBitVector+0x3b>
sar    $0x3,%ebp
mov    %ebp,%edx
add    $0x1,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Memory alloc error\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @createBitVector(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sdiv i32 %6, 8
%8 = add nsw i32 %7, 1
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %1
store i32 0, i32* %5
br label %23
23: ; preds = %32, %22
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %27
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %23
35: ; preds = %23
%36 = load i8*, i8** %4
ret i8* %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Memory alloc error\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @createBitVector(i32 %0) {
%2 = sdiv i32 %0, 8
%3 = shl nsw i32 %2, 3
%4 = add i32 %3, 8
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = icmp slt i32 %0, -7
br i1 %9, label %18, label %10
10: ; preds = %8
%11 = zext i32 %2 to i64
%12 = add nuw nsw i64 %11, 1
br label %18
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %10, %8
ret i8* %6
}