#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);
void *malloc(int);
int **Allocate_2D_Array(int iRow, int iColumn) {
  int **iNewArray = malloc(iRow * sizeof(int *));
  if (!iNewArray)
    exit(1);
  int i;
  for (i = 0; i < iRow; i++) {
    iNewArray[i] = malloc(iColumn * sizeof(int));
    if (!iNewArray[i])
      exit(1);
  }
  return iNewArray;
}


x86 assembly (clang, -O0):
<Allocate_2D_Array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1156 <Allocate_2D_Array+0x36>
mov    $0x1,%edi
call   1040 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b7 <Allocate_2D_Array+0x97>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11a4 <Allocate_2D_Array+0x84>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    11a9 <Allocate_2D_Array+0x89>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <Allocate_2D_Array+0x3d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Allocate_2D_Array>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     1186 <Allocate_2D_Array+0x66>
mov    %rax,%r12
test   %r14d,%r14d
jle    117a <Allocate_2D_Array+0x5a>
shl    $0x2,%r15d
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1030 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
test   %rax,%rax
je     1186 <Allocate_2D_Array+0x66>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <Allocate_2D_Array+0x40>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define i32** @Allocate_2D_Array(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 8
%10 = trunc i64 %9 to i32
%11 = call i8* @malloc(i32 %10)
%12 = bitcast i8* %11 to i32**
store i32** %12, i32*** %5
%13 = load i32**, i32*** %5
%14 = icmp ne i32** %13, null
br i1 %14, label %17, label %15
15: ; preds = %2
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
store i32 0, i32* %6
br label %18
18: ; preds = %42, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %45
22: ; preds = %18
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 4
%26 = trunc i64 %25 to i32
%27 = call i8* @malloc(i32 %26)
%28 = bitcast i8* %27 to i32*
%29 = load i32**, i32*** %5
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32*, i32** %29, i64 %31
store i32* %28, i32** %32
%33 = load i32**, i32*** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32*, i32** %33, i64 %35
%37 = load i32*, i32** %36
%38 = icmp ne i32* %37, null
br i1 %38, label %41, label %39
39: ; preds = %22
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %22
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %18
45: ; preds = %18
%46 = load i32**, i32*** %5
ret i32** %46
}

LLVM IR (-O2):
define noalias i32** @Allocate_2D_Array(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i8* @malloc(i32 %3)
%5 = bitcast i8* %4 to i32**
%6 = icmp eq i8* %4, null
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %25
9: ; preds = %7
%10 = shl i32 %1, 2
%11 = zext i32 %0 to i64
br label %16
12: ; preds = %2
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %16
%15 = icmp eq i64 %22, %11
br i1 %15, label %25, label %16
16: ; preds = %9, %14
%17 = phi i64 [ 0, %9 ], [ %22, %14 ]
%18 = tail call i8* @malloc(i32 %10)
%19 = getelementptr inbounds i32*, i32** %5, i64 %17
%20 = bitcast i32** %19 to i8**
store i8* %18, i8** %20
%21 = icmp eq i8* %18, null
%22 = add nuw nsw i64 %17, 1
br i1 %21, label %23, label %14
23: ; preds = %16
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %14, %7
ret i32** %5
}