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


x86 assembly (clang, -O0):
<get_4d_mem_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1175 <get_4d_mem_float+0x45>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12aa <get_4d_mem_float+0x17a>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11c1 <get_4d_mem_float+0x91>
lea    0xe4e(%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    1297 <get_4d_mem_float+0x167>
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x20(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    1215 <get_4d_mem_float+0xe5>
lea    0xdfa(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1284 <get_4d_mem_float+0x154>
mov    -0x10(%rbp),%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x20(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x1c(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    1271 <get_4d_mem_float+0x141>
lea    0xd9e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    1276 <get_4d_mem_float+0x146>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121c <get_4d_mem_float+0xec>
jmp    1289 <get_4d_mem_float+0x159>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c8 <get_4d_mem_float+0x98>
jmp    129c <get_4d_mem_float+0x16c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117c <get_4d_mem_float+0x4c>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_4d_mem_float>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r13d
mov    %edi,%r12d
mov    $0x8,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     124b <get_4d_mem_float+0x11b>
mov    %rax,%rbp
test   %r12d,%r12d
jle    1239 <get_4d_mem_float+0x109>
mov    %r12d,%eax
mov    %rax,0x8(%rsp)
mov    %r13d,%eax
mov    %rax,0x10(%rsp)
mov    %r15d,%r12d
xor    %r14d,%r14d
mov    %r15d,0x4(%rsp)
mov    %r13d,(%rsp)
jmp    11a3 <get_4d_mem_float+0x73>
nopl   0x0(%rax)
add    $0x1,%r14
cmp    0x8(%rsp),%r14
mov    (%rsp),%r13d
je     1239 <get_4d_mem_float+0x109>
mov    %r13d,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,0x0(%rbp,%r14,8)
test   %rax,%rax
je     124b <get_4d_mem_float+0x11b>
test   %r13d,%r13d
jle    1190 <get_4d_mem_float+0x60>
xor    %r13d,%r13d
jmp    11e0 <get_4d_mem_float+0xb0>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    0x10(%rsp),%r13
mov    0x4(%rsp),%r15d
je     1190 <get_4d_mem_float+0x60>
mov    %r15d,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    0x0(%rbp,%r14,8),%rcx
mov    %rax,(%rcx,%r13,8)
test   %rax,%rax
je     124b <get_4d_mem_float+0x11b>
test   %r15d,%r15d
jle    11d0 <get_4d_mem_float+0xa0>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    0x0(%rbp,%r14,8),%rcx
mov    (%rcx,%r13,8),%rcx
mov    %rax,(%rcx,%r15,8)
test   %rax,%rax
je     124b <get_4d_mem_float+0x11b>
add    $0x1,%r15
cmp    %r15,%r12
jne    1210 <get_4d_mem_float+0xe0>
jmp    11d0 <get_4d_mem_float+0xa0>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdae(%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_4d_mem_float\0A\00"
define float**** @get_4d_mem_float(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float****
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %5
%14 = call i64 @calloc(i32 %13, i32 8)
%15 = inttoptr i64 %14 to float****
store float**** %15, float***** %9
%16 = icmp ne float**** %15, null
br i1 %16, label %20, label %17
17: ; preds = %4
%18 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %4
store i32 0, i32* %12
br label %21
21: ; preds = %92, %20
%22 = load i32, i32* %12
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %95
25: ; preds = %21
%26 = load i32, i32* %6
%27 = call i64 @calloc(i32 %26, i32 8)
%28 = inttoptr i64 %27 to float***
%29 = load float****, float***** %9
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float***, float**** %29, i64 %31
store float*** %28, float**** %32
%33 = icmp ne float*** %28, null
br i1 %33, label %37, label %34
34: ; preds = %25
%35 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %25
store i32 0, i32* %11
br label %38
38: ; preds = %88, %37
%39 = load i32, i32* %11
%40 = load i32, i32* %6
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %91
42: ; preds = %38
%43 = load i32, i32* %7
%44 = call i64 @calloc(i32 %43, i32 8)
%45 = inttoptr i64 %44 to float**
%46 = load float****, float***** %9
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float***, float**** %46, i64 %48
%50 = load float***, float**** %49
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float**, float*** %50, i64 %52
store float** %45, float*** %53
%54 = icmp ne float** %45, null
br i1 %54, label %58, label %55
55: ; preds = %42
%56 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %42
store i32 0, i32* %10
br label %59
59: ; preds = %84, %58
%60 = load i32, i32* %10
%61 = load i32, i32* %7
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %87
63: ; preds = %59
%64 = load i32, i32* %8
%65 = call i64 @calloc(i32 %64, i32 4)
%66 = inttoptr i64 %65 to float*
%67 = load float****, float***** %9
%68 = load i32, i32* %12
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds float***, float**** %67, i64 %69
%71 = load float***, float**** %70
%72 = load i32, i32* %11
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds float**, float*** %71, i64 %73
%75 = load float**, float*** %74
%76 = load i32, i32* %10
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float*, float** %75, i64 %77
store float* %66, float** %78
%79 = icmp ne float* %66, null
br i1 %79, label %83, label %80
80: ; preds = %63
%81 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %63
br label %84
84: ; preds = %83
%85 = load i32, i32* %10
%86 = add nsw i32 %85, 1
store i32 %86, i32* %10
br label %59
87: ; preds = %59
br label %88
88: ; preds = %87
%89 = load i32, i32* %11
%90 = add nsw i32 %89, 1
store i32 %90, i32* %11
br label %38
91: ; preds = %38
br label %92
92: ; preds = %91
%93 = load i32, i32* %12
%94 = add nsw i32 %93, 1
store i32 %94, i32* %12
br label %21
95: ; preds = %21
%96 = load float****, float***** %9
ret float**** %96
}

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