#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 */
int ***malloc3d(int, int, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int i, j, k;
  int x = 10;
  int y = 10;
  int z = 10;
  int ***t2 = malloc3d(y, x, z);
  for (i = 0; i < y; ++i) {
    for (j = 0; j < x; ++j) {
      for (k = 0; k < x; ++k) {
        t2[i][j][k] = 1;
      }
    }
  }
  printf("3d Success\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <malloc3d@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e2 <main+0xc2>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cf <main+0xaf>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bc <main+0x9c>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1183 <main+0x63>
jmp    11c1 <main+0xa1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1170 <main+0x50>
jmp    11d4 <main+0xb4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x3d>
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%edi
mov    $0xa,%esi
mov    $0xa,%edx
call   1040 <malloc3d@plt>
xor    %ecx,%ecx
movaps 0xec2(%rip),%xmm0
movabs $0x100000001,%rdx
nopl   0x0(%rax,%rax,1)
mov    (%rax,%rcx,8),%rsi
mov    (%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x8(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x10(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x18(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x20(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x28(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x30(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x38(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x40(%rsi),%rdi
movups %xmm0,(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdx,0x20(%rdi)
mov    0x48(%rsi),%rsi
movups %xmm0,(%rsi)
movups %xmm0,0x10(%rsi)
mov    %rdx,0x20(%rsi)
add    $0x1,%rcx
cmp    $0xa,%rcx
jne    1150 <main+0x30>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"3d Success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32***
store i32 0, i32* %1
store i32 10, i32* %5
store i32 10, i32* %6
store i32 10, i32* %7
%9 = load i32, i32* %6
%10 = load i32, i32* %5
%11 = load i32, i32* %7
%12 = call i32*** @malloc3d(i32 %9, i32 %10, i32 %11)
store i32*** %12, i32**** %8
store i32 0, i32* %2
br label %13
13: ; preds = %48, %0
%14 = load i32, i32* %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %51
17: ; preds = %13
store i32 0, i32* %3
br label %18
18: ; preds = %44, %17
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %47
22: ; preds = %18
store i32 0, i32* %4
br label %23
23: ; preds = %40, %22
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %43
27: ; preds = %23
%28 = load i32***, i32**** %8
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32**, i32*** %28, i64 %30
%32 = load i32**, i32*** %31
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32*, i32** %32, i64 %34
%36 = load i32*, i32** %35
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
store i32 1, i32* %39
br label %40
40: ; preds = %27
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %23
43: ; preds = %23
br label %44
44: ; preds = %43
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %18
47: ; preds = %18
br label %48
48: ; preds = %47
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %13
51: ; preds = %13
%52 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [11 x i8] c"3d Success\00"
define i32 @main() {
%1 = tail call i32*** @malloc3d(i32 10, i32 10, i32 10)
br label %2
2: ; preds = %0, %2
%3 = phi i64 [ 0, %0 ], [ %75, %2 ]
%4 = getelementptr inbounds i32**, i32*** %1, i64 %3
%5 = load i32**, i32*** %4
%6 = load i32*, i32** %5
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %7
%8 = getelementptr inbounds i32, i32* %6, i64 4
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %6, i64 8
store i32 1, i32* %10
%11 = getelementptr inbounds i32, i32* %6, i64 9
store i32 1, i32* %11
%12 = getelementptr inbounds i32*, i32** %5, i64 1
%13 = load i32*, i32** %12
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %14
%15 = getelementptr inbounds i32, i32* %13, i64 4
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %16
%17 = getelementptr inbounds i32, i32* %13, i64 8
store i32 1, i32* %17
%18 = getelementptr inbounds i32, i32* %13, i64 9
store i32 1, i32* %18
%19 = getelementptr inbounds i32*, i32** %5, i64 2
%20 = load i32*, i32** %19
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %21
%22 = getelementptr inbounds i32, i32* %20, i64 4
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %23
%24 = getelementptr inbounds i32, i32* %20, i64 8
store i32 1, i32* %24
%25 = getelementptr inbounds i32, i32* %20, i64 9
store i32 1, i32* %25
%26 = getelementptr inbounds i32*, i32** %5, i64 3
%27 = load i32*, i32** %26
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %28
%29 = getelementptr inbounds i32, i32* %27, i64 4
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %30
%31 = getelementptr inbounds i32, i32* %27, i64 8
store i32 1, i32* %31
%32 = getelementptr inbounds i32, i32* %27, i64 9
store i32 1, i32* %32
%33 = getelementptr inbounds i32*, i32** %5, i64 4
%34 = load i32*, i32** %33
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %35
%36 = getelementptr inbounds i32, i32* %34, i64 4
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %37
%38 = getelementptr inbounds i32, i32* %34, i64 8
store i32 1, i32* %38
%39 = getelementptr inbounds i32, i32* %34, i64 9
store i32 1, i32* %39
%40 = getelementptr inbounds i32*, i32** %5, i64 5
%41 = load i32*, i32** %40
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %42
%43 = getelementptr inbounds i32, i32* %41, i64 4
%44 = bitcast i32* %43 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %44
%45 = getelementptr inbounds i32, i32* %41, i64 8
store i32 1, i32* %45
%46 = getelementptr inbounds i32, i32* %41, i64 9
store i32 1, i32* %46
%47 = getelementptr inbounds i32*, i32** %5, i64 6
%48 = load i32*, i32** %47
%49 = bitcast i32* %48 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %49
%50 = getelementptr inbounds i32, i32* %48, i64 4
%51 = bitcast i32* %50 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %51
%52 = getelementptr inbounds i32, i32* %48, i64 8
store i32 1, i32* %52
%53 = getelementptr inbounds i32, i32* %48, i64 9
store i32 1, i32* %53
%54 = getelementptr inbounds i32*, i32** %5, i64 7
%55 = load i32*, i32** %54
%56 = bitcast i32* %55 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %56
%57 = getelementptr inbounds i32, i32* %55, i64 4
%58 = bitcast i32* %57 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %58
%59 = getelementptr inbounds i32, i32* %55, i64 8
store i32 1, i32* %59
%60 = getelementptr inbounds i32, i32* %55, i64 9
store i32 1, i32* %60
%61 = getelementptr inbounds i32*, i32** %5, i64 8
%62 = load i32*, i32** %61
%63 = bitcast i32* %62 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %63
%64 = getelementptr inbounds i32, i32* %62, i64 4
%65 = bitcast i32* %64 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %65
%66 = getelementptr inbounds i32, i32* %62, i64 8
store i32 1, i32* %66
%67 = getelementptr inbounds i32, i32* %62, i64 9
store i32 1, i32* %67
%68 = getelementptr inbounds i32*, i32** %5, i64 9
%69 = load i32*, i32** %68
%70 = bitcast i32* %69 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %70
%71 = getelementptr inbounds i32, i32* %69, i64 4
%72 = bitcast i32* %71 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %72
%73 = getelementptr inbounds i32, i32* %69, i64 8
store i32 1, i32* %73
%74 = getelementptr inbounds i32, i32* %69, i64 9
store i32 1, i32* %74
%75 = add nuw nsw i64 %3, 1
%76 = icmp eq i64 %75, 10
br i1 %76, label %77, label %2
77: ; preds = %2
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
}