#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_double_3d(double ***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] = (double)rand();
      }
    }
  }
}


x86 assembly (clang, -O0):
<random_matrix_double_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    11b8 <random_matrix_double_3d+0xa8>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a5 <random_matrix_double_3d+0x95>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1192 <random_matrix_double_3d+0x82>
mov    $0x0,%al
call   1030 <rand@plt>
cvtsi2sd %rax,%xmm0
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
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <random_matrix_double_3d+0x42>
jmp    1197 <random_matrix_double_3d+0x87>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <random_matrix_double_3d+0x2f>
jmp    11aa <random_matrix_double_3d+0x9a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <random_matrix_double_3d+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_matrix_double_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     11b9 <random_matrix_double_3d+0xa9>
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_double_3d+0x4b>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11b9 <random_matrix_double_3d+0xa9>
cmpl   $0x0,0x8(%rsp)
je     1150 <random_matrix_double_3d+0x40>
xor    %r15d,%r15d
jmp    1179 <random_matrix_double_3d+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r13,%r15
je     1150 <random_matrix_double_3d+0x40>
cmpl   $0x0,0xc(%rsp)
je     1170 <random_matrix_double_3d+0x60>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x0(%rbp,%r14,8),%rax
mov    (%rax,%r15,8),%rax
movsd  %xmm0,(%rax,%r12,8)
add    $0x1,%r12
cmp    %r12,%rbx
jne    1190 <random_matrix_double_3d+0x80>
jmp    1170 <random_matrix_double_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_double_3d(double*** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double***
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store double*** %0, double**** %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 = %49, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %52
16: ; preds = %12
store i32 0, i32* %10
br label %17
17: ; preds = %45, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %6
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %48
21: ; preds = %17
store i32 0, i32* %11
br label %22
22: ; preds = %41, %21
%23 = load i32, i32* %11
%24 = load i32, i32* %7
%25 = icmp ult i32 %23, %24
br i1 %25, label %26, label %44
26: ; preds = %22
%27 = call i64 (...) @rand()
%28 = sitofp i64 %27 to double
%29 = load double***, double**** %5
%30 = load i32, i32* %9
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds double**, double*** %29, i64 %31
%33 = load double**, double*** %32
%34 = load i32, i32* %10
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds double*, double** %33, i64 %35
%37 = load double*, double** %36
%38 = load i32, i32* %11
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %28, double* %40
br label %41
41: ; preds = %26
%42 = load i32, i32* %11
%43 = add i32 %42, 1
store i32 %43, i32* %11
br label %22
44: ; preds = %22
br label %45
45: ; preds = %44
%46 = load i32, i32* %10
%47 = add i32 %46, 1
store i32 %47, i32* %10
br label %17
48: ; preds = %17
br label %49
49: ; preds = %48
%50 = load i32, i32* %9
%51 = add i32 %50, 1
store i32 %51, i32* %9
br label %12
52: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @random_matrix_double_3d(double*** 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 double**, double*** %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 [ %33, %25 ], [ 0, %17 ]
%27 = tail call i64 (...) @rand()
%28 = sitofp i64 %27 to double
%29 = load double**, double*** %15
%30 = getelementptr inbounds double*, double** %29, i64 %18
%31 = load double*, double** %30
%32 = getelementptr inbounds double, double* %31, i64 %26
store double %28, double* %32
%33 = add nuw nsw i64 %26, 1
%34 = icmp eq i64 %33, %11
br i1 %34, label %22, label %25
}