#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(int);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ printf(char *);
char *alloc1D(int Ydim, int Xdim, int Size) {
  int i, Count;
  char *Data;
  Count = Xdim * Ydim;
  if ((Data = (char *)malloc((unsigned)(Count * Size))) == NULL) {
    printf("Could not allocate image buffer");
    exit(1);
  };
  ;
  for (i = 0; i < Count * Size; i++)
    Data[i] = 0;
  return (Data);
}


x86 assembly (clang, -O0):
<alloc1D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
imul   -0xc(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    117b <alloc1D+0x4b>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11ae <alloc1D+0x7e>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1182 <alloc1D+0x52>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc1D>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
imul   %esi,%ebp
imul   %edx,%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1174 <alloc1D+0x34>
mov    %rax,%rbx
test   %ebp,%ebp
jle    116a <alloc1D+0x2a>
mov    %ebp,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str = [32 x i8] c"Could not allocate image buffer\00"
define i8* @alloc1D(i32 %0, i32 %1, i32 %2) {
%4 = mul nsw i32 %1, %0
%5 = mul nsw i32 %4, %2
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i64 %6, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = icmp sgt i32 %5, 0
br i1 %10, label %11, label %16
11: ; preds = %9
%12 = zext i32 %5 to i64
br label %16
13: ; preds = %3
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %11, %9
ret i8* %7
}