float **matrix(n, m)
int n, m;
{
  int i;
  float **mat;
  mat = (float **)malloc((unsigned)(n) * sizeof(float *));
  if (!mat)
    erhand("Allocation failure 1 in matrix().");
  mat -= 1;
  for (i = 1; i <= n; i++) {
    mat[i] = (float *)malloc((unsigned)(m) * sizeof(float));
    if (!mat[i])
      erhand("Allocation failure 2 in matrix().");
    mat[i] -= 1;
  }
  return mat;
}


x86 assembly (clang, -O0):
<matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1159 <matrix+0x39>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <erhand@plt>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11d8 <matrix+0xb8>
mov    -0x8(%rbp),%eax
mov    %eax,%edi
shl    $0x2,%rdi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11b6 <matrix+0x96>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <erhand@plt>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116c <matrix+0x4c>
mov    -0x18(%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    %esi,%ebx
mov    %edi,%ebp
mov    %edi,%r13d
lea    0x0(,%r13,8),%rdi
call   1030 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1155 <matrix+0x35>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <erhand@plt>
lea    -0x8(%r15),%rax
mov    %rax,(%rsp)
test   %ebp,%ebp
jle    11ad <matrix+0x8d>
mov    %ebx,%ebx
shl    $0x2,%rbx
lea    0xeb4(%rip),%r12
xor    %r14d,%r14d
jmp    1191 <matrix+0x71>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xfffffffffffffffc,%rbp
mov    %rbp,(%r15,%r14,8)
add    $0x1,%r14
cmp    %r14,%r13
je     11ad <matrix+0x8d>
mov    %rbx,%rdi
call   1030 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1180 <matrix+0x60>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <erhand@plt>
jmp    1180 <matrix+0x60>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Allocation failure 1 in matrix().\00"
@.str.1 = [34 x i8] c"Allocation failure 2 in matrix().\00"
define float** @matrix(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float**
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = mul i64 %8, 8
%10 = call i8* @malloc(i64 %9)
%11 = bitcast i8* %10 to float**
store float** %11, float*** %6
%12 = load float**, float*** %6
%13 = icmp ne float** %12, null
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @erhand to i32 (i8*, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = load float**, float*** %6
%18 = getelementptr inbounds float*, float** %17, i64 -1
store float** %18, float*** %6
store i32 1, i32* %5
br label %19
19: ; preds = %48, %16
%20 = load i32, i32* %5
%21 = load i32, i32* %3
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %51
23: ; preds = %19
%24 = load i32, i32* %4
%25 = zext i32 %24 to i64
%26 = mul i64 %25, 4
%27 = call i8* @malloc(i64 %26)
%28 = bitcast i8* %27 to float*
%29 = load float**, float*** %6
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float*, float** %29, i64 %31
store float* %28, float** %32
%33 = load float**, float*** %6
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float*, float** %33, i64 %35
%37 = load float*, float** %36
%38 = icmp ne float* %37, null
br i1 %38, label %41, label %39
39: ; preds = %23
%40 = call i32 (i8*, ...) bitcast (i32 (...)* @erhand to i32 (i8*, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39, %23
%42 = load float**, float*** %6
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds float*, float** %42, i64 %44
%46 = load float*, float** %45
%47 = getelementptr inbounds float, float* %46, i64 -1
store float* %47, float** %45
br label %48
48: ; preds = %41
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %19
51: ; preds = %19
%52 = load float**, float*** %6
ret float** %52
}

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