#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 /*<<< orphan*/ printf(char *, ...);
void dump_3d(int c, int r, int z, double *array) {
  printf("I am computing d!\n");
  int i, j, k;
  for (i = 0; i < z; i++) {
    for (k = 0; k < c; k++) {
      for (j = 0; j < r; j++) {
        printf("%f ", array[(i * c + k) * r + j]);
      }
      printf("\n");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump_3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dd <dump_3d+0xcd>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c1 <dump_3d+0xb1>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a5 <dump_3d+0x95>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe83(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1160 <dump_3d+0x50>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <dump_3d+0x3d>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <dump_3d+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,0x10(%rsp)
mov    %edx,%ebx
mov    %esi,0xc(%rsp)
mov    %edi,0x8(%rsp)
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
jle    122b <dump_3d+0xfb>
movslq 0xc(%rsp),%r14
movslq 0x8(%rsp),%rax
mov    %ebx,%ecx
mov    %rcx,0x18(%rsp)
mov    %eax,%ecx
mov    %rcx,0x30(%rsp)
mov    %r14d,%r13d
imul   %r14,%rax
shl    $0x3,%rax
mov    %rax,0x20(%rsp)
shl    $0x3,%r14
xor    %ecx,%ecx
lea    0xe6a(%rip),%rbx
jmp    11c4 <dump_3d+0x94>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x28(%rsp),%rcx
add    $0x1,%rcx
mov    0x20(%rsp),%rax
add    %rax,0x10(%rsp)
cmp    0x18(%rsp),%rcx
je     122b <dump_3d+0xfb>
mov    %rcx,0x28(%rsp)
cmpl   $0x0,0x8(%rsp)
jle    11a0 <dump_3d+0x70>
mov    0x10(%rsp),%r15
xor    %r12d,%r12d
jmp    11f8 <dump_3d+0xc8>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
add    %r14,%r15
cmp    0x30(%rsp),%r12
je     11a0 <dump_3d+0x70>
cmpl   $0x0,0xc(%rsp)
jle    11e0 <dump_3d+0xb0>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%rbp,8),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1210 <dump_3d+0xe0>
jmp    11e0 <dump_3d+0xb0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%f \00"
@str = [18 x i8] c"I am computing d!\00"
define void @dump_3d(i32 %0, i32 %1, i32 %2, double* nocapture %3) {
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %40
7: ; preds = %4
%8 = icmp sgt i32 %0, 0
%9 = icmp sgt i32 %1, 0
%10 = sext i32 %1 to i64
%11 = sext i32 %0 to i64
%12 = zext i32 %2 to i64
%13 = zext i32 %0 to i64
%14 = zext i32 %1 to i64
br label %15
15: ; preds = %7, %36
%16 = phi i64 [ 0, %7 ], [ %38, %36 ]
br i1 %8, label %17, label %36
17: ; preds = %15
%18 = mul nsw i64 %16, %11
br label %19
19: ; preds = %17, %32
%20 = phi i64 [ 0, %17 ], [ %34, %32 ]
br i1 %9, label %21, label %32
21: ; preds = %19
%22 = add nsw i64 %20, %18
%23 = mul nsw i64 %22, %10
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ 0, %21 ], [ %30, %24 ]
%26 = add nsw i64 %25, %23
%27 = getelementptr inbounds double, double* %3, i64 %26
%28 = load double, double* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = add nuw nsw i64 %25, 1
%31 = icmp eq i64 %30, %14
br i1 %31, label %32, label %24
32: ; preds = %24, %19
%33 = tail call i32 @putchar(i32 10)
%34 = add nuw nsw i64 %20, 1
%35 = icmp eq i64 %34, %13
br i1 %35, label %36, label %19
36: ; preds = %32, %15
%37 = tail call i32 @putchar(i32 10)
%38 = add nuw nsw i64 %16, 1
%39 = icmp eq i64 %38, %12
br i1 %39, label %40, label %15
40: ; preds = %36, %4
ret void
}