#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);
void alloc_matrix(int m, int n, float ***a) {
  int i;
  (*a) = (float **)calloc(m, sizeof(float *));
  for (i = 0; i < m; ++i) {
    (*a)[i] = (float *)calloc(n, sizeof(float));
  }
}


x86 assembly (clang, -O0):
<alloc_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1179 <alloc_matrix+0x69>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%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    1140 <alloc_matrix+0x30>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @alloc_matrix(i32 %0, i32 %1, float*** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca float***
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store float*** %2, float**** %6
%8 = load i32, i32* %4
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to float**
%11 = load float***, float**** %6
store float** %10, float*** %11
store i32 0, i32* %7
br label %12
12: ; preds = %25, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i32, i32* %5
%18 = call i64 @calloc(i32 %17, i32 4)
%19 = inttoptr i64 %18 to float*
%20 = load float***, float**** %6
%21 = load float**, float*** %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float*, float** %21, i64 %23
store float* %19, float** %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 void
}

LLVM IR (-O2):
define void @alloc_matrix(i32 %0, i32 %1, float*** nocapture %2) {
%4 = tail call i64 @calloc(i32 %0, i32 8)
%5 = inttoptr i64 %4 to float**
store float** %5, float*** %2
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %15, %9 ]
%11 = tail call i64 @calloc(i32 %1, i32 4)
%12 = inttoptr i64 %11 to float*
%13 = load float**, float*** %2
%14 = getelementptr inbounds float*, float** %13, i64 %10
store float* %12, float** %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 void
}