#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*/ dump_error(char *);
scalar_t__ malloc(unsigned int);
double **dmatrix(int nrl, int nrh, int ncl, int nch) {
  int i;
  double **m;
  m = (double **)malloc((unsigned)(nrh - nrl + 1) * sizeof(double *));
  if (!m)
    dump_error("allocation failure 1 in dmatrix()");
  m -= nrl;
  for (i = nrl; i <= nrh; i++) {
    m[i] = (double *)malloc((unsigned)(nch - ncl + 1) * sizeof(double));
    if (!m[i])
      dump_error("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),%eax
sub    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1165 <dmatrix+0x45>
lea    0xea0(%rip),%rdi
call   1030 <dump_error@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     1205 <dmatrix+0xe5>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@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    11d5 <dmatrix+0xb5>
lea    0xe52(%rip),%rdi
call   1030 <dump_error@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    1185 <dmatrix+0x65>
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,%r13d
mov    %edx,%r12d
mov    %esi,%r14d
mov    %edi,%ebp
mov    %esi,%eax
sub    %edi,%eax
lea    0x8(,%rax,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    115a <dmatrix+0x3a>
lea    0xeab(%rip),%rdi
call   1030 <dump_error@plt>
movslq %ebp,%rax
shl    $0x3,%rax
mov    %rbx,%rcx
sub    %rax,%rcx
mov    %rcx,(%rsp)
sub    %ebp,%r14d
jge    1183 <dmatrix+0x63>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
sub    %r12d,%r13d
lea    0x8(,%r13,8),%r13d
movslq %r12d,%rbp
neg    %rbp
add    $0x1,%r14d
xor    %r15d,%r15d
lea    0xe80(%rip),%r12
jmp    11c1 <dmatrix+0xa1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rax,%rbp,8),%rax
mov    %rax,(%rbx,%r15,8)
add    $0x1,%r15
cmp    %r15d,%r14d
je     1170 <dmatrix+0x50>
mov    %r13d,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx,%r15,8)
test   %rax,%rax
jne    11b0 <dmatrix+0x90>
mov    %r12,%rdi
call   1030 <dump_error@plt>
mov    (%rbx,%r15,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 = zext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double**
store double** %19, double*** %10
%20 = load double**, double*** %10
%21 = icmp ne double** %20, null
br i1 %21, label %24, label %22
22: ; preds = %4
%23 = call i32 @dump_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %4
%25 = load i32, i32* %5
%26 = load double**, double*** %10
%27 = sext i32 %25 to i64
%28 = sub i64 0, %27
%29 = getelementptr inbounds double*, double** %26, i64 %28
store double** %29, double*** %10
%30 = load i32, i32* %5
store i32 %30, i32* %9
br label %31
31: ; preds = %67, %24
%32 = load i32, i32* %9
%33 = load i32, i32* %6
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %70
35: ; preds = %31
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = sub nsw i32 %36, %37
%39 = add nsw i32 %38, 1
%40 = zext i32 %39 to i64
%41 = mul i64 %40, 8
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to double*
%45 = load double**, double*** %10
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double*, double** %45, i64 %47
store double* %44, double** %48
%49 = load double**, double*** %10
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double*, double** %49, i64 %51
%53 = load double*, double** %52
%54 = icmp ne double* %53, null
br i1 %54, label %57, label %55
55: ; preds = %35
%56 = call i32 @dump_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %57
57: ; preds = %55, %35
%58 = load i32, i32* %7
%59 = load double**, double*** %10
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double*, double** %59, i64 %61
%63 = load double*, double** %62
%64 = sext i32 %58 to i64
%65 = sub i64 0, %64
%66 = getelementptr inbounds double, double* %63, i64 %65
store double* %66, double** %62
br label %67
67: ; preds = %57
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %31
70: ; preds = %31
%71 = load double**, double*** %10
ret double** %71
}

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 nsw i32 %1, %0
%6 = shl i32 %5, 3
%7 = add i32 %6, 8
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double**
%10 = icmp eq i64 %8, 0
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @dump_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %4
%14 = sext i32 %0 to i64
%15 = sub nsw i64 0, %14
%16 = getelementptr inbounds double*, double** %9, i64 %15
%17 = icmp slt i32 %1, %0
br i1 %17, label %40, label %18
18: ; preds = %13
%19 = sub nsw i32 %3, %2
%20 = shl i32 %19, 3
%21 = add i32 %20, 8
%22 = sext i32 %2 to i64
%23 = sub nsw i64 0, %22
%24 = add i32 %1, 1
br label %25
25: ; preds = %18, %34
%26 = phi i64 [ %14, %18 ], [ %37, %34 ]
%27 = tail call i64 @malloc(i32 %21)
%28 = inttoptr i64 %27 to double*
%29 = getelementptr inbounds double*, double** %16, i64 %26
store double* %28, double** %29
%30 = icmp eq i64 %27, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = tail call i32 @dump_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%33 = load double*, double** %29
br label %34
34: ; preds = %31, %25
%35 = phi double* [ %33, %31 ], [ %28, %25 ]
%36 = getelementptr inbounds double, double* %35, i64 %23
store double* %36, double** %29
%37 = add nsw i64 %26, 1
%38 = trunc i64 %37 to i32
%39 = icmp eq i32 %24, %38
br i1 %39, label %40, label %25
40: ; preds = %34, %13
ret double** %16
}