#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);
void alocaMatriz(int **matriz, int lin, int col) {
  matriz = (int **)malloc(lin * sizeof(int **));
  for (int i = 0; i < col; i++)
    matriz[i] = (int *)malloc(col * sizeof(int));
}


x86 assembly (clang, -O0):
<alocaMatriz>:
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 <malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1174 <alocaMatriz+0x64>
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <alocaMatriz+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alocaMatriz>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
lea    0x0(,%rsi,8),%edi
call   1030 <malloc@plt>
test   %r14d,%r14d
jle    1155 <alocaMatriz+0x45>
mov    %rax,%r15
mov    %r14d,%ebp
shl    $0x2,%r14d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
call   1030 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <alocaMatriz+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @alocaMatriz(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 @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* %6
%17 = icmp slt 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 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
%25 = load i32**, i32*** %4
%26 = load i32, i32* %7
%27 = sext 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 nsw i32 %30, 1
store i32 %31, i32* %7
br label %14
32: ; preds = %14
ret void
}

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