#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
double **nr_matrix(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, "Memory failure in routine 'nr_matrix'.\n");
    exit(1);
  }
  m += 1;
  m -= nrl;
  m[nrl] = (double *)malloc((size_t)((nrow * ncol + 1) * sizeof(double)));
  if (!m[nrl]) {
    fprintf(stderr, "Memory failure in routine 'matrix'\n");
    exit(1);
  }
  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):
<nr_matrix>:
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   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11a7 <nr_matrix+0x77>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@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
shl    $0x3,%rdi
call   1040 <malloc@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    1222 <nr_matrix+0xf2>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@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     12a8 <nr_matrix+0x178>
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    1262 <nr_matrix+0x132>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nr_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r13
mov    %rsi,0x10(%rsp)
sub    %rdi,%r14
lea    0x10(,%r14,8),%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     12db <nr_matrix+0x1ab>
mov    %rax,%rbp
mov    %r15,%rcx
sub    %rbx,%rcx
add    $0x1,%rcx
shl    $0x3,%r14
lea    0x0(,%r13,8),%rax
mov    %rbp,%r12
sub    %rax,%r12
add    $0x8,%r14
mov    %rcx,0x8(%rsp)
imul   %rcx,%r14
add    $0x8,%r14
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,0x8(%r12,%r13,8)
test   %rax,%rax
je     12ed <nr_matrix+0x1bd>
add    $0x8,%r12
lea    0x0(,%rbx,8),%r8
mov    %rax,%rdx
sub    %r8,%rdx
add    $0x8,%rdx
mov    %rdx,(%r12,%r13,8)
mov    0x10(%rsp),%r14
cmp    %r13,%r14
jle    12c9 <nr_matrix+0x199>
mov    %rbx,%r11
mov    %r14d,%edi
sub    %r13d,%edi
mov    %r13,%r9
not    %r9
add    %r14,%r9
and    $0x7,%rdi
je     1232 <nr_matrix+0x102>
lea    0x0(,%r15,8),%rcx
sub    %r8,%rcx
add    $0x8,%rcx
mov    %r15,%rbx
sub    %r11,%rbx
sub    %r11,%rbx
lea    (%rax,%rbx,8),%rsi
add    $0x10,%rsi
xor    %eax,%eax
mov    %rsi,0x10(%rbp,%rax,8)
add    $0x1,%rax
add    %rcx,%rdx
add    %rcx,%rsi
cmp    %rax,%rdi
jne    1210 <nr_matrix+0xe0>
add    %r13,%rax
cmp    $0x7,%r9
jae    123f <nr_matrix+0x10f>
jmp    12c9 <nr_matrix+0x199>
mov    %r13,%rax
cmp    $0x7,%r9
jb     12c9 <nr_matrix+0x199>
mov    0x8(%rsp),%rcx
lea    (%rdx,%rcx,8),%rdx
mov    %r15,%rsi
shl    $0x6,%rsi
shl    $0x6,%r11
sub    %r11,%rsi
add    $0x40,%rsi
mov    $0x9,%ecx
sub    %r13,%rcx
lea    0x0(,%rcx,8),%rdi
add    %rbp,%rdi
shl    $0x3,%r15
sub    %r8,%r15
add    $0x8,%r15
nopl   0x0(%rax,%rax,1)
mov    %rdx,-0x38(%rdi,%rax,8)
lea    (%rdx,%r15,1),%rcx
mov    %rcx,-0x30(%rdi,%rax,8)
add    %r15,%rcx
mov    %rcx,-0x28(%rdi,%rax,8)
add    %r15,%rcx
mov    %rcx,-0x20(%rdi,%rax,8)
add    %r15,%rcx
mov    %rcx,-0x18(%rdi,%rax,8)
add    %r15,%rcx
mov    %rcx,-0x10(%rdi,%rax,8)
add    %r15,%rcx
mov    %rcx,-0x8(%rdi,%rax,8)
add    %r15,%rcx
mov    %rcx,(%rdi,%rax,8)
add    $0x8,%rax
add    %rsi,%rdx
cmp    %rax,%r14
jne    1280 <nr_matrix+0x150>
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
lea    0xd15(%rip),%rsi
jmp    12fd <nr_matrix+0x1cd>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
lea    0xd2b(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"Memory failure in routine 'nr_matrix'.\0A\00"
@.str.1 = [36 x i8] c"Memory failure in routine 'matrix'\0A\00"
define double** @nr_matrix(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = sub nsw i64 %1, %0
%6 = sub nsw i64 %3, %2
%7 = add nsw i64 %6, 1
%8 = shl i64 %5, 3
%9 = add i64 %8, 16
%10 = tail call i64 @malloc(i64 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %4
%17 = inttoptr i64 %10 to double**
%18 = getelementptr inbounds double*, double** %17, i64 1
%19 = sub i64 0, %0
%20 = getelementptr inbounds double*, double** %18, i64 %19
%21 = add i64 %8, 8
%22 = mul i64 %21, %7
%23 = add i64 %22, 8
%24 = tail call i64 @malloc(i64 %23)
%25 = inttoptr i64 %24 to double*
%26 = getelementptr inbounds double*, double** %20, i64 %0
store double* %25, double** %26
%27 = icmp eq i64 %24, 0
br i1 %27, label %28, label %32
28: ; preds = %16
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %16
%33 = getelementptr inbounds double, double* %25, i64 1
%34 = sub i64 0, %2
%35 = getelementptr inbounds double, double* %33, i64 %34
store double* %35, double** %26
%36 = icmp sgt i64 %1, %0
br i1 %36, label %37, label %84
37: ; preds = %32
%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 %7
%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 %7
%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 %7
%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 %7
%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 %7
%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 %7
%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 %7
%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 %7
%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 %7
%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, %32
ret double** %20
}