#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_FAILURE;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ malloc(int);
int **makeMap(int rows, int cols) {
  int **map = (int **)malloc(sizeof(int *) * rows);
  if (map == NULL)
    exit(EXIT_FAILURE);
  for (int i = 0; i < rows; i++) {
    map[i] = (int *)calloc(sizeof(int), cols);
    if (map[i] == NULL)
      exit(EXIT_FAILURE);
  }
  return map;
}


x86 assembly (clang, -O0):
<makeMap>:
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   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116a <makeMap+0x3a>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cd <makeMap+0x9d>
mov    -0x8(%rbp),%esi
mov    $0x4,%edi
call   1030 <calloc@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    11ba <makeMap+0x8a>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11bf <makeMap+0x8f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <makeMap+0x41>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeMap>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     118b <makeMap+0x5b>
mov    %rax,%r12
test   %r14d,%r14d
jle    117f <makeMap+0x4f>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    $0x4,%edi
mov    %r15d,%esi
call   1030 <calloc@plt>
mov    %rax,(%r12,%rbx,8)
test   %rax,%rax
je     118b <makeMap+0x5b>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <makeMap+0x30>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i32** @makeMap(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 i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32**
store i32** %12, i32*** %5
%13 = load i32**, i32*** %5
%14 = icmp eq i32** %13, null
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
store i32 0, i32* %6
br label %19
19: ; preds = %41, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %3
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %44
23: ; preds = %19
%24 = load i32, i32* %4
%25 = call i64 @calloc(i32 4, i32 %24)
%26 = inttoptr i64 %25 to i32*
%27 = load i32**, i32*** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32*, i32** %27, i64 %29
store i32* %26, i32** %30
%31 = load i32**, i32*** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32*, i32** %31, i64 %33
%35 = load i32*, i32** %34
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %23
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %23
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %19
44: ; preds = %19
%45 = load i32**, i32*** %5
ret i32** %45
}

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