#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__ eca_malloc(size_t, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, int);
double **dmatrix(int LoRows, int HiRows, int LoCols, int HiCols) {
  int i, NumRows, NumCols;
  double **temp;
  NumRows = HiRows - LoRows + 1;
  NumCols = HiCols - LoCols + 1;
  temp = (double **)eca_malloc((size_t)((NumRows + 1) * sizeof(double *)),
                               "(size_t) ((NumRows+1) * sizeof(double *) )");
  if (temp == NULL) {
    printf("\n\ndmatrix failed to allocate to array of pointers of length %d",
           HiRows + 1);
    exit(1);
  }
  temp += 1;
  temp -= LoRows;
  temp[LoRows] =
      (double *)eca_malloc((size_t)((NumRows * NumCols + 1) * sizeof(double)),
                           "(size_t)( (NumRows*NumCols+1)*sizeof(double))");
  if (temp[LoRows] == NULL) {
    printf("\n\ndmatrix failed to allocate to array of doubles of length %d",
           HiRows + 1);
    exit(1);
  }
  temp[LoRows] += 1;
  temp[LoRows] -= LoCols;
  for (i = LoRows + 1; i <= HiRows; i++) {
    temp[i] = temp[i - 1] + NumCols;
  }
  return (temp);
}


x86 assembly (clang, -O0):
<dmatrix>:
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    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
lea    0xe90(%rip),%rsi
call   1040 <eca_malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a0 <dmatrix+0x70>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
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    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
lea    0xe8c(%rip),%rsi
call   1040 <eca_malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1221 <dmatrix+0xf1>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x8,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x4(%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    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12a2 <dmatrix+0x172>
mov    -0x28(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1260 <dmatrix+0x130>
mov    -0x28(%rbp),%rax
add    $0x30,%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,%ebp
mov    %edx,%r14d
mov    %esi,%r13d
mov    %edi,%r12d
mov    %esi,(%rsp)
sub    %edi,%r13d
movslq %r13d,%rax
lea    0x10(,%rax,8),%rdi
lea    0xea2(%rip),%rsi
call   1040 <eca_malloc@plt>
test   %rax,%rax
je     129c <dmatrix+0x16c>
mov    %rax,%rbx
mov    %r14d,0x4(%rsp)
sub    %r14d,%ebp
add    $0x1,%ebp
add    $0x1,%r13d
movslq %r12d,%r15
lea    0x0(,%r15,8),%rax
mov    %rbx,%r14
sub    %rax,%r14
imul   %ebp,%r13d
movslq %r13d,%rax
lea    0x8(,%rax,8),%rdi
lea    0xec5(%rip),%rsi
call   1040 <eca_malloc@plt>
mov    %rax,0x8(%r14,%r15,8)
test   %rax,%rax
je     12ab <dmatrix+0x17b>
add    $0x8,%r14
movslq 0x4(%rsp),%rcx
shl    $0x3,%rcx
sub    %rcx,%rax
add    $0x8,%rax
mov    %rax,(%r14,%r15,8)
mov    (%rsp),%edx
mov    %edx,%edi
sub    %r12d,%edi
jle    128a <dmatrix+0x15a>
movslq %ebp,%rcx
movslq %edx,%rdx
mov    %r15,%r8
not    %r8
add    %rdx,%r8
and    $0x7,%rdi
je     121c <dmatrix+0xec>
lea    0x0(,%rcx,8),%rbp
xor    %esi,%esi
nopl   (%rax)
add    %rbp,%rax
mov    %rax,0x10(%rbx,%rsi,8)
add    $0x1,%rsi
cmp    %rsi,%rdi
jne    1200 <dmatrix+0xd0>
add    %r15,%rsi
cmp    $0x7,%r8
jae    1225 <dmatrix+0xf5>
jmp    128a <dmatrix+0x15a>
mov    %r15,%rsi
cmp    $0x7,%r8
jb     128a <dmatrix+0x15a>
lea    (%rax,%rcx,8),%rax
mov    %rcx,%rdi
shl    $0x6,%rdi
mov    $0x9,%ebp
sub    %r15,%rbp
lea    (%rbx,%rbp,8),%rbp
shl    $0x3,%rcx
mov    %rax,-0x38(%rbp,%rsi,8)
lea    (%rax,%rcx,1),%rbx
mov    %rbx,-0x30(%rbp,%rsi,8)
add    %rcx,%rbx
mov    %rbx,-0x28(%rbp,%rsi,8)
add    %rcx,%rbx
mov    %rbx,-0x20(%rbp,%rsi,8)
add    %rcx,%rbx
mov    %rbx,-0x18(%rbp,%rsi,8)
add    %rcx,%rbx
mov    %rbx,-0x10(%rbp,%rsi,8)
add    %rcx,%rbx
mov    %rbx,-0x8(%rbp,%rsi,8)
add    %rcx,%rbx
mov    %rbx,0x0(%rbp,%rsi,8)
add    $0x8,%rsi
add    %rdi,%rax
cmp    %rsi,%rdx
jne    1240 <dmatrix+0x110>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%esi
add    $0x1,%esi
lea    0xd82(%rip),%rdi
jmp    12b8 <dmatrix+0x188>
mov    (%rsp),%esi
add    $0x1,%esi
lea    0xde0(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"(size_t) ((NumRows+1) * sizeof(double *) )\00"
@.str.1 = [63 x i8] c"\0A\0Admatrix failed to allocate to array of pointers of length %d\00"
@.str.2 = [46 x i8] c"(size_t)( (NumRows*NumCols+1)*sizeof(double))\00"
@.str.3 = [62 x i8] c"\0A\0Admatrix failed to allocate to array of doubles of length %d\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 i32
%11 = alloca i32
%12 = alloca double**
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = sub nsw i32 %13, %14
%16 = add nsw i32 %15, 1
store i32 %16, i32* %10
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %11
%21 = load i32, i32* %10
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 8
%25 = call i64 @eca_malloc(i64 %24, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%26 = inttoptr i64 %25 to double**
store double** %26, double*** %12
%27 = load double**, double*** %12
%28 = icmp eq double** %27, null
br i1 %28, label %29, label %34
29: ; preds = %4
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
%32 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %4
%35 = load double**, double*** %12
%36 = getelementptr inbounds double*, double** %35, i64 1
store double** %36, double*** %12
%37 = load i32, i32* %5
%38 = load double**, double*** %12
%39 = sext i32 %37 to i64
%40 = sub i64 0, %39
%41 = getelementptr inbounds double*, double** %38, i64 %40
store double** %41, double*** %12
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = mul nsw i32 %42, %43
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = mul i64 %46, 8
%48 = call i64 @eca_malloc(i64 %47, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%49 = inttoptr i64 %48 to double*
%50 = load double**, double*** %12
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double*, double** %50, i64 %52
store double* %49, double** %53
%54 = load double**, double*** %12
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double*, double** %54, i64 %56
%58 = load double*, double** %57
%59 = icmp eq double* %58, null
br i1 %59, label %60, label %65
60: ; preds = %34
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
%63 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %62)
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %34
%66 = load double**, double*** %12
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double*, double** %66, i64 %68
%70 = load double*, double** %69
%71 = getelementptr inbounds double, double* %70, i64 1
store double* %71, double** %69
%72 = load i32, i32* %7
%73 = load double**, double*** %12
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double*, double** %73, i64 %75
%77 = load double*, double** %76
%78 = sext i32 %72 to i64
%79 = sub i64 0, %78
%80 = getelementptr inbounds double, double* %77, i64 %79
store double* %80, double** %76
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
store i32 %82, i32* %9
br label %83
83: ; preds = %101, %65
%84 = load i32, i32* %9
%85 = load i32, i32* %6
%86 = icmp sle i32 %84, %85
br i1 %86, label %87, label %104
87: ; preds = %83
%88 = load double**, double*** %12
%89 = load i32, i32* %9
%90 = sub nsw i32 %89, 1
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double*, double** %88, i64 %91
%93 = load double*, double** %92
%94 = load i32, i32* %11
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double**, double*** %12
%98 = load i32, i32* %9
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double*, double** %97, i64 %99
store double* %96, double** %100
br label %101
101: ; preds = %87
%102 = load i32, i32* %9
%103 = add nsw i32 %102, 1
store i32 %103, i32* %9
br label %83
104: ; preds = %83
%105 = load double**, double*** %12
ret double** %105
}

LLVM IR (-O2):
@.str = [43 x i8] c"(size_t) ((NumRows+1) * sizeof(double *) )\00"
@.str.1 = [63 x i8] c"\0A\0Admatrix failed to allocate to array of pointers of length %d\00"
@.str.2 = [46 x i8] c"(size_t)( (NumRows*NumCols+1)*sizeof(double))\00"
@.str.3 = [62 x i8] c"\0A\0Admatrix failed to allocate to array of doubles of length %d\00"
define double** @dmatrix(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %1, %0
%6 = sub nsw i32 %3, %2
%7 = add nsw i32 %6, 1
%8 = add nsw i32 %5, 2
%9 = sext i32 %8 to i64
%10 = shl nsw i64 %9, 3
%11 = tail call i64 @eca_malloc(i64 %10, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = add nsw i32 %1, 1
%15 = tail call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %4
%18 = inttoptr i64 %11 to double**
%19 = add nsw i32 %5, 1
%20 = getelementptr inbounds double*, double** %18, i64 1
%21 = sext i32 %0 to i64
%22 = sub nsw i64 0, %21
%23 = getelementptr inbounds double*, double** %20, i64 %22
%24 = mul nsw i32 %7, %19
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = shl nsw i64 %26, 3
%28 = tail call i64 @eca_malloc(i64 %27, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%29 = inttoptr i64 %28 to double*
%30 = getelementptr inbounds double*, double** %23, i64 %21
store double* %29, double** %30
%31 = icmp eq i64 %28, 0
br i1 %31, label %32, label %36
32: ; preds = %17
%33 = add nsw i32 %1, 1
%34 = tail call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %17
%37 = getelementptr inbounds double, double* %29, i64 1
%38 = sext i32 %2 to i64
%39 = sub nsw i64 0, %38
%40 = getelementptr inbounds double, double* %37, i64 %39
store double* %40, double** %30
%41 = icmp sgt i32 %1, %0
br i1 %41, label %42, label %91
42: ; preds = %36
%43 = sext i32 %7 to i64
%44 = sext i32 %1 to i64
%45 = sub nsw i64 %44, %21
%46 = xor i64 %21, -1
%47 = add nsw i64 %46, %44
%48 = and i64 %45, 7
%49 = icmp eq i64 %48, 0
br i1 %49, label %59, label %50
50: ; preds = %42, %50
%51 = phi double* [ %55, %50 ], [ %40, %42 ]
%52 = phi i64 [ %54, %50 ], [ %21, %42 ]
%53 = phi i64 [ %57, %50 ], [ 0, %42 ]
%54 = add nsw i64 %52, 1
%55 = getelementptr inbounds double, double* %51, i64 %43
%56 = getelementptr inbounds double*, double** %23, i64 %54
store double* %55, double** %56
%57 = add i64 %53, 1
%58 = icmp eq i64 %57, %48
br i1 %58, label %59, label %50
59: ; preds = %50, %42
%60 = phi double* [ %40, %42 ], [ %55, %50 ]
%61 = phi i64 [ %21, %42 ], [ %54, %50 ]
%62 = icmp ult i64 %47, 7
br i1 %62, label %91, label %63
63: ; preds = %59, %63
%64 = phi double* [ %88, %63 ], [ %60, %59 ]
%65 = phi i64 [ %87, %63 ], [ %61, %59 ]
%66 = add nsw i64 %65, 1
%67 = getelementptr inbounds double, double* %64, i64 %43
%68 = getelementptr inbounds double*, double** %23, i64 %66
store double* %67, double** %68
%69 = add nsw i64 %65, 2
%70 = getelementptr inbounds double, double* %67, i64 %43
%71 = getelementptr inbounds double*, double** %23, i64 %69
store double* %70, double** %71
%72 = add nsw i64 %65, 3
%73 = getelementptr inbounds double, double* %70, i64 %43
%74 = getelementptr inbounds double*, double** %23, i64 %72
store double* %73, double** %74
%75 = add nsw i64 %65, 4
%76 = getelementptr inbounds double, double* %73, i64 %43
%77 = getelementptr inbounds double*, double** %23, i64 %75
store double* %76, double** %77
%78 = add nsw i64 %65, 5
%79 = getelementptr inbounds double, double* %76, i64 %43
%80 = getelementptr inbounds double*, double** %23, i64 %78
store double* %79, double** %80
%81 = add nsw i64 %65, 6
%82 = getelementptr inbounds double, double* %79, i64 %43
%83 = getelementptr inbounds double*, double** %23, i64 %81
store double* %82, double** %83
%84 = add nsw i64 %65, 7
%85 = getelementptr inbounds double, double* %82, i64 %43
%86 = getelementptr inbounds double*, double** %23, i64 %84
store double* %85, double** %86
%87 = add nsw i64 %65, 8
%88 = getelementptr inbounds double, double* %85, i64 %43
%89 = getelementptr inbounds double*, double** %23, i64 %87
store double* %88, double** %89
%90 = icmp eq i64 %87, %44
br i1 %90, label %91, label %63
91: ; preds = %59, %63, %36
ret double** %23
}