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


x86 assembly (clang, -O0):
<dmatrix>:
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,-0x30(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    119d <dmatrix+0x6d>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x40(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
imul   -0x38(%rbp),%rdi
add    $0x1,%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    120f <dmatrix+0xdf>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x8,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
xor    %esi,%esi
sub    %rdi,%rsi
shl    $0x3,%rsi
add    %rsi,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     1295 <dmatrix+0x165>
mov    -0x40(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x40(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    124f <dmatrix+0x11f>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,0x10(%rsp)
sub    %rdi,%r14
mov    %rcx,%r15
mov    %rdx,0x20(%rsp)
sub    %rdx,%r15
add    $0x1,%r15
lea    0x10(,%r14,8),%rdi
add    $0x1,%r14
call   1050 <malloc@plt>
mov    %rax,%r13
test   %rax,%rax
jne    118c <dmatrix+0x5c>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
lea    0x0(,%rbx,8),%rax
mov    %r13,%rbp
sub    %rax,%rbp
lea    0x8(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    %r15,0x18(%rsp)
imul   %r15,%r14
add    $0x1,%r14
mov    %r14,%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,0x8(%rbp,%rbx,8)
test   %rax,%rax
mov    %rbx,%r15
mov    0x8(%rsp),%rbx
jne    11e8 <dmatrix+0xb8>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx,%r15,8),%rax
mov    0x20(%rsp),%r11
lea    0x0(,%r11,8),%r8
mov    %rax,%rdx
sub    %r8,%rdx
add    $0x8,%rdx
mov    %rdx,(%rbx,%r15,8)
mov    0x10(%rsp),%rbp
cmp    %r15,%rbp
mov    0x18(%rsp),%r14
jle    1309 <dmatrix+0x1d9>
mov    %ebp,%edi
sub    %r15d,%edi
mov    %r15,%r9
not    %r9
add    %rbp,%r9
and    $0x7,%rdi
je     1275 <dmatrix+0x145>
mov    %rbx,%r10
lea    0x0(,%r12,8),%rcx
sub    %r8,%rcx
add    $0x8,%rcx
mov    %r12,%rbx
sub    %r11,%rbx
sub    %r11,%rbx
lea    (%rax,%rbx,8),%rsi
add    $0x10,%rsi
xor    %eax,%eax
nop
mov    %rsi,0x10(%r13,%rax,8)
add    $0x1,%rax
add    %rcx,%rdx
add    %rcx,%rsi
cmp    %rax,%rdi
jne    1250 <dmatrix+0x120>
add    %r15,%rax
mov    %r10,%rbx
cmp    $0x7,%r9
jae    1282 <dmatrix+0x152>
jmp    1309 <dmatrix+0x1d9>
mov    %r15,%rax
cmp    $0x7,%r9
jb     1309 <dmatrix+0x1d9>
lea    (%rdx,%r14,8),%rdx
mov    %r12,%rsi
shl    $0x6,%rsi
shl    $0x6,%r11
sub    %r11,%rsi
add    $0x40,%rsi
mov    $0x9,%ecx
sub    %r15,%rcx
lea    0x0(,%rcx,8),%rdi
add    %r13,%rdi
shl    $0x3,%r12
sub    %r8,%r12
add    $0x8,%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rdx,-0x38(%rdi,%rax,8)
lea    (%rdx,%r12,1),%rcx
mov    %rcx,-0x30(%rdi,%rax,8)
add    %r12,%rcx
mov    %rcx,-0x28(%rdi,%rax,8)
add    %r12,%rcx
mov    %rcx,-0x20(%rdi,%rax,8)
add    %r12,%rcx
mov    %rcx,-0x18(%rdi,%rax,8)
add    %r12,%rcx
mov    %rcx,-0x10(%rdi,%rax,8)
add    %r12,%rcx
mov    %rcx,-0x8(%rdi,%rax,8)
add    %r12,%rcx
mov    %rcx,(%rdi,%rax,8)
add    $0x8,%rax
add    %rsi,%rdx
cmp    %rax,%rbp
jne    12c0 <dmatrix+0x190>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"allocation failure 1 in matrix()\00"
@.str.1 = [43 x i8] c"allocation failure 2 in matrix()for double\00"
define double** @dmatrix(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 i64
%12 = alloca double**
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%13 = load i64, i64* %6
%14 = load i64, i64* %5
%15 = sub nsw i64 %13, %14
%16 = add nsw i64 %15, 1
store i64 %16, i64* %10
%17 = load i64, i64* %8
%18 = load i64, i64* %7
%19 = sub nsw i64 %17, %18
%20 = add nsw i64 %19, 1
store i64 %20, i64* %11
%21 = load i64, i64* %10
%22 = add nsw i64 %21, 1
%23 = mul i64 %22, 8
%24 = call i64 @malloc(i64 %23)
%25 = inttoptr i64 %24 to double**
store double** %25, double*** %12
%26 = load double**, double*** %12
%27 = icmp ne double** %26, null
br i1 %27, label %31, label %28
28: ; preds = %4
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %28, %4
%32 = load double**, double*** %12
%33 = getelementptr inbounds double*, double** %32, i64 1
store double** %33, double*** %12
%34 = load i64, i64* %5
%35 = load double**, double*** %12
%36 = sub i64 0, %34
%37 = getelementptr inbounds double*, double** %35, i64 %36
store double** %37, double*** %12
%38 = load i64, i64* %10
%39 = load i64, i64* %11
%40 = mul nsw i64 %38, %39
%41 = add nsw i64 %40, 1
%42 = call i64 @calloc(i64 %41, i32 8)
%43 = inttoptr i64 %42 to double*
%44 = load double**, double*** %12
%45 = load i64, i64* %5
%46 = getelementptr inbounds double*, double** %44, i64 %45
store double* %43, double** %46
%47 = load double**, double*** %12
%48 = load i64, i64* %5
%49 = getelementptr inbounds double*, double** %47, i64 %48
%50 = load double*, double** %49
%51 = icmp ne double* %50, null
br i1 %51, label %55, label %52
52: ; preds = %31
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %55
55: ; preds = %52, %31
%56 = load double**, double*** %12
%57 = load i64, i64* %5
%58 = getelementptr inbounds double*, double** %56, i64 %57
%59 = load double*, double** %58
%60 = getelementptr inbounds double, double* %59, i64 1
store double* %60, double** %58
%61 = load i64, i64* %7
%62 = load double**, double*** %12
%63 = load i64, i64* %5
%64 = getelementptr inbounds double*, double** %62, i64 %63
%65 = load double*, double** %64
%66 = sub i64 0, %61
%67 = getelementptr inbounds double, double* %65, i64 %66
store double* %67, double** %64
%68 = load i64, i64* %5
%69 = add nsw i64 %68, 1
store i64 %69, i64* %9
br label %70
70: ; preds = %85, %55
%71 = load i64, i64* %9
%72 = load i64, i64* %6
%73 = icmp sle i64 %71, %72
br i1 %73, label %74, label %88
74: ; preds = %70
%75 = load double**, double*** %12
%76 = load i64, i64* %9
%77 = sub nsw i64 %76, 1
%78 = getelementptr inbounds double*, double** %75, i64 %77
%79 = load double*, double** %78
%80 = load i64, i64* %11
%81 = getelementptr inbounds double, double* %79, i64 %80
%82 = load double**, double*** %12
%83 = load i64, i64* %9
%84 = getelementptr inbounds double*, double** %82, i64 %83
store double* %81, double** %84
br label %85
85: ; preds = %74
%86 = load i64, i64* %9
%87 = add nsw i64 %86, 1
store i64 %87, i64* %9
br label %70
88: ; preds = %70
%89 = load double**, double*** %12
ret double** %89
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"allocation failure 1 in matrix()\00"
@.str.1 = [43 x i8] c"allocation failure 2 in matrix()for double\00"
define double** @dmatrix(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = sub nsw i64 %1, %0
%6 = add nsw i64 %5, 1
%7 = sub nsw i64 %3, %2
%8 = add nsw i64 %7, 1
%9 = shl i64 %5, 3
%10 = add i64 %9, 16
%11 = tail call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to double**
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %4
%18 = getelementptr inbounds double*, double** %12, i64 1
%19 = sub i64 0, %0
%20 = getelementptr inbounds double*, double** %18, i64 %19
%21 = mul nsw i64 %8, %6
%22 = add nsw i64 %21, 1
%23 = tail call i64 @calloc(i64 %22, i32 8)
%24 = inttoptr i64 %23 to double*
%25 = getelementptr inbounds double*, double** %20, i64 %0
store double* %24, double** %25
%26 = icmp eq i64 %23, 0
br i1 %26, label %27, label %31
27: ; preds = %17
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%30 = load double*, double** %25
br label %31
31: ; preds = %27, %17
%32 = phi double* [ %30, %27 ], [ %24, %17 ]
%33 = getelementptr inbounds double, double* %32, i64 1
%34 = sub i64 0, %2
%35 = getelementptr inbounds double, double* %33, i64 %34
store double* %35, double** %25
%36 = icmp sgt i64 %1, %0
br i1 %36, label %37, label %84
37: ; preds = %31
%38 = sub i64 %1, %0
%39 = xor i64 %0, -1
%40 = add i64 %39, %1
%41 = and i64 %38, 7
%42 = icmp eq i64 %41, 0
br i1 %42, label %52, label %43
43: ; preds = %37, %43
%44 = phi double* [ %48, %43 ], [ %35, %37 ]
%45 = phi i64 [ %47, %43 ], [ %0, %37 ]
%46 = phi i64 [ %50, %43 ], [ 0, %37 ]
%47 = add nsw i64 %45, 1
%48 = getelementptr inbounds double, double* %44, i64 %8
%49 = getelementptr inbounds double*, double** %20, i64 %47
store double* %48, double** %49
%50 = add i64 %46, 1
%51 = icmp eq i64 %50, %41
br i1 %51, label %52, label %43
52: ; preds = %43, %37
%53 = phi double* [ %35, %37 ], [ %48, %43 ]
%54 = phi i64 [ %0, %37 ], [ %47, %43 ]
%55 = icmp ult i64 %40, 7
br i1 %55, label %84, label %56
56: ; preds = %52, %56
%57 = phi double* [ %81, %56 ], [ %53, %52 ]
%58 = phi i64 [ %80, %56 ], [ %54, %52 ]
%59 = add nsw i64 %58, 1
%60 = getelementptr inbounds double, double* %57, i64 %8
%61 = getelementptr inbounds double*, double** %20, i64 %59
store double* %60, double** %61
%62 = add nsw i64 %58, 2
%63 = getelementptr inbounds double, double* %60, i64 %8
%64 = getelementptr inbounds double*, double** %20, i64 %62
store double* %63, double** %64
%65 = add nsw i64 %58, 3
%66 = getelementptr inbounds double, double* %63, i64 %8
%67 = getelementptr inbounds double*, double** %20, i64 %65
store double* %66, double** %67
%68 = add nsw i64 %58, 4
%69 = getelementptr inbounds double, double* %66, i64 %8
%70 = getelementptr inbounds double*, double** %20, i64 %68
store double* %69, double** %70
%71 = add nsw i64 %58, 5
%72 = getelementptr inbounds double, double* %69, i64 %8
%73 = getelementptr inbounds double*, double** %20, i64 %71
store double* %72, double** %73
%74 = add nsw i64 %58, 6
%75 = getelementptr inbounds double, double* %72, i64 %8
%76 = getelementptr inbounds double*, double** %20, i64 %74
store double* %75, double** %76
%77 = add nsw i64 %58, 7
%78 = getelementptr inbounds double, double* %75, i64 %8
%79 = getelementptr inbounds double*, double** %20, i64 %77
store double* %78, double** %79
%80 = add nsw i64 %58, 8
%81 = getelementptr inbounds double, double* %78, i64 %8
%82 = getelementptr inbounds double*, double** %20, i64 %80
store double* %81, double** %82
%83 = icmp eq i64 %80, %1
br i1 %83, label %84, label %56
84: ; preds = %52, %56, %31
ret double** %20
}