#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__ malloc(int const);
int **matrix_int_calloc(const int dimension1, const int dimension2) {
  int i, j;
  int **Matrix;
  Matrix = (int **)malloc(dimension1 * sizeof(int *));
  for (i = 0; i < dimension1; i++) {
    Matrix[i] = (int *)malloc(dimension2 * sizeof(int));
    for (j = 0; j < dimension2; j++) {
      Matrix[i][j] = 0;
    }
  }
  return Matrix;
}


x86 assembly (clang, -O0):
<matrix_int_calloc>:
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,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ad <matrix_int_calloc+0x9d>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119a <matrix_int_calloc+0x8a>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1169 <matrix_int_calloc+0x59>
jmp    119f <matrix_int_calloc+0x8f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <matrix_int_calloc+0x28>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_int_calloc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r13
test   %ebx,%ebx
jle    118a <matrix_int_calloc+0x6a>
lea    0x0(,%r14,4),%r12d
mov    %r14d,%r15d
shl    $0x2,%r15
mov    %ebx,%ebx
xor    %ebp,%ebp
jmp    1169 <matrix_int_calloc+0x49>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     118a <matrix_int_calloc+0x6a>
mov    %r12d,%edi
call   1040 <malloc@plt>
mov    %rax,0x0(%r13,%rbp,8)
test   %r14d,%r14d
jle    1160 <matrix_int_calloc+0x40>
mov    %rax,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <memset@plt>
jmp    1160 <matrix_int_calloc+0x40>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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