#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*/ NRerror(char *);
scalar_t__ malloc(unsigned int);
double ***D3dmatrix(int nrl, int nrh, int ncl, int nch, int nzl, int nzh) {
  int i, j;
  double ***m;
  m = (double ***)malloc((unsigned)(nrh - nrl + 1) * sizeof(double *));
  if (!m)
    NRerror("alloc failure 1 in 3Ddmatrix()");
  m -= nrl;
  for (i = nrl; i <= nrh; i++) {
    m[i] = (double **)malloc((unsigned)(nch - ncl + 1) * sizeof(double *));
    if (!m[i])
      NRerror("alloc failure 2 in 3Dmatrix()");
    m[i] -= ncl;
    for (j = ncl; j <= nch; j++) {
      m[i][j] = (double *)malloc((unsigned)(nzh - nzl + 1) * sizeof(double));
      if (!m[i][j])
        NRerror("alloc failure 3 in 3Ddmatrix()");
      m[i][j] -= nzl;
    }
  }
  return m;
}


x86 assembly (clang, -O0):
<D3dmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%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,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116d <D3dmatrix+0x4d>
lea    0xe98(%rip),%rdi
call   1030 <NRerror@plt>
mov    -0x4(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12b0 <D3dmatrix+0x190>
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    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11dd <D3dmatrix+0xbd>
lea    0xe47(%rip),%rdi
call   1030 <NRerror@plt>
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x1c(%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    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     129d <D3dmatrix+0x17d>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1265 <D3dmatrix+0x145>
lea    0xddd(%rip),%rdi
call   1030 <NRerror@plt>
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%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    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1205 <D3dmatrix+0xe5>
jmp    12a2 <D3dmatrix+0x182>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118d <D3dmatrix+0x6d>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<D3dmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r14d
mov    %r8d,%r13d
mov    %ecx,0x4(%rsp)
mov    %edx,(%rsp)
mov    %esi,%r12d
mov    %edi,%ebx
mov    %esi,%eax
sub    %edi,%eax
lea    0x8(,%rax,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1164 <D3dmatrix+0x44>
lea    0xea1(%rip),%rdi
call   1030 <NRerror@plt>
movslq %ebx,%r15
lea    0x0(,%r15,8),%rax
sub    %rax,%rbp
cmp    %ebx,%r12d
jge    1189 <D3dmatrix+0x69>
mov    %rbp,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rsp),%eax
mov    %eax,%ecx
mov    (%rsp),%eax
sub    %eax,%ecx
lea    0x8(,%rcx,8),%edx
mov    %edx,0x8(%rsp)
cltq
mov    %rax,0x10(%rsp)
neg    %rax
mov    %rax,0x20(%rsp)
sub    %r13d,%r14d
lea    0x8(,%r14,8),%ebx
movslq %r13d,%r13
neg    %r13
add    $0x1,%r12d
add    $0x1,%ecx
mov    %rcx,0x18(%rsp)
mov    %r12d,0xc(%rsp)
jmp    11ee <D3dmatrix+0xce>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r15
mov    0xc(%rsp),%r12d
cmp    %r15d,%r12d
je     1177 <D3dmatrix+0x57>
mov    0x8(%rsp),%edi
call   1040 <malloc@plt>
mov    %rax,0x0(%rbp,%r15,8)
test   %rax,%rax
jne    1212 <D3dmatrix+0xf2>
lea    0xe17(%rip),%rdi
call   1030 <NRerror@plt>
mov    0x0(%rbp,%r15,8),%rax
mov    0x20(%rsp),%rcx
lea    (%rax,%rcx,8),%rax
mov    %rax,0x0(%rbp,%r15,8)
mov    (%rsp),%eax
cmp    %eax,0x4(%rsp)
jl     11e0 <D3dmatrix+0xc0>
mov    0x18(%rsp),%rax
mov    %eax,%r12d
mov    0x10(%rsp),%r14
jmp    1252 <D3dmatrix+0x132>
nopl   0x0(%rax,%rax,1)
lea    (%rcx,%r13,8),%rcx
mov    %rcx,(%rax,%r14,8)
add    $0x1,%r14
add    $0xffffffff,%r12d
je     11e0 <D3dmatrix+0xc0>
mov    %ebx,%edi
call   1040 <malloc@plt>
mov    0x0(%rbp,%r15,8),%rcx
mov    %rax,(%rcx,%r14,8)
mov    0x0(%rbp,%r15,8),%rax
mov    (%rax,%r14,8),%rcx
test   %rcx,%rcx
jne    1240 <D3dmatrix+0x120>
lea    0xdc6(%rip),%rdi
call   1030 <NRerror@plt>
mov    0x0(%rbp,%r15,8),%rax
mov    (%rax,%r14,8),%rcx
jmp    1240 <D3dmatrix+0x120>

LLVM IR (-O0):
@.str = [31 x i8] c"alloc failure 1 in 3Ddmatrix()\00"
@.str.1 = [30 x i8] c"alloc failure 2 in 3Dmatrix()\00"
@.str.2 = [31 x i8] c"alloc failure 3 in 3Ddmatrix()\00"
define double*** @D3dmatrix(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double***
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = sub nsw i32 %16, %17
%19 = add nsw i32 %18, 1
%20 = zext i32 %19 to i64
%21 = mul i64 %20, 8
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to double***
store double*** %24, double**** %15
%25 = load double***, double**** %15
%26 = icmp ne double*** %25, null
br i1 %26, label %29, label %27
27: ; preds = %6
%28 = call i32 @NRerror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %6
%30 = load i32, i32* %7
%31 = load double***, double**** %15
%32 = sext i32 %30 to i64
%33 = sub i64 0, %32
%34 = getelementptr inbounds double**, double*** %31, i64 %33
store double*** %34, double**** %15
%35 = load i32, i32* %7
store i32 %35, i32* %13
br label %36
36: ; preds = %125, %29
%37 = load i32, i32* %13
%38 = load i32, i32* %8
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %128
40: ; preds = %36
%41 = load i32, i32* %10
%42 = load i32, i32* %9
%43 = sub nsw i32 %41, %42
%44 = add nsw i32 %43, 1
%45 = zext i32 %44 to i64
%46 = mul i64 %45, 8
%47 = trunc i64 %46 to i32
%48 = call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to double**
%50 = load double***, double**** %15
%51 = load i32, i32* %13
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double**, double*** %50, i64 %52
store double** %49, double*** %53
%54 = load double***, double**** %15
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double**, double*** %54, i64 %56
%58 = load double**, double*** %57
%59 = icmp ne double** %58, null
br i1 %59, label %62, label %60
60: ; preds = %40
%61 = call i32 @NRerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %60, %40
%63 = load i32, i32* %9
%64 = load double***, double**** %15
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double**, double*** %64, i64 %66
%68 = load double**, double*** %67
%69 = sext i32 %63 to i64
%70 = sub i64 0, %69
%71 = getelementptr inbounds double*, double** %68, i64 %70
store double** %71, double*** %67
%72 = load i32, i32* %9
store i32 %72, i32* %14
br label %73
73: ; preds = %121, %62
%74 = load i32, i32* %14
%75 = load i32, i32* %10
%76 = icmp sle i32 %74, %75
br i1 %76, label %77, label %124
77: ; preds = %73
%78 = load i32, i32* %12
%79 = load i32, i32* %11
%80 = sub nsw i32 %78, %79
%81 = add nsw i32 %80, 1
%82 = zext i32 %81 to i64
%83 = mul i64 %82, 8
%84 = trunc i64 %83 to i32
%85 = call i64 @malloc(i32 %84)
%86 = inttoptr i64 %85 to double*
%87 = load double***, double**** %15
%88 = load i32, i32* %13
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double**, double*** %87, i64 %89
%91 = load double**, double*** %90
%92 = load i32, i32* %14
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double*, double** %91, i64 %93
store double* %86, double** %94
%95 = load double***, double**** %15
%96 = load i32, i32* %13
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double**, double*** %95, i64 %97
%99 = load double**, double*** %98
%100 = load i32, i32* %14
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double*, double** %99, i64 %101
%103 = load double*, double** %102
%104 = icmp ne double* %103, null
br i1 %104, label %107, label %105
105: ; preds = %77
%106 = call i32 @NRerror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %107
107: ; preds = %105, %77
%108 = load i32, i32* %11
%109 = load double***, double**** %15
%110 = load i32, i32* %13
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double**, double*** %109, i64 %111
%113 = load double**, double*** %112
%114 = load i32, i32* %14
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds double*, double** %113, i64 %115
%117 = load double*, double** %116
%118 = sext i32 %108 to i64
%119 = sub i64 0, %118
%120 = getelementptr inbounds double, double* %117, i64 %119
store double* %120, double** %116
br label %121
121: ; preds = %107
%122 = load i32, i32* %14
%123 = add nsw i32 %122, 1
store i32 %123, i32* %14
br label %73
124: ; preds = %73
br label %125
125: ; preds = %124
%126 = load i32, i32* %13
%127 = add nsw i32 %126, 1
store i32 %127, i32* %13
br label %36
128: ; preds = %36
%129 = load double***, double**** %15
ret double*** %129
}

LLVM IR (-O2):
@.str = [31 x i8] c"alloc failure 1 in 3Ddmatrix()\00"
@.str.1 = [30 x i8] c"alloc failure 2 in 3Dmatrix()\00"
@.str.2 = [31 x i8] c"alloc failure 3 in 3Ddmatrix()\00"
define double*** @D3dmatrix(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = sub nsw i32 %1, %0
%8 = shl i32 %7, 3
%9 = add i32 %8, 8
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to double***
%12 = icmp eq i64 %10, 0
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @NRerror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %6
%16 = sext i32 %0 to i64
%17 = sub nsw i64 0, %16
%18 = getelementptr inbounds double**, double*** %11, i64 %17
%19 = icmp slt i32 %1, %0
br i1 %19, label %73, label %20
20: ; preds = %15
%21 = sub nsw i32 %3, %2
%22 = shl i32 %21, 3
%23 = add i32 %22, 8
%24 = sext i32 %2 to i64
%25 = sub nsw i64 0, %24
%26 = icmp slt i32 %3, %2
%27 = sub nsw i32 %5, %4
%28 = shl i32 %27, 3
%29 = add i32 %28, 8
%30 = sext i32 %4 to i64
%31 = sub nsw i64 0, %30
%32 = add i32 %3, 1
%33 = add i32 %1, 1
br label %34
34: ; preds = %20, %69
%35 = phi i64 [ %16, %20 ], [ %70, %69 ]
%36 = tail call i64 @malloc(i32 %23)
%37 = inttoptr i64 %36 to double**
%38 = getelementptr inbounds double**, double*** %18, i64 %35
store double** %37, double*** %38
%39 = icmp eq i64 %36, 0
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = tail call i32 @NRerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%42 = load double**, double*** %38
br label %43
43: ; preds = %40, %34
%44 = phi double** [ %42, %40 ], [ %37, %34 ]
%45 = getelementptr inbounds double*, double** %44, i64 %25
store double** %45, double*** %38
br i1 %26, label %69, label %46
46: ; preds = %43, %61
%47 = phi i64 [ %66, %61 ], [ %24, %43 ]
%48 = tail call i64 @malloc(i32 %29)
%49 = inttoptr i64 %48 to double*
%50 = load double**, double*** %38
%51 = getelementptr inbounds double*, double** %50, i64 %47
store double* %49, double** %51
%52 = load double**, double*** %38
%53 = getelementptr inbounds double*, double** %52, i64 %47
%54 = load double*, double** %53
%55 = icmp eq double* %54, null
br i1 %55, label %56, label %61
56: ; preds = %46
%57 = tail call i32 @NRerror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%58 = load double**, double*** %38
%59 = getelementptr inbounds double*, double** %58, i64 %47
%60 = load double*, double** %59
br label %61
61: ; preds = %56, %46
%62 = phi double* [ %60, %56 ], [ %54, %46 ]
%63 = phi double** [ %58, %56 ], [ %52, %46 ]
%64 = getelementptr inbounds double*, double** %63, i64 %47
%65 = getelementptr inbounds double, double* %62, i64 %31
store double* %65, double** %64
%66 = add nsw i64 %47, 1
%67 = trunc i64 %66 to i32
%68 = icmp eq i32 %32, %67
br i1 %68, label %69, label %46
69: ; preds = %61, %43
%70 = add nsw i64 %35, 1
%71 = trunc i64 %70 to i32
%72 = icmp eq i32 %33, %71
br i1 %72, label %73, label %34
73: ; preds = %69, %15
ret double*** %18
}