void free_dmatrix(double **m, int nrl, int nrh, int ncl, int nch) {
  int i;
  for (i = nrh; i >= nrl; i--)
    free((char *)(m[i] + ncl));
  free((double *)(m + nrl));
}


x86 assembly (clang, -O0):
<free_dmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1165 <free_dmatrix+0x55>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    112f <free_dmatrix+0x1f>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_dmatrix>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    %esi,%edx
jge    1124 <free_dmatrix+0x14>
movslq %esi,%r15
jmp    1156 <free_dmatrix+0x46>
movslq %ecx,%r12
movslq %edx,%rbx
movslq %esi,%r15
add    $0x1,%rbx
shl    $0x3,%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x8(%r14,%rbx,8),%rdi
add    %r12,%rdi
call   1030 <free@plt>
add    $0xffffffffffffffff,%rbx
cmp    %r15,%rbx
jg     1140 <free_dmatrix+0x30>
lea    (%r14,%r15,8),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @free_dmatrix(double** %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store double** %0, double*** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %8
store i32 %12, i32* %11
br label %13
13: ; preds = %27, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %7
%16 = icmp sge i32 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load double**, double*** %6
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double*, double** %18, i64 %20
%22 = load double*, double** %21
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = bitcast double* %25 to i8*
br label %27
27: ; preds = %17
%28 = load i32, i32* %11
%29 = add nsw i32 %28, -1
store i32 %29, i32* %11
br label %13
30: ; preds = %13
%31 = load double**, double*** %6
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double*, double** %31, i64 %33
%35 = bitcast double** %34 to double*
%36 = bitcast double* %35 to i8*
ret void
}

LLVM IR (-O2):
define void @free_dmatrix(double** nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %2, %1
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = sext i32 %1 to i64
br label %21
9: ; preds = %5
%10 = sext i32 %3 to i64
%11 = sext i32 %2 to i64
%12 = sext i32 %1 to i64
br label %13
13: ; preds = %9, %13
%14 = phi i64 [ %11, %9 ], [ %19, %13 ]
%15 = getelementptr inbounds double*, double** %0, i64 %14
%16 = load double*, double** %15
%17 = getelementptr inbounds double, double* %16, i64 %10
%18 = bitcast double* %17 to i8*
tail call void @free(i8* %18)
%19 = add nsw i64 %14, -1
%20 = icmp sgt i64 %14, %12
br i1 %20, label %13, label %21
21: ; preds = %13, %7
%22 = phi i64 [ %8, %7 ], [ %12, %13 ]
%23 = getelementptr inbounds double*, double** %0, i64 %22
%24 = bitcast double** %23 to i8*
tail call void @free(i8* %24)
ret void
}