#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 */
char **ft_malloc2d(int, int);
char ***ft_memalloc(int);
char ***ft_malloc3d(int x, int y, int z) {
  char ***array;
  int i;
  i = -1;
  while (!(array = ft_memalloc(sizeof(char **) * (z + 1))))
    continue;
  while (++i < z)
    while (!(array[i] = ft_malloc2d(x, y)))
      continue;
  return (array);
}


x86 assembly (clang, -O0):
<ft_malloc3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <ft_memalloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1165 <ft_malloc3d+0x45>
jmp    116a <ft_malloc3d+0x4a>
jmp    1138 <ft_malloc3d+0x18>
jmp    116f <ft_malloc3d+0x4f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    -0xc(%rbp),%eax
jge    11bd <ft_malloc3d+0x9d>
jmp    1186 <ft_malloc3d+0x66>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_malloc2d@plt>
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b3 <ft_malloc3d+0x93>
jmp    11b8 <ft_malloc3d+0x98>
jmp    1186 <ft_malloc3d+0x66>
jmp    116f <ft_malloc3d+0x4f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_malloc3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%r13d
lea    0x8(,%r15,8),%r12d
nopl   0x0(%rax)
mov    %r12d,%edi
call   1040 <ft_memalloc@plt>
test   %rax,%rax
je     1140 <ft_malloc3d+0x20>
mov    %rax,%rbx
test   %r15d,%r15d
jle    117d <ft_malloc3d+0x5d>
mov    %r15d,%r15d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14d,%esi
call   1030 <ft_malloc2d@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     1160 <ft_malloc3d+0x40>
add    $0x1,%rbp
cmp    %r15,%rbp
jne    1160 <ft_malloc3d+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8*** @ft_malloc3d(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8***
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 -1, i32* %8
br label %9
9: ; preds = %18, %3
%10 = load i32, i32* %6
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call i8*** @ft_memalloc(i32 %14)
store i8*** %15, i8**** %7
%16 = icmp ne i8*** %15, null
%17 = xor i1 %16, true
br i1 %17, label %18, label %19
18: ; preds = %9
br label %9
19: ; preds = %9
br label %20
20: ; preds = %37, %19
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %20
br label %26
26: ; preds = %36, %25
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i8** @ft_malloc2d(i32 %27, i32 %28)
%30 = load i8***, i8**** %7
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8**, i8*** %30, i64 %32
store i8** %29, i8*** %33
%34 = icmp ne i8** %29, null
%35 = xor i1 %34, true
br i1 %35, label %36, label %37
36: ; preds = %26
br label %26
37: ; preds = %26
br label %20
38: ; preds = %20
%39 = load i8***, i8**** %7
ret i8*** %39
}

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