#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__ rand();
void random_matrix_long_3d(long ***a, const unsigned int rows,
                           const unsigned int cols, const unsigned int dimz) {
  for (unsigned int z = 0; z < dimz; z++) {
    for (unsigned int r = 0; r < rows; r++) {
      for (unsigned int c = 0; c < cols; c++) {
        a[z][r][c] = (long)rand();
      }
    }
  }
}


x86 assembly (clang, -O0):
<random_matrix_long_3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11b5 <random_matrix_long_3d+0xa5>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a2 <random_matrix_long_3d+0x92>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    118f <random_matrix_long_3d+0x7f>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <random_matrix_long_3d+0x42>
jmp    1194 <random_matrix_long_3d+0x84>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <random_matrix_long_3d+0x2f>
jmp    11a7 <random_matrix_long_3d+0x97>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <random_matrix_long_3d+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_matrix_long_3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
mov    %esi,0x8(%rsp)
test   %ecx,%ecx
je     11af <random_matrix_long_3d+0x9f>
mov    %rdi,%rbp
mov    %ecx,%eax
mov    %rax,0x10(%rsp)
mov    0x8(%rsp),%r13d
mov    0xc(%rsp),%ebx
xor    %r14d,%r14d
jmp    115b <random_matrix_long_3d+0x4b>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11af <random_matrix_long_3d+0x9f>
cmpl   $0x0,0x8(%rsp)
je     1150 <random_matrix_long_3d+0x40>
xor    %r15d,%r15d
jmp    1179 <random_matrix_long_3d+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r13,%r15
je     1150 <random_matrix_long_3d+0x40>
cmpl   $0x0,0xc(%rsp)
je     1170 <random_matrix_long_3d+0x60>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <rand@plt>
mov    0x0(%rbp,%r14,8),%rcx
mov    (%rcx,%r15,8),%rcx
mov    %rax,(%rcx,%r12,8)
add    $0x1,%r12
cmp    %r12,%rbx
jne    1190 <random_matrix_long_3d+0x80>
jmp    1170 <random_matrix_long_3d+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @random_matrix_long_3d(i64*** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i64***
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i64*** %0, i64**** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %48, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %51
16: ; preds = %12
store i32 0, i32* %10
br label %17
17: ; preds = %44, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %6
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %47
21: ; preds = %17
store i32 0, i32* %11
br label %22
22: ; preds = %40, %21
%23 = load i32, i32* %11
%24 = load i32, i32* %7
%25 = icmp ult i32 %23, %24
br i1 %25, label %26, label %43
26: ; preds = %22
%27 = call i64 (...) @rand()
%28 = load i64***, i64**** %5
%29 = load i32, i32* %9
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i64**, i64*** %28, i64 %30
%32 = load i64**, i64*** %31
%33 = load i32, i32* %10
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i64*, i64** %32, i64 %34
%36 = load i64*, i64** %35
%37 = load i32, i32* %11
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i64, i64* %36, i64 %38
store i64 %27, i64* %39
br label %40
40: ; preds = %26
%41 = load i32, i32* %11
%42 = add i32 %41, 1
store i32 %42, i32* %11
br label %22
43: ; preds = %22
br label %44
44: ; preds = %43
%45 = load i32, i32* %10
%46 = add i32 %45, 1
store i32 %46, i32* %10
br label %17
47: ; preds = %17
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add i32 %49, 1
store i32 %50, i32* %9
br label %12
51: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @random_matrix_long_3d(i64*** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %16, label %6
6: ; preds = %4
%7 = icmp eq i32 %1, 0
%8 = icmp eq i32 %2, 0
%9 = zext i32 %3 to i64
%10 = zext i32 %1 to i64
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %6, %19
%13 = phi i64 [ 0, %6 ], [ %20, %19 ]
br i1 %7, label %19, label %14
14: ; preds = %12
%15 = getelementptr inbounds i64**, i64*** %0, i64 %13
br label %17
16: ; preds = %19, %4
ret void
17: ; preds = %14, %22
%18 = phi i64 [ 0, %14 ], [ %23, %22 ]
br i1 %8, label %22, label %25
19: ; preds = %22, %12
%20 = add nuw nsw i64 %13, 1
%21 = icmp eq i64 %20, %9
br i1 %21, label %16, label %12
22: ; preds = %25, %17
%23 = add nuw nsw i64 %18, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %19, label %17
25: ; preds = %17, %25
%26 = phi i64 [ %32, %25 ], [ 0, %17 ]
%27 = tail call i64 (...) @rand()
%28 = load i64**, i64*** %15
%29 = getelementptr inbounds i64*, i64** %28, i64 %18
%30 = load i64*, i64** %29
%31 = getelementptr inbounds i64, i64* %30, i64 %26
store i64 %27, i64* %31
%32 = add nuw nsw i64 %26, 1
%33 = icmp eq i64 %32, %11
br i1 %33, label %22, label %25
}