#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*/ free(double *);
size_t ind3D(int, int, int, int, int, int);
void reduce3Darray(double *old_array, int old_nrow, int old_ncol, int old_ndep,
                   double *new_array, int new_nrow, int new_ncol,
                   int new_ndep) {
  int ii, jj, kk;
  for (ii = 0; ii < new_nrow; ii++) {
    for (jj = 0; jj < new_ncol; jj++) {
      for (kk = 0; kk < new_ndep; kk++) {
        new_array[ind3D(ii, jj, kk, new_nrow, new_ncol, new_ndep)] =
            old_array[ind3D(ii, jj, kk, old_nrow, old_ncol, old_ndep)];
      }
    }
  }
  free(old_array);
}


x86 assembly (clang, -O0):
<reduce3Darray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1214 <reduce3Darray+0xf4>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1201 <reduce3Darray+0xe1>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    11ee <reduce3Darray+0xce>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
call   1040 <ind3D@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9d
call   1040 <ind3D@plt>
movsd  -0x40(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1170 <reduce3Darray+0x50>
jmp    11f3 <reduce3Darray+0xd3>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115d <reduce3Darray+0x3d>
jmp    1206 <reduce3Darray+0xe6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114a <reduce3Darray+0x2a>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reduce3Darray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,0x10(%rsp)
test   %r9d,%r9d
jle    1217 <reduce3Darray+0xf7>
mov    %ecx,%eax
mov    %edx,%ebx
mov    %esi,%r12d
mov    0x68(%rsp),%edx
mov    0x60(%rsp),%esi
xor    %edi,%edi
mov    %r9d,0x4(%rsp)
mov    %esi,0x8(%rsp)
mov    %ecx,0xc(%rsp)
mov    %r8,0x18(%rsp)
jmp    1184 <reduce3Darray+0x64>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%edi
add    $0x1,%edi
mov    0x4(%rsp),%r9d
cmp    %r9d,%edi
je     1217 <reduce3Darray+0xf7>
mov    %edi,(%rsp)
test   %esi,%esi
jle    1170 <reduce3Darray+0x50>
xor    %r14d,%r14d
jmp    11a0 <reduce3Darray+0x80>
add    $0x1,%r14d
mov    0x8(%rsp),%esi
cmp    %esi,%r14d
mov    %r9d,%edx
je     1170 <reduce3Darray+0x50>
test   %edx,%edx
mov    %edx,%r9d
mov    (%rsp),%r15d
jle    1190 <reduce3Darray+0x70>
xor    %ebp,%ebp
nopl   (%rax)
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %ebx,%r8d
mov    %r9d,%r13d
mov    %eax,%r9d
call   1040 <ind3D@plt>
mov    0x10(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    %r13d,%r9d
call   1040 <ind3D@plt>
mov    %r13d,%r9d
mov    0x18(%rsp),%r8
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r8,%rax,8)
mov    0xc(%rsp),%eax
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    11b0 <reduce3Darray+0x90>
jmp    1190 <reduce3Darray+0x70>
mov    0x10(%rsp),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @reduce3Darray(double* %0, i32 %1, i32 %2, i32 %3, double* %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store double* %0, double** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store double* %4, double** %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
store i32 0, i32* %17
br label %20
20: ; preds = %62, %8
%21 = load i32, i32* %17
%22 = load i32, i32* %14
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %65
24: ; preds = %20
store i32 0, i32* %18
br label %25
25: ; preds = %58, %24
%26 = load i32, i32* %18
%27 = load i32, i32* %15
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %61
29: ; preds = %25
store i32 0, i32* %19
br label %30
30: ; preds = %54, %29
%31 = load i32, i32* %19
%32 = load i32, i32* %16
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %57
34: ; preds = %30
%35 = load double*, double** %9
%36 = load i32, i32* %17
%37 = load i32, i32* %18
%38 = load i32, i32* %19
%39 = load i32, i32* %10
%40 = load i32, i32* %11
%41 = load i32, i32* %12
%42 = call i64 @ind3D(i32 %36, i32 %37, i32 %38, i32 %39, i32 %40, i32 %41)
%43 = getelementptr inbounds double, double* %35, i64 %42
%44 = load double, double* %43
%45 = load double*, double** %13
%46 = load i32, i32* %17
%47 = load i32, i32* %18
%48 = load i32, i32* %19
%49 = load i32, i32* %14
%50 = load i32, i32* %15
%51 = load i32, i32* %16
%52 = call i64 @ind3D(i32 %46, i32 %47, i32 %48, i32 %49, i32 %50, i32 %51)
%53 = getelementptr inbounds double, double* %45, i64 %52
store double %44, double* %53
br label %54
54: ; preds = %34
%55 = load i32, i32* %19
%56 = add nsw i32 %55, 1
store i32 %56, i32* %19
br label %30
57: ; preds = %30
br label %58
58: ; preds = %57
%59 = load i32, i32* %18
%60 = add nsw i32 %59, 1
store i32 %60, i32* %18
br label %25
61: ; preds = %25
br label %62
62: ; preds = %61
%63 = load i32, i32* %17
%64 = add nsw i32 %63, 1
store i32 %64, i32* %17
br label %20
65: ; preds = %20
%66 = load double*, double** %9
%67 = call i32 @free(double* %66)
ret void
}

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