#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(size_t);
int /*<<< orphan*/ nrerror(char *);
double **dmatrix_map(long nrl, long nrh, long ncl, long nch) {
  long nrow = nrh - nrl + 1, ncol = nch - ncl + 1;
  double **m;
  m = (double **)malloc((size_t)(nrow * sizeof(double *)));
  if (!m)
    nrerror("allocation failure 1 in dmatrix_map()");
  m -= nrl;
  return m;
}


x86 assembly (clang, -O0):
<dmatrix_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
sub    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1180 <dmatrix_map+0x60>
lea    0xe85(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x8(%rbp),%rdx
mov    -0x38(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmatrix_map>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
sub    %rdi,%rsi
lea    0x8(,%rsi,8),%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114b <dmatrix_map+0x2b>
lea    0xeba(%rip),%rdi
call   1030 <nrerror@plt>
shl    $0x3,%r14
sub    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c"allocation failure 1 in dmatrix_map()\00"
define double** @dmatrix_map(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca double**
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%12 = load i64, i64* %6
%13 = load i64, i64* %5
%14 = sub nsw i64 %12, %13
%15 = add nsw i64 %14, 1
store i64 %15, i64* %9
%16 = load i64, i64* %8
%17 = load i64, i64* %7
%18 = sub nsw i64 %16, %17
%19 = add nsw i64 %18, 1
store i64 %19, i64* %10
%20 = load i64, i64* %9
%21 = mul i64 %20, 8
%22 = call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to double**
store double** %23, double*** %11
%24 = load double**, double*** %11
%25 = icmp ne double** %24, null
br i1 %25, label %28, label %26
26: ; preds = %4
%27 = call i32 @nrerror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %4
%29 = load i64, i64* %5
%30 = load double**, double*** %11
%31 = sub i64 0, %29
%32 = getelementptr inbounds double*, double** %30, i64 %31
store double** %32, double*** %11
%33 = load double**, double*** %11
ret double** %33
}

LLVM IR (-O2):
@.str = [38 x i8] c"allocation failure 1 in dmatrix_map()\00"
define double** @dmatrix_map(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = sub nsw i64 %1, %0
%6 = shl i64 %5, 3
%7 = add i64 %6, 8
%8 = tail call i64 @malloc(i64 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @nrerror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %4
%13 = inttoptr i64 %8 to double**
%14 = sub i64 0, %0
%15 = getelementptr inbounds double*, double** %13, i64 %14
ret double** %15
}