double **matrix(nrl, nrh, ncl, nch)
int nrl, nrh, ncl, nch;
{
  int i;
  double **m;
  m = (double **)malloc((unsigned)(nrh - nrl + 1) * sizeof(double *));
  if (!m)
    nrerror("allocation failure 1 in matrix()");
  m -= nrl;
  for (i = nrl; i <= nrh; i++) {
    m[i] = (double *)malloc((unsigned)(nch - ncl + 1) * sizeof(double));
    if (!m[i])
      nrerror("allocation failure 2 in matrix()");
    m[i] -= ncl;
  }
  return m;
}


x86 assembly (clang, -O0):
<matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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,%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1167 <matrix+0x47>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <nrerror@plt>
mov    -0x4(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1209 <matrix+0xe9>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11d9 <matrix+0xb9>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <nrerror@plt>
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x14(%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    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <matrix+0x67>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%ebx
mov    %edi,%ebp
mov    %esi,%r15d
sub    %edi,%r15d
add    $0x1,%r15d
lea    0x0(,%r15,8),%rdi
call   1040 <malloc@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1162 <matrix+0x42>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1030 <nrerror@plt>
movslq %ebp,%rax
shl    $0x3,%rax
mov    %r13,%rcx
sub    %rax,%rcx
mov    %rcx,(%rsp)
cmp    %ebx,%ebp
jle    118a <matrix+0x6a>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
sub    %r12d,%r14d
add    $0x1,%r14d
shl    $0x3,%r14
movslq %r12d,%rbx
neg    %rbx
xor    %r12d,%r12d
jmp    11b9 <matrix+0x99>
lea    0x0(,%rbx,8),%rax
add    %rbp,%rax
mov    %rax,0x0(%r13,%r12,8)
add    $0x1,%r12
cmp    %r12d,%r15d
je     1177 <matrix+0x57>
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11a0 <matrix+0x80>
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1030 <nrerror@plt>
jmp    11a0 <matrix+0x80>

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

LLVM IR (-O2):
@.str = [33 x i8] c"allocation failure 1 in matrix()\00"
@.str.1 = [33 x i8] c"allocation failure 2 in matrix()\00"
define double** @matrix(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sub i32 1, %0
%6 = add i32 %5, %1
%7 = zext i32 %6 to i64
%8 = shl nuw nsw i64 %7, 3
%9 = tail call i8* @malloc(i64 %8)
%10 = bitcast i8* %9 to double**
%11 = icmp eq i8* %9, null
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 (i8*, ...) bitcast (i32 (...)* @nrerror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %4
%15 = sext i32 %0 to i64
%16 = sub nsw i64 0, %15
%17 = getelementptr inbounds double*, double** %10, i64 %16
%18 = icmp sgt i32 %0, %1
br i1 %18, label %40, label %19
19: ; preds = %14
%20 = sub i32 1, %2
%21 = add i32 %20, %3
%22 = zext i32 %21 to i64
%23 = shl nuw nsw i64 %22, 3
%24 = sext i32 %2 to i64
%25 = sub nsw i64 0, %24
%26 = add i32 %1, 1
br label %27
27: ; preds = %19, %35
%28 = phi i64 [ %15, %19 ], [ %37, %35 ]
%29 = tail call i8* @malloc(i64 %23)
%30 = getelementptr inbounds double*, double** %17, i64 %28
%31 = icmp eq i8* %29, null
%32 = bitcast i8* %29 to double*
br i1 %31, label %33, label %35
33: ; preds = %27
%34 = tail call i32 (i8*, ...) bitcast (i32 (...)* @nrerror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %27
%36 = getelementptr inbounds double, double* %32, i64 %25
store double* %36, double** %30
%37 = add nsw i64 %28, 1
%38 = trunc i64 %37 to i32
%39 = icmp eq i32 %26, %38
br i1 %39, label %40, label %27
40: ; preds = %35, %14
ret double** %17
}