#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
scalar_t__ calloc(size_t const, int);
scalar_t__ malloc(size_t const);
uint8_t **ui8matrix(const size_t nrow, const size_t ncol) {
  size_t i;
  uint8_t **m = (uint8_t **)malloc(nrow * sizeof(uint8_t *));
  assert(m);
  for (i = 0; i < nrow; i++) {
    m[i] = (uint8_t *)calloc(ncol, sizeof(uint8_t));
    assert(m[i]);
  }
  return m;
}


x86 assembly (clang, -O0):
<ui8matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <assert@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11af <ui8matrix+0x7f>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1162 <ui8matrix+0x32>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui8matrix>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x0(,%rdi,8),%rdi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <assert@plt>
test   %r15,%r15
je     1182 <ui8matrix+0x52>
xor    %ebx,%ebx
nopl   (%rax)
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,(%r12,%rbx,8)
mov    %rax,%rdi
call   1040 <assert@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <ui8matrix+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32** @ui8matrix(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32**
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = mul i64 %7, 8
%9 = call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i32**
store i32** %10, i32*** %6
%11 = load i32**, i32*** %6
%12 = bitcast i32** %11 to i32*
%13 = call i32 @assert(i32* %12)
store i64 0, i64* %5
br label %14
14: ; preds = %30, %2
%15 = load i64, i64* %5
%16 = load i64, i64* %3
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = load i64, i64* %4
%20 = call i64 @calloc(i64 %19, i32 4)
%21 = inttoptr i64 %20 to i32*
%22 = load i32**, i32*** %6
%23 = load i64, i64* %5
%24 = getelementptr inbounds i32*, i32** %22, i64 %23
store i32* %21, i32** %24
%25 = load i32**, i32*** %6
%26 = load i64, i64* %5
%27 = getelementptr inbounds i32*, i32** %25, i64 %26
%28 = load i32*, i32** %27
%29 = call i32 @assert(i32* %28)
br label %30
30: ; preds = %18
%31 = load i64, i64* %5
%32 = add i64 %31, 1
store i64 %32, i64* %5
br label %14
33: ; preds = %14
%34 = load i32**, i32*** %6
ret i32** %34
}

LLVM IR (-O2):
define i32** @ui8matrix(i64 %0, i64 %1) {
%3 = shl i64 %0, 3
%4 = tail call i64 @malloc(i64 %3)
%5 = inttoptr i64 %4 to i32**
%6 = inttoptr i64 %4 to i32*
%7 = tail call i32 @assert(i32* %6)
%8 = icmp eq i64 %0, 0
br i1 %8, label %17, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %15, %9 ], [ 0, %2 ]
%11 = tail call i64 @calloc(i64 %1, i32 4)
%12 = inttoptr i64 %11 to i32*
%13 = getelementptr inbounds i32*, i32** %5, i64 %10
store i32* %12, i32** %13
%14 = tail call i32 @assert(i32* %12)
%15 = add nuw i64 %10, 1
%16 = icmp eq i64 %15, %0
br i1 %16, label %17, label %9
17: ; preds = %9, %2
ret i32** %5
}