#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__ calloc(int, int);
int /*<<< orphan*/ fatalerr(char *, int, int);
extern double *zeros(int n, int m) {
  double *p;
  if (n <= 0 || m <= 0) {
    return NULL;
  }
  if (!(p = (double *)calloc(sizeof(double), n * m))) {
    fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m);
  }
  return p;
}


x86 assembly (clang, -O0):
<zeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1142 <zeros+0x22>
cmpl   $0x0,-0x10(%rbp)
jg     114f <zeros+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    1188 <zeros+0x68>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
mov    $0x8,%edi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1180 <zeros+0x60>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe85(%rip),%rdi
call   1030 <fatalerr@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zeros>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
test   %edi,%edi
jle    115c <zeros+0x3c>
mov    %esi,%r14d
test   %esi,%esi
jle    115c <zeros+0x3c>
mov    %edi,%ebp
mov    %r14d,%esi
imul   %edi,%esi
mov    $0x8,%edi
call   1040 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    115c <zeros+0x3c>
lea    0xeae(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <fatalerr@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"matrix memory allocation error: n=%d,m=%d\0A\00"
define double* @zeros(i32 %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store double* null, double** %3
br label %26
13: ; preds = %9
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = mul nsw i32 %14, %15
%17 = call i64 @calloc(i32 8, i32 %16)
%18 = inttoptr i64 %17 to double*
store double* %18, double** %6
%19 = icmp ne double* %18, null
br i1 %19, label %24, label %20
20: ; preds = %13
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = call i32 @fatalerr(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22)
br label %24
24: ; preds = %20, %13
%25 = load double*, double** %6
store double* %25, double** %3
br label %26
26: ; preds = %24, %12
%27 = load double*, double** %3
ret double* %27
}

LLVM IR (-O2):
@.str = [43 x i8] c"matrix memory allocation error: n=%d,m=%d\0A\00"
define double* @zeros(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 1
%4 = icmp slt i32 %1, 1
%5 = or i1 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = mul nsw i32 %1, %0
%8 = tail call i64 @calloc(i32 8, i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = icmp eq i64 %8, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @fatalerr(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %13
13: ; preds = %6, %11, %2
%14 = phi double* [ null, %2 ], [ %9, %11 ], [ %9, %6 ]
ret double* %14
}