#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *memalign(int, size_t);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ stderr;
char *ramTest_alloc(size_t numBlocks, size_t blockSize) {
  char *data;
  {
    data = memalign(
        4096, (((size_t)((numBlocks * blockSize) * (1))) / 4096 + 1) * 4096);
    if (data)
      memset(data, 0,
             (((size_t)((numBlocks * blockSize) * (1))) / 4096 + 1) * 4096);
    if (!(data)) {
      fprintf(stderr, "ooom!!\n");
      abort();
    }
  };
  return data;
}


x86 assembly (clang, -O0):
<ramTest_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
imul   -0x10(%rbp),%rsi
shl    $0x0,%rsi
shr    $0xc,%rsi
add    $0x1,%rsi
shl    $0xc,%rsi
mov    $0x1000,%edi
call   1060 <memalign@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a6 <ramTest_alloc+0x66>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
imul   -0x10(%rbp),%rdx
shl    $0x0,%rdx
shr    $0xc,%rdx
add    $0x1,%rdx
shl    $0xc,%rdx
xor    %esi,%esi
call   1040 <memset@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11cd <ramTest_alloc+0x8d>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ramTest_alloc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
imul   %rsi,%rbx
add    $0x1000,%rbx
and    $0xfffffffffffff000,%rbx
mov    $0x1000,%edi
mov    %rbx,%rsi
call   1060 <memalign@plt>
test   %rax,%rax
je     1186 <ramTest_alloc+0x46>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1040 <memset@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [8 x i8] c"ooom!!\0A\00"
define i8* @ramTest_alloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = load i64, i64* %4
%8 = mul i64 %6, %7
%9 = mul i64 %8, 1
%10 = udiv i64 %9, 4096
%11 = add i64 %10, 1
%12 = mul i64 %11, 4096
%13 = call i8* @memalign(i32 4096, i64 %12)
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %26
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = load i64, i64* %3
%19 = load i64, i64* %4
%20 = mul i64 %18, %19
%21 = mul i64 %20, 1
%22 = udiv i64 %21, 4096
%23 = add i64 %22, 1
%24 = mul i64 %23, 4096
%25 = call i32 @memset(i8* %17, i32 0, i64 %24)
br label %26
26: ; preds = %16, %2
%27 = load i8*, i8** %5
%28 = icmp ne i8* %27, null
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%32 = call i32 (...) @abort()
unreachable
33: ; preds = %26
%34 = load i8*, i8** %5
ret i8* %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"ooom!!\0A\00"
define i8* @ramTest_alloc(i64 %0, i64 %1) {
%3 = mul i64 %1, %0
%4 = add i64 %3, 4096
%5 = and i64 %4, -4096
%6 = tail call align 4096 i8* @memalign(i32 4096, i64 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @memset(i8* %6, i32 0, i64 %5)
ret i8* %6
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 (...) @abort()
unreachable
}