#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*/ Visualizar(double *, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
main() {
  int elems = 6;
  double *m = (double *)malloc(elems * sizeof(double));
  if (m == NULL) {
    printf("Insuficiente memoria\n");
    return -1;
  }
  memset(m, 0, elems * sizeof(double));
  Visualizar(m, elems);
  free(m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119c <main+0x4c>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cd <main+0x7d>
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <Visualizar@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x30,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     118d <main+0x3d>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <Visualizar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    119e <main+0x4e>
lea    0xe6c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [21 x i8] c"Insuficiente memoria\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 48)
%2 = inttoptr i64 %1 to double*
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %10
6: ; preds = %0
%7 = tail call i32 @memset(double* %2, i32 0, i32 48)
%8 = tail call i32 @Visualizar(double* %2, i32 6)
%9 = tail call i32 @free(double* %2)
br label %10
10: ; preds = %6, %4
%11 = phi i32 [ -1, %4 ], [ 0, %6 ]
ret i32 %11
}