void aml_array_dbl_3d_copy(double ***dst, double ***src, int s1, int s2,
                           int s3) {
  int i, j, k;
  for (i = 0; i < s1; i++)
    for (j = 0; j < s2; j++)
      for (k = 0; k < s3; k++)
        dst[i][j][k] = src[i][j][k];
}


x86 assembly (clang, -O0):
<aml_array_dbl_3d_copy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bd <aml_array_dbl_3d_copy+0xbd>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11aa <aml_array_dbl_3d_copy+0xaa>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1197 <aml_array_dbl_3d_copy+0x97>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1143 <aml_array_dbl_3d_copy+0x43>
jmp    119c <aml_array_dbl_3d_copy+0x9c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1130 <aml_array_dbl_3d_copy+0x30>
jmp    11af <aml_array_dbl_3d_copy+0xaf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111d <aml_array_dbl_3d_copy+0x1d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_3d_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %ecx,-0x2c(%rsp)
test   %edx,%edx
jle    1321 <aml_array_dbl_3d_copy+0x221>
mov    %edx,%eax
mov    %rax,-0x28(%rsp)
mov    -0x2c(%rsp),%r13d
mov    %r8d,%eax
mov    %eax,%ecx
and    $0xfffffffc,%ecx
mov    %rcx,-0x8(%rsp)
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x10(%rsp)
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %ecx,%r11d
and    $0x3,%r11d
and    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x20(%rsp)
mov    %eax,%r12d
and    $0x3,%r12d
mov    %r11,-0x18(%rsp)
shl    $0x5,%r11
xor    %r15d,%r15d
jmp    117f <aml_array_dbl_3d_copy+0x7f>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15
cmp    -0x28(%rsp),%r15
je     1321 <aml_array_dbl_3d_copy+0x221>
cmpl   $0x0,-0x2c(%rsp)
jle    1170 <aml_array_dbl_3d_copy+0x70>
xor    %ebp,%ebp
jmp    1199 <aml_array_dbl_3d_copy+0x99>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %r13,%rbp
je     1170 <aml_array_dbl_3d_copy+0x70>
test   %r8d,%r8d
jle    1190 <aml_array_dbl_3d_copy+0x90>
mov    (%rsi,%r15,8),%rcx
mov    (%rcx,%rbp,8),%r9
mov    (%rdi,%r15,8),%rcx
mov    (%rcx,%rbp,8),%r14
cmp    $0x4,%r8d
jb     11ca <aml_array_dbl_3d_copy+0xca>
lea    (%r9,%rax,8),%rcx
cmp    %rcx,%r14
jae    1244 <aml_array_dbl_3d_copy+0x144>
lea    (%r14,%rax,8),%rcx
cmp    %rcx,%r9
jae    1244 <aml_array_dbl_3d_copy+0x144>
xor    %r10d,%r10d
mov    %r10,%rcx
not    %rcx
add    %rax,%rcx
test   %r12,%r12
je     11f6 <aml_array_dbl_3d_copy+0xf6>
mov    %r12,%rdx
xchg   %ax,%ax
movsd  (%r9,%r10,8),%xmm0
movsd  %xmm0,(%r14,%r10,8)
add    $0x1,%r10
add    $0xffffffffffffffff,%rdx
jne    11e0 <aml_array_dbl_3d_copy+0xe0>
cmp    $0x3,%rcx
jb     1190 <aml_array_dbl_3d_copy+0x90>
nopl   0x0(%rax)
movsd  (%r9,%r10,8),%xmm0
movsd  %xmm0,(%r14,%r10,8)
movsd  0x8(%r9,%r10,8),%xmm0
movsd  %xmm0,0x8(%r14,%r10,8)
movsd  0x10(%r9,%r10,8),%xmm0
movsd  %xmm0,0x10(%r14,%r10,8)
movsd  0x18(%r9,%r10,8),%xmm0
movsd  %xmm0,0x18(%r14,%r10,8)
add    $0x4,%r10
cmp    %r10,%rax
jne    1200 <aml_array_dbl_3d_copy+0x100>
jmp    1190 <aml_array_dbl_3d_copy+0x90>
cmpq   $0xc,-0x10(%rsp)
jae    1250 <aml_array_dbl_3d_copy+0x150>
xor    %ecx,%ecx
jmp    12c8 <aml_array_dbl_3d_copy+0x1c8>
mov    -0x20(%rsp),%rdx
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movups (%r9,%rcx,8),%xmm0
movups 0x10(%r9,%rcx,8),%xmm1
movups %xmm0,(%r14,%rcx,8)
movups %xmm1,0x10(%r14,%rcx,8)
movups 0x20(%r9,%rcx,8),%xmm0
movups 0x30(%r9,%rcx,8),%xmm1
movups %xmm0,0x20(%r14,%rcx,8)
movups %xmm1,0x30(%r14,%rcx,8)
movups 0x40(%r9,%rcx,8),%xmm0
movups 0x50(%r9,%rcx,8),%xmm1
movups %xmm0,0x40(%r14,%rcx,8)
movups %xmm1,0x50(%r14,%rcx,8)
movups 0x60(%r9,%rcx,8),%xmm0
movups 0x70(%r9,%rcx,8),%xmm1
movups %xmm0,0x60(%r14,%rcx,8)
movups %xmm1,0x70(%r14,%rcx,8)
add    $0x10,%rcx
add    $0xfffffffffffffffc,%rdx
jne    1260 <aml_array_dbl_3d_copy+0x160>
cmpq   $0x0,-0x18(%rsp)
je     130b <aml_array_dbl_3d_copy+0x20b>
lea    (%r14,%rcx,8),%rdx
add    $0x10,%rdx
lea    (%r9,%rcx,8),%rcx
add    $0x10,%rcx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups -0x10(%rcx,%rbx,1),%xmm0
movups (%rcx,%rbx,1),%xmm1
movups %xmm0,-0x10(%rdx,%rbx,1)
movups %xmm1,(%rdx,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r11
jne    12f0 <aml_array_dbl_3d_copy+0x1f0>
mov    -0x8(%rsp),%rcx
mov    %rcx,%r10
cmp    %rax,%rcx
je     1190 <aml_array_dbl_3d_copy+0x90>
jmp    11cd <aml_array_dbl_3d_copy+0xcd>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @aml_array_dbl_3d_copy(double*** nocapture %0, double*** nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %156
7: ; preds = %5
%8 = icmp sgt i32 %3, 0
%9 = icmp sgt i32 %4, 0
%10 = zext i32 %2 to i64
%11 = zext i32 %3 to i64
%12 = zext i32 %4 to i64
%13 = and i64 %12, 4294967292
%14 = add nsw i64 %13, -4
%15 = lshr exact i64 %14, 2
%16 = add nuw nsw i64 %15, 1
%17 = icmp ult i32 %4, 4
%18 = and i64 %12, 4294967292
%19 = and i64 %16, 3
%20 = icmp ult i64 %14, 12
%21 = and i64 %16, 9223372036854775804
%22 = icmp eq i64 %19, 0
%23 = icmp eq i64 %18, %12
%24 = and i64 %12, 3
%25 = icmp eq i64 %24, 0
br label %26
26: ; preds = %7, %153
%27 = phi i64 [ 0, %7 ], [ %154, %153 ]
br i1 %8, label %28, label %153
28: ; preds = %26
%29 = getelementptr inbounds double**, double*** %1, i64 %27
%30 = getelementptr inbounds double**, double*** %0, i64 %27
br label %31
31: ; preds = %28, %150
%32 = phi i64 [ 0, %28 ], [ %151, %150 ]
br i1 %9, label %33, label %150
33: ; preds = %31
%34 = load double**, double*** %29
%35 = getelementptr inbounds double*, double** %34, i64 %32
%36 = load double*, double** %35
%37 = load double**, double*** %30
%38 = getelementptr inbounds double*, double** %37, i64 %32
%39 = load double*, double** %38
br i1 %17, label %115, label %40
40: ; preds = %33
%41 = getelementptr double, double* %39, i64 %12
%42 = getelementptr double, double* %36, i64 %12
%43 = icmp ult double* %39, %42
%44 = icmp ult double* %36, %41
%45 = and i1 %43, %44
br i1 %45, label %115, label %46
46: ; preds = %40
br i1 %20, label %96, label %47
47: ; preds = %46, %47
%48 = phi i64 [ %93, %47 ], [ 0, %46 ]
%49 = phi i64 [ %94, %47 ], [ 0, %46 ]
%50 = getelementptr inbounds double, double* %36, i64 %48
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds double, double* %50, i64 2
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %39, i64 %48
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> %52, <2 x double>* %57
%58 = getelementptr inbounds double, double* %56, i64 2
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %55, <2 x double>* %59
%60 = or i64 %48, 4
%61 = getelementptr inbounds double, double* %36, i64 %60
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = getelementptr inbounds double, double* %39, i64 %60
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> %63, <2 x double>* %68
%69 = getelementptr inbounds double, double* %67, i64 2
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %66, <2 x double>* %70
%71 = or i64 %48, 8
%72 = getelementptr inbounds double, double* %36, i64 %71
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = getelementptr inbounds double, double* %72, i64 2
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = getelementptr inbounds double, double* %39, i64 %71
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> %74, <2 x double>* %79
%80 = getelementptr inbounds double, double* %78, i64 2
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %77, <2 x double>* %81
%82 = or i64 %48, 12
%83 = getelementptr inbounds double, double* %36, i64 %82
%84 = bitcast double* %83 to <2 x double>*
%85 = load <2 x double>, <2 x double>* %84
%86 = getelementptr inbounds double, double* %83, i64 2
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = getelementptr inbounds double, double* %39, i64 %82
%90 = bitcast double* %89 to <2 x double>*
store <2 x double> %85, <2 x double>* %90
%91 = getelementptr inbounds double, double* %89, i64 2
%92 = bitcast double* %91 to <2 x double>*
store <2 x double> %88, <2 x double>* %92
%93 = add nuw i64 %48, 16
%94 = add nuw i64 %49, 4
%95 = icmp eq i64 %94, %21
br i1 %95, label %96, label %47
96: ; preds = %47, %46
%97 = phi i64 [ 0, %46 ], [ %93, %47 ]
br i1 %22, label %114, label %98
98: ; preds = %96, %98
%99 = phi i64 [ %111, %98 ], [ %97, %96 ]
%100 = phi i64 [ %112, %98 ], [ 0, %96 ]
%101 = getelementptr inbounds double, double* %36, i64 %99
%102 = bitcast double* %101 to <2 x double>*
%103 = load <2 x double>, <2 x double>* %102
%104 = getelementptr inbounds double, double* %101, i64 2
%105 = bitcast double* %104 to <2 x double>*
%106 = load <2 x double>, <2 x double>* %105
%107 = getelementptr inbounds double, double* %39, i64 %99
%108 = bitcast double* %107 to <2 x double>*
store <2 x double> %103, <2 x double>* %108
%109 = getelementptr inbounds double, double* %107, i64 2
%110 = bitcast double* %109 to <2 x double>*
store <2 x double> %106, <2 x double>* %110
%111 = add nuw i64 %99, 4
%112 = add i64 %100, 1
%113 = icmp eq i64 %112, %19
br i1 %113, label %114, label %98
114: ; preds = %98, %96
br i1 %23, label %150, label %115
115: ; preds = %40, %33, %114
%116 = phi i64 [ 0, %40 ], [ 0, %33 ], [ %18, %114 ]
%117 = xor i64 %116, -1
%118 = add nsw i64 %117, %12
br i1 %25, label %128, label %119
119: ; preds = %115, %119
%120 = phi i64 [ %125, %119 ], [ %116, %115 ]
%121 = phi i64 [ %126, %119 ], [ 0, %115 ]
%122 = getelementptr inbounds double, double* %36, i64 %120
%123 = load double, double* %122
%124 = getelementptr inbounds double, double* %39, i64 %120
store double %123, double* %124
%125 = add nuw nsw i64 %120, 1
%126 = add i64 %121, 1
%127 = icmp eq i64 %126, %24
br i1 %127, label %128, label %119
128: ; preds = %119, %115
%129 = phi i64 [ %116, %115 ], [ %125, %119 ]
%130 = icmp ult i64 %118, 3
br i1 %130, label %150, label %131
131: ; preds = %128, %131
%132 = phi i64 [ %148, %131 ], [ %129, %128 ]
%133 = getelementptr inbounds double, double* %36, i64 %132
%134 = load double, double* %133
%135 = getelementptr inbounds double, double* %39, i64 %132
store double %134, double* %135
%136 = add nuw nsw i64 %132, 1
%137 = getelementptr inbounds double, double* %36, i64 %136
%138 = load double, double* %137
%139 = getelementptr inbounds double, double* %39, i64 %136
store double %138, double* %139
%140 = add nuw nsw i64 %132, 2
%141 = getelementptr inbounds double, double* %36, i64 %140
%142 = load double, double* %141
%143 = getelementptr inbounds double, double* %39, i64 %140
store double %142, double* %143
%144 = add nuw nsw i64 %132, 3
%145 = getelementptr inbounds double, double* %36, i64 %144
%146 = load double, double* %145
%147 = getelementptr inbounds double, double* %39, i64 %144
store double %146, double* %147
%148 = add nuw nsw i64 %132, 4
%149 = icmp eq i64 %148, %12
br i1 %149, label %150, label %131
150: ; preds = %128, %131, %114, %31
%151 = add nuw nsw i64 %32, 1
%152 = icmp eq i64 %151, %11
br i1 %152, label %153, label %31
153: ; preds = %150, %26
%154 = add nuw nsw i64 %27, 1
%155 = icmp eq i64 %154, %10
br i1 %155, label %156, label %26
156: ; preds = %153, %5
ret void
}