#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*/ isNullPointer(void *);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ requestMemoryBlock(int, void **);
void initializeMemoryBlock(void **memory_pointer, int memory_block_index,
                           int blocksize_bytes) {
  requestMemoryBlock(blocksize_bytes, &memory_pointer[memory_block_index]);
  if (!isNullPointer(memory_pointer[memory_block_index]))
    memset(memory_pointer[memory_block_index], 0, blocksize_bytes);
  return;
}


x86 assembly (clang, -O0):
<initializeMemoryBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <requestMemoryBlock@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <isNullPointer@plt>
cmp    $0x0,%eax
jne    1189 <initializeMemoryBlock+0x59>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initializeMemoryBlock>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rdi,%rbp
movslq %esi,%rbx
lea    (%rdi,%rbx,8),%r15
mov    %edx,%edi
mov    %r15,%rsi
call   1030 <requestMemoryBlock@plt>
mov    0x0(%rbp,%rbx,8),%rdi
call   1050 <isNullPointer@plt>
test   %eax,%eax
je     1167 <initializeMemoryBlock+0x37>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15),%rdi
xor    %esi,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <memset@plt>

LLVM IR (-O0):
define void @initializeMemoryBlock(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = load i8**, i8*** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = call i32 @requestMemoryBlock(i32 %7, i8** %11)
%13 = load i8**, i8*** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @isNullPointer(i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %3
%21 = load i8**, i8*** %4
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = load i32, i32* %6
%27 = call i32 @memset(i8* %25, i32 0, i32 %26)
br label %28
28: ; preds = %20, %3
ret void
}

LLVM IR (-O2):
define void @initializeMemoryBlock(i8** %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i8*, i8** %0, i64 %4
%6 = tail call i32 @requestMemoryBlock(i32 %2, i8** %5)
%7 = load i8*, i8** %5
%8 = tail call i32 @isNullPointer(i8* %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = tail call i32 @memset(i8* %11, i32 0, i32 %2)
br label %13
13: ; preds = %10, %3
ret void
}