#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);
double *mallocMatrizDouble(int cantFila, int cantCol) {
  int i;
  double *datos = ((double *)malloc(cantFila * cantCol * sizeof(double)));
  if (datos == NULL) {
    return NULL;
  } else {
    for (i = 0; i < cantFila * cantCol; i++) {
      datos[i] = 0.0;
    }
  }
  return datos;
}


x86 assembly (clang, -O0):
<mallocMatrizDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    114e <mallocMatrizDouble+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    1192 <mallocMatrizDouble+0x82>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1185 <mallocMatrizDouble+0x75>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <mallocMatrizDouble+0x45>
jmp    118a <mallocMatrizDouble+0x7a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mallocMatrizDouble>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
imul   %esi,%ebx
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1153 <mallocMatrizDouble+0x33>
mov    %rax,%r14
test   %ebx,%ebx
jle    1156 <mallocMatrizDouble+0x36>
mov    %ebx,%edx
shl    $0x3,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
jmp    1156 <mallocMatrizDouble+0x36>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @mallocMatrizDouble(i32 %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = mul nsw i32 %8, %9
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 8
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to double*
store double* %15, double** %7
%16 = load double*, double** %7
%17 = icmp eq double* %16, null
br i1 %17, label %18, label %19
18: ; preds = %2
store double* null, double** %3
br label %37
19: ; preds = %2
store i32 0, i32* %6
br label %20
20: ; preds = %31, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = mul nsw i32 %22, %23
%25 = icmp slt i32 %21, %24
br i1 %25, label %26, label %34
26: ; preds = %20
%27 = load double*, double** %7
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
store double 0.000000e+00, double* %30
br label %31
31: ; preds = %26
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %20
34: ; preds = %20
br label %35
35: ; preds = %34
%36 = load double*, double** %7
store double* %36, double** %3
br label %37
37: ; preds = %35, %18
%38 = load double*, double** %3
ret double* %38
}

LLVM IR (-O2):
define double* @mallocMatrizDouble(i32 %0, i32 %1) {
%3 = mul nsw i32 %1, %0
%4 = shl i32 %3, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to double*
%7 = inttoptr i64 %5 to i8*
%8 = icmp eq i64 %5, 0
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = zext i32 %3 to i64
%13 = shl nuw nsw i64 %12, 3
br label %14
14: ; preds = %11, %9, %2
%15 = phi double* [ null, %2 ], [ %6, %9 ], [ %6, %11 ]
ret double* %15
}