#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 */
void *malloc(int);
int /*<<< orphan*/ matriz_ponteiro(int **, int, int);
int main() {
  int **mtr = malloc(3 * sizeof(*mtr));
  for (int lin = 0, cont = 0; lin < 3; lin++) {
    mtr[lin] = malloc(4 * sizeof(*mtr[lin]));
    for (int col = 0; col < 4; col++)
      mtr[lin][col] = cont++;
  }
  matriz_ponteiro(mtr, 3, 4);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11be <main+0x9e>
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11ab <main+0x8b>
mov    -0x18(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1175 <main+0x55>
jmp    11b0 <main+0x90>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <main+0x2b>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1030 <matriz_ponteiro@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
movaps 0xebe(%rip),%xmm0
movups %xmm0,(%rax)
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%rbx)
movaps 0xeb6(%rip),%xmm0
movups %xmm0,(%rax)
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,0x10(%rbx)
movaps 0xeae(%rip),%xmm0
movups %xmm0,(%rax)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1030 <matriz_ponteiro@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call dereferenceable_or_null(24) i8* @malloc(i32 24)
%2 = bitcast i8* %1 to i32**
%3 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%4 = bitcast i8* %1 to i8**
store i8* %3, i8** %4
%5 = bitcast i8* %3 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %5
%6 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%7 = getelementptr inbounds i32*, i32** %2, i64 1
%8 = bitcast i32** %7 to i8**
store i8* %6, i8** %8
%9 = bitcast i8* %6 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %9
%10 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%11 = getelementptr inbounds i32*, i32** %2, i64 2
%12 = bitcast i32** %11 to i8**
store i8* %10, i8** %12
%13 = bitcast i8* %10 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %13
%14 = tail call i32 @matriz_ponteiro(i32** %2, i32 3, i32 4)
ret i32 0
}