#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
float ***get_3d_mem_float(int dim1, int dim2, int dim3) {
  float ***array_3d;
  int k, j;
  if (!(array_3d = (float ***)calloc(dim1, sizeof(float **)))) {
    printf("Cannot allocate memory in get_3d_mem_float\n");
    exit(1);
  }
  for (k = 0; k < dim1; k++) {
    if (!(array_3d[k] = (float **)calloc(dim2, sizeof(float *)))) {
      printf("Cannot allocate memory in get_3d_mem_float\n");
      exit(1);
    }
    for (j = 0; j < dim2; j++) {
      if (!(array_3d[k][j] = (float *)calloc(dim3, sizeof(float)))) {
        printf("Cannot allocate memory in get_3d_mem_float\n");
        exit(1);
      }
    }
  }
  return array_3d;
}


x86 assembly (clang, -O0):
<get_3d_mem_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1172 <get_3d_mem_float+0x42>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1238 <get_3d_mem_float+0x108>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11be <get_3d_mem_float+0x8e>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1225 <get_3d_mem_float+0xf5>
mov    -0xc(%rbp),%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x20(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    1212 <get_3d_mem_float+0xe2>
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    1217 <get_3d_mem_float+0xe7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c5 <get_3d_mem_float+0x95>
jmp    122a <get_3d_mem_float+0xfa>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <get_3d_mem_float+0x49>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_3d_mem_float>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %edi,%r15d
mov    $0x8,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     11d8 <get_3d_mem_float+0xa8>
mov    %rax,%r13
test   %r15d,%r15d
jle    11c6 <get_3d_mem_float+0x96>
mov    %r15d,%eax
mov    %rax,(%rsp)
mov    %r14d,%ebx
xor    %ebp,%ebp
jmp    117a <get_3d_mem_float+0x4a>
nopl   (%rax)
add    $0x1,%rbp
cmp    (%rsp),%rbp
je     11c6 <get_3d_mem_float+0x96>
mov    %r14d,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,0x0(%r13,%rbp,8)
test   %rax,%rax
je     11d8 <get_3d_mem_float+0xa8>
test   %r14d,%r14d
jle    1170 <get_3d_mem_float+0x40>
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    %r12d,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    0x0(%r13,%rbp,8),%rcx
mov    %rax,(%rcx,%r15,8)
test   %rax,%rax
je     11d8 <get_3d_mem_float+0xa8>
add    $0x1,%r15
cmp    %r15,%rbx
jne    11a0 <get_3d_mem_float+0x70>
jmp    1170 <get_3d_mem_float+0x40>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe21(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"Cannot allocate memory in get_3d_mem_float\0A\00"
define float*** @get_3d_mem_float(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float***
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to float***
store float*** %12, float**** %7
%13 = icmp ne float*** %12, null
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %3
store i32 0, i32* %8
br label %18
18: ; preds = %60, %17
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %63
22: ; preds = %18
%23 = load i32, i32* %5
%24 = call i64 @calloc(i32 %23, i32 8)
%25 = inttoptr i64 %24 to float**
%26 = load float***, float**** %7
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float**, float*** %26, i64 %28
store float** %25, float*** %29
%30 = icmp ne float** %25, null
br i1 %30, label %34, label %31
31: ; preds = %22
%32 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %22
store i32 0, i32* %9
br label %35
35: ; preds = %56, %34
%36 = load i32, i32* %9
%37 = load i32, i32* %5
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %59
39: ; preds = %35
%40 = load i32, i32* %6
%41 = call i64 @calloc(i32 %40, i32 4)
%42 = inttoptr i64 %41 to float*
%43 = load float***, float**** %7
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds float**, float*** %43, i64 %45
%47 = load float**, float*** %46
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds float*, float** %47, i64 %49
store float* %42, float** %50
%51 = icmp ne float* %42, null
br i1 %51, label %55, label %52
52: ; preds = %39
%53 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %39
br label %56
56: ; preds = %55
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %35
59: ; preds = %35
br label %60
60: ; preds = %59
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %18
63: ; preds = %18
%64 = load float***, float**** %7
ret float*** %64
}

LLVM IR (-O2):
@str.2 = [43 x i8] c"Cannot allocate memory in get_3d_mem_float\00"
define float*** @get_3d_mem_float(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @calloc(i32 %0, i32 8)
%5 = inttoptr i64 %4 to float***
%6 = icmp eq i64 %4, 0
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %42
9: ; preds = %7
%10 = icmp sgt i32 %1, 0
%11 = zext i32 %0 to i64
%12 = zext i32 %1 to i64
br label %16
13: ; preds = %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.2, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9, %39
%17 = phi i64 [ 0, %9 ], [ %40, %39 ]
%18 = tail call i64 @calloc(i32 %1, i32 8)
%19 = inttoptr i64 %18 to float**
%20 = getelementptr inbounds float**, float*** %5, i64 %17
store float** %19, float*** %20
%21 = icmp eq i64 %18, 0
br i1 %21, label %23, label %22
22: ; preds = %16
br i1 %10, label %28, label %39
23: ; preds = %16
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.2, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %28
%27 = icmp eq i64 %35, %12
br i1 %27, label %39, label %28
28: ; preds = %22, %26
%29 = phi i64 [ %35, %26 ], [ 0, %22 ]
%30 = tail call i64 @calloc(i32 %2, i32 4)
%31 = inttoptr i64 %30 to float*
%32 = load float**, float*** %20
%33 = getelementptr inbounds float*, float** %32, i64 %29
store float* %31, float** %33
%34 = icmp eq i64 %30, 0
%35 = add nuw nsw i64 %29, 1
br i1 %34, label %36, label %26
36: ; preds = %28
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.2, i64 0, i64 0))
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %26, %22
%40 = add nuw nsw i64 %17, 1
%41 = icmp eq i64 %40, %11
br i1 %41, label %42, label %16
42: ; preds = %39, %7
ret float*** %5
}