double **matrix(nrl, nrh, ncl, nch)
int nrl, nrh, ncl, nch;
{
  int i;
  double **m;
  m = (double **)calloc((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
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1178 <matrix+0x48>
lea    0xe8f(%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     121a <matrix+0xea>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1050 <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    11ea <matrix+0xba>
lea    0xe40(%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    1198 <matrix+0x68>
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,%ebp
mov    %edi,%r13d
mov    %esi,%ebx
sub    %edi,%ebx
add    $0x1,%ebx
mov    $0x8,%esi
mov    %rbx,%rdi
call   1040 <calloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1170 <matrix+0x40>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1030 <nrerror@plt>
movslq %r13d,%rax
shl    $0x3,%rax
mov    %r15,%rcx
sub    %rax,%rcx
mov    %rcx,(%rsp)
cmp    %ebp,%r13d
jle    1199 <matrix+0x69>
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,%r12
neg    %r12
xor    %r13d,%r13d
jmp    11c8 <matrix+0x98>
nop
lea    0x0(,%r12,8),%rax
add    %rbp,%rax
mov    %rax,(%r15,%r13,8)
add    $0x1,%r13
cmp    %r13d,%ebx
je     1186 <matrix+0x56>
mov    %r14,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11b0 <matrix+0x80>
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1030 <nrerror@plt>
jmp    11b0 <matrix+0x80>

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

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