#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(unsigned int, int);
int /*<<< orphan*/ printf(char *);
double **dmatrix(int nrl, int nrh, int ncl, int nch) {
  int i;
  double **m;
  m = (double **)calloc((unsigned)(nrh - nrl + 1), sizeof(double *));
  if (!m)
    printf("allocation failure 1 in dmatrix()");
  m -= nrl;
  for (i = nrl; i <= nrh; i++) {
    m[i] = (double *)calloc((unsigned)(nch - ncl + 1), sizeof(double));
    if (!m[i])
      printf("allocation failure 2 in dmatrix()");
    m[i] -= ncl;
  }
  return m;
}


x86 assembly (clang, -O0):
<dmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sub    -0x4(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1162 <dmatrix+0x42>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ff <dmatrix+0xdf>
mov    -0x10(%rbp),%edi
sub    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11cf <dmatrix+0xaf>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq %esi,%rdi
xor    %esi,%esi
sub    %rdi,%rsi
shl    $0x3,%rsi
add    %rsi,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <dmatrix+0x62>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %esi,%r13d
mov    %edi,%r12d
mov    %esi,%r15d
sub    %edi,%r15d
add    $0x1,%r15d
mov    %r15d,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1161 <dmatrix+0x41>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
movslq %r12d,%rax
shl    $0x3,%rax
mov    %rbp,%rcx
sub    %rax,%rcx
mov    %rcx,(%rsp)
cmp    %r13d,%r12d
jle    118a <dmatrix+0x6a>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
sub    %ebx,%r14d
add    $0x1,%r14d
movslq %ebx,%r13
neg    %r13
xor    %ebx,%ebx
lea    0xe82(%rip),%r12
jmp    11c2 <dmatrix+0xa2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rax,%r13,8),%rax
mov    %rax,0x0(%rbp,%rbx,8)
add    $0x1,%rbx
cmp    %ebx,%r15d
je     1177 <dmatrix+0x57>
mov    %r14d,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,0x0(%rbp,%rbx,8)
test   %rax,%rax
jne    11b0 <dmatrix+0x90>
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x0(%rbp,%rbx,8),%rax
jmp    11b0 <dmatrix+0x90>

LLVM IR (-O0):
@.str = [34 x i8] c"allocation failure 1 in dmatrix()\00"
@.str.1 = [34 x i8] c"allocation failure 2 in dmatrix()\00"
define double** @dmatrix(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double**
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = sub nsw i32 %11, %12
%14 = add nsw i32 %13, 1
%15 = call i64 @calloc(i32 %14, i32 8)
%16 = inttoptr i64 %15 to double**
store double** %16, double*** %10
%17 = load double**, double*** %10
%18 = icmp ne double** %17, null
br i1 %18, label %21, label %19
19: ; preds = %4
%20 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %4
%22 = load i32, i32* %5
%23 = load double**, double*** %10
%24 = sext i32 %22 to i64
%25 = sub i64 0, %24
%26 = getelementptr inbounds double*, double** %23, i64 %25
store double** %26, double*** %10
%27 = load i32, i32* %5
store i32 %27, i32* %9
br label %28
28: ; preds = %61, %21
%29 = load i32, i32* %9
%30 = load i32, i32* %6
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %64
32: ; preds = %28
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = sub nsw i32 %33, %34
%36 = add nsw i32 %35, 1
%37 = call i64 @calloc(i32 %36, i32 8)
%38 = inttoptr i64 %37 to double*
%39 = load double**, double*** %10
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double*, double** %39, i64 %41
store double* %38, double** %42
%43 = load double**, double*** %10
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double*, double** %43, i64 %45
%47 = load double*, double** %46
%48 = icmp ne double* %47, null
br i1 %48, label %51, label %49
49: ; preds = %32
%50 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %49, %32
%52 = load i32, i32* %7
%53 = load double**, double*** %10
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double*, double** %53, i64 %55
%57 = load double*, double** %56
%58 = sext i32 %52 to i64
%59 = sub i64 0, %58
%60 = getelementptr inbounds double, double* %57, i64 %59
store double* %60, double** %56
br label %61
61: ; preds = %51
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %28
64: ; preds = %28
%65 = load double**, double*** %10
ret double** %65
}

LLVM IR (-O2):
@.str = [34 x i8] c"allocation failure 1 in dmatrix()\00"
@.str.1 = [34 x i8] c"allocation failure 2 in dmatrix()\00"
define double** @dmatrix(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sub i32 1, %0
%6 = add i32 %5, %1
%7 = tail call i64 @calloc(i32 %6, i32 8)
%8 = inttoptr i64 %7 to double**
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %4
%13 = sext i32 %0 to i64
%14 = sub nsw i64 0, %13
%15 = getelementptr inbounds double*, double** %8, i64 %14
%16 = icmp sgt i32 %0, %1
br i1 %16, label %38, label %17
17: ; preds = %12
%18 = sub i32 1, %2
%19 = add i32 %18, %3
%20 = sext i32 %2 to i64
%21 = sub nsw i64 0, %20
%22 = add i32 %1, 1
br label %23
23: ; preds = %17, %32
%24 = phi i64 [ %13, %17 ], [ %35, %32 ]
%25 = tail call i64 @calloc(i32 %19, i32 8)
%26 = inttoptr i64 %25 to double*
%27 = getelementptr inbounds double*, double** %15, i64 %24
store double* %26, double** %27
%28 = icmp eq i64 %25, 0
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%31 = load double*, double** %27
br label %32
32: ; preds = %29, %23
%33 = phi double* [ %31, %29 ], [ %26, %23 ]
%34 = getelementptr inbounds double, double* %33, i64 %21
store double* %34, double** %27
%35 = add nsw i64 %24, 1
%36 = trunc i64 %35 to i32
%37 = icmp eq i32 %22, %36
br i1 %37, label %38, label %23
38: ; preds = %32, %12
ret double** %15
}