#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 */
unsigned long *malloc(unsigned int);
void init_matrix_l(unsigned long ***matrix, unsigned int x, unsigned int y) {
  *matrix = (unsigned long **)malloc(y * sizeof(unsigned long *));
  for (; y > 0; --y) {
    (*matrix)[y - 1] = malloc(x * sizeof(unsigned long));
  }
}


x86 assembly (clang, -O0):
<init_matrix_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x0,-0x10(%rbp)
jbe    1176 <init_matrix_l+0x66>
mov    -0xc(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <init_matrix_l+0x2a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_matrix_l>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r13d
mov    %rdi,%r14
lea    0x0(,%r12,8),%edi
call   1030 <malloc@plt>
mov    %rax,(%r14)
test   %r12d,%r12d
je     117a <init_matrix_l+0x6a>
mov    %rax,%r15
shl    $0x3,%r13d
mov    %r12d,%ebx
mov    %r13d,%edi
call   1030 <malloc@plt>
mov    %rbx,%rcx
mov    %rax,-0x8(%r15,%rbx,8)
add    $0xffffffffffffffff,%rcx
je     117a <init_matrix_l+0x6a>
nopl   0x0(%rax)
mov    (%r14),%rbp
mov    %r13d,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp,%rbx,8)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jne    1160 <init_matrix_l+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @init_matrix_l(i64*** nocapture %0, i32 %1, i32 %2) {
%4 = shl i32 %2, 3
%5 = tail call i64* @malloc(i32 %4)
%6 = bitcast i64*** %0 to i64**
store i64* %5, i64** %6
%7 = icmp eq i32 %2, 0
br i1 %7, label %23, label %8
8: ; preds = %3
%9 = shl i32 %1, 3
%10 = zext i32 %2 to i64
%11 = tail call i64* @malloc(i32 %9)
%12 = add nsw i64 %10, -1
%13 = getelementptr inbounds i64, i64* %5, i64 %12
%14 = bitcast i64* %13 to i64**
store i64* %11, i64** %14
%15 = icmp eq i64 %12, 0
br i1 %15, label %23, label %16
16: ; preds = %8, %16
%17 = phi i64 [ %20, %16 ], [ %12, %8 ]
%18 = load i64**, i64*** %0
%19 = tail call i64* @malloc(i32 %9)
%20 = add nsw i64 %17, -1
%21 = getelementptr inbounds i64*, i64** %18, i64 %20
store i64* %19, i64** %21
%22 = icmp eq i64 %20, 0
br i1 %22, label %23, label %16
23: ; preds = %16, %8, %3
ret void
}