char **cmatrix(nsam, len)
int nsam, len;
{
  int i;
  char **m;
  if (!(m = (char **)malloc((unsigned)nsam * sizeof(char *))))
    perror("alloc error in cmatrix");
  for (i = 0; i < nsam; i++) {
    if (!(m[i] = (char *)malloc((unsigned)len * sizeof(char))))
      perror("alloc error in cmatric. 2");
  }
  return (m);
}


x86 assembly (clang, -O0):
<cmatrix>:
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)
cmp    $0x0,%rax
jne    1158 <cmatrix+0x38>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <perror@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b0 <cmatrix+0x90>
mov    -0x8(%rbp),%eax
mov    %eax,%edi
shl    $0x0,%rdi
call   1030 <malloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0xc(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    119d <cmatrix+0x7d>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <perror@plt>
jmp    11a2 <cmatrix+0x82>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115f <cmatrix+0x3f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%ebx
mov    %edi,%r12d
lea    0x0(,%r12,8),%rdi
call   1030 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     114b <cmatrix+0x2b>
test   %ebx,%ebx
jg     115d <cmatrix+0x3d>
jmp    1196 <cmatrix+0x76>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <perror@plt>
test   %ebx,%ebx
jle    1196 <cmatrix+0x76>
mov    %r15d,%ebx
lea    0xeb0(%rip),%r15
xor    %ebp,%ebp
jmp    1179 <cmatrix+0x59>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r12
je     1196 <cmatrix+0x76>
mov    %rbx,%rdi
call   1030 <malloc@plt>
mov    %rax,(%r14,%rbp,8)
test   %rax,%rax
jne    1170 <cmatrix+0x50>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <perror@plt>
jmp    1170 <cmatrix+0x50>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"alloc error in cmatrix\00"
@.str.1 = [26 x i8] c"alloc error in cmatric. 2\00"
define i8** @cmatrix(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
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 i8**
store i8** %11, i8*** %6
%12 = icmp ne i8** %11, null
br i1 %12, label %15, label %13
13: ; preds = %2
%14 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
store i32 0, i32* %5
br label %16
16: ; preds = %33, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load i32, i32* %4
%22 = zext i32 %21 to i64
%23 = mul i64 %22, 1
%24 = call i8* @malloc(i64 %23)
%25 = load i8**, i8*** %6
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
store i8* %24, i8** %28
%29 = icmp ne i8* %24, null
br i1 %29, label %32, label %30
30: ; preds = %20
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %20
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %16
36: ; preds = %16
%37 = load i8**, i8*** %6
ret i8** %37
}

LLVM IR (-O2):
@.str = [23 x i8] c"alloc error in cmatrix\00"
@.str.1 = [26 x i8] c"alloc error in cmatric. 2\00"
define i8** @cmatrix(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 i8**
%7 = icmp eq i8* %5, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %24
12: ; preds = %10
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %12, %21
%15 = phi i64 [ 0, %12 ], [ %22, %21 ]
%16 = tail call i8* @malloc(i64 %13)
%17 = getelementptr inbounds i8*, i8** %6, i64 %15
store i8* %16, i8** %17
%18 = icmp eq i8* %16, null
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %14, %19
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %3
br i1 %23, label %24, label %14
24: ; preds = %21, %10
ret i8** %6
}