#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 */
scalar_t__ safe_malloc(int);
int **alloc_mat2D_int(int **mat2D_int, int x, int y) {
  unsigned int i;
  mat2D_int = (int **)safe_malloc(x * sizeof(int *));
  for (i = 0; i < x; ++i)
    mat2D_int[i] = (int *)safe_malloc(y * sizeof(int));
  return mat2D_int;
}


x86 assembly (clang, -O0):
<alloc_mat2D_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <safe_malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1173 <alloc_mat2D_int+0x63>
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <safe_malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <alloc_mat2D_int+0x2c>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_mat2D_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%r14d
lea    0x0(,%r14,8),%edi
call   1030 <safe_malloc@plt>
mov    %rax,%r12
test   %r14d,%r14d
je     1155 <alloc_mat2D_int+0x45>
shl    $0x2,%r15d
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15d,%edi
call   1030 <safe_malloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <alloc_mat2D_int+0x30>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32** @alloc_mat2D_int(i32** %0, i32 %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32** %0, i32*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call i64 @safe_malloc(i32 %11)
%13 = inttoptr i64 %12 to i32**
store i32** %13, i32*** %4
store i32 0, i32* %7
br label %14
14: ; preds = %29, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 4
%22 = trunc i64 %21 to i32
%23 = call i64 @safe_malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
%25 = load i32**, i32*** %4
%26 = load i32, i32* %7
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i32*, i32** %25, i64 %27
store i32* %24, i32** %28
br label %29
29: ; preds = %18
%30 = load i32, i32* %7
%31 = add i32 %30, 1
store i32 %31, i32* %7
br label %14
32: ; preds = %14
%33 = load i32**, i32*** %4
ret i32** %33
}

LLVM IR (-O2):
define i32** @alloc_mat2D_int(i32** nocapture readnone %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 3
%5 = tail call i64 @safe_malloc(i32 %4)
%6 = inttoptr i64 %5 to i32**
%7 = icmp eq i32 %1, 0
br i1 %7, label %18, label %8
8: ; preds = %3
%9 = shl i32 %2, 2
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %16, %11 ]
%13 = tail call i64 @safe_malloc(i32 %9)
%14 = inttoptr i64 %13 to i32*
%15 = getelementptr inbounds i32*, i32** %6, i64 %12
store i32* %14, i32** %15
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %3
ret i32** %6
}