#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*/ AsignarMem2D(double ***, int, int);
int /*<<< orphan*/ LiberarMem2D(double **, int);
int /*<<< orphan*/ Visualizar(double **, int, int);
int /*<<< orphan*/ printf(char *);
main() {
  int filas = 2, cols = 3;
  double **m = NULL;
  AsignarMem2D(&m, filas, cols);
  if (m == NULL) {
    printf("Insuficiente memoria\n");
    return -1;
  }
  Visualizar(m, filas, cols);
  LiberarMem2D(m, filas);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    -0x18(%rbp),%rdi
call   1030 <AsignarMem2D@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1197 <main+0x57>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b9 <main+0x79>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <Visualizar@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <LiberarMem2D@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1040 <AsignarMem2D@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     1185 <main+0x45>
mov    $0x2,%esi
mov    $0x3,%edx
call   1050 <Visualizar@plt>
mov    (%rsp),%rdi
mov    $0x2,%esi
call   1060 <LiberarMem2D@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Insuficiente memoria\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double**
store i32 0, i32* %1
store i32 2, i32* %2
store i32 3, i32* %3
store double** null, double*** %4
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = call i32 @AsignarMem2D(double*** %4, i32 %5, i32 %6)
%8 = load double**, double*** %4
%9 = icmp eq double** %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %20
12: ; preds = %0
%13 = load double**, double*** %4
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 @Visualizar(double** %13, i32 %14, i32 %15)
%17 = load double**, double*** %4
%18 = load i32, i32* %2
%19 = call i32 @LiberarMem2D(double** %17, i32 %18)
store i32 0, i32* %1
br label %20
20: ; preds = %12, %10
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@str = [21 x i8] c"Insuficiente memoria\00"
define i32 @main() {
%1 = alloca double**
%2 = bitcast double*** %1 to i8*
store double** null, double*** %1
%3 = call i32 @AsignarMem2D(double*** %1, i32 2, i32 3)
%4 = load double**, double*** %1
%5 = icmp eq double** %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %12
8: ; preds = %0
%9 = call i32 @Visualizar(double** %4, i32 2, i32 3)
%10 = load double**, double*** %1
%11 = call i32 @LiberarMem2D(double** %10, i32 2)
br label %12
12: ; preds = %8, %6
%13 = phi i32 [ -1, %6 ], [ 0, %8 ]
ret i32 %13
}