#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*/ fprintf(int /*<<< orphan*/, char *, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int *new_intarray(int size1, int size2) {
  int i;
  int *array, *ptr;
  array = (int *)malloc(sizeof(int) * size1 * size2);
  if (!array) {
    fprintf(stderr, "Insufficient memory for %dx%d data array.\n", size1,
            size2);
    return NULL;
  }
  ptr = array;
  for (i = 0; i < size1 * size2; i++, ptr++)
    *ptr = 0;
  return array;
}


x86 assembly (clang, -O0):
<new_intarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
movslq -0x10(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117c <new_intarray+0x5c>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11c9 <new_intarray+0xa9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11c1 <new_intarray+0xa1>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
jmp    118b <new_intarray+0x6b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_intarray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
mov    %edi,%ebp
imul   %esi,%ebp
lea    0x0(,%rbp,4),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     116c <new_intarray+0x3c>
mov    %rax,%rbx
test   %ebp,%ebp
jle    1189 <new_intarray+0x59>
mov    %ebp,%edx
shl    $0x2,%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
jmp    1189 <new_intarray+0x59>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Insufficient memory for %dx%d data array.\0A\00"
define i32* @new_intarray(i32 %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = mul i64 4, %10
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = mul i64 %11, %13
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = icmp ne i32* %18, null
br i1 %19, label %25, label %20
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
store i32* null, i32** %3
br label %42
25: ; preds = %2
%26 = load i32*, i32** %7
store i32* %26, i32** %8
store i32 0, i32* %6
br label %27
27: ; preds = %35, %25
%28 = load i32, i32* %6
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = mul nsw i32 %29, %30
%32 = icmp slt i32 %28, %31
br i1 %32, label %33, label %40
33: ; preds = %27
%34 = load i32*, i32** %8
store i32 0, i32* %34
br label %35
35: ; preds = %33
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
%38 = load i32*, i32** %8
%39 = getelementptr inbounds i32, i32* %38, i32 1
store i32* %39, i32** %8
br label %27
40: ; preds = %27
%41 = load i32*, i32** %7
store i32* %41, i32** %3
br label %42
42: ; preds = %40, %20
%43 = load i32*, i32** %3
ret i32* %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Insufficient memory for %dx%d data array.\0A\00"
define i32* @new_intarray(i32 %0, i32 %1) {
%3 = shl i32 %0, 2
%4 = mul i32 %3, %1
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i32*
%7 = inttoptr i64 %5 to i8*
%8 = icmp eq i64 %5, 0
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = mul i32 %1, %0
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = zext i32 %10 to i64
%14 = shl nuw nsw i64 %13, 2
br label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %18
18: ; preds = %12, %9, %15
%19 = phi i32* [ null, %15 ], [ %6, %9 ], [ %6, %12 ]
ret i32* %19
}