#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 */

/* Variables and functions */
scalar_t__ calloc(int, int);
int init_matrix(char ***m, int rows, int columns) {
  int r = 0;
  (*m) = (char **)calloc(rows, sizeof(char *));
  for (r = 0; r < rows; r++) {
    (*m)[r] = (char *)calloc(columns, sizeof(char));
  }
  return 0;
}


x86 assembly (clang, -O0):
<init_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1180 <init_matrix+0x70>
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <init_matrix+0x37>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r12
mov    %esi,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%r12)
test   %r14d,%r14d
jle    115e <init_matrix+0x4e>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    (%r12),%rcx
mov    %rax,(%rcx,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <init_matrix+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @init_matrix(i8*** %0, i32 %1, i32 %2) {
%4 = alloca i8***
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8*** %0, i8**** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %5
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to i8**
%11 = load i8***, i8**** %4
store i8** %10, i8*** %11
store i32 0, i32* %7
br label %12
12: ; preds = %25, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i32, i32* %6
%18 = call i64 @calloc(i32 %17, i32 1)
%19 = inttoptr i64 %18 to i8*
%20 = load i8***, i8**** %4
%21 = load i8**, i8*** %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
store i8* %19, i8** %24
br label %25
25: ; preds = %16
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %12
28: ; preds = %12
ret i32 0
}

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