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


x86 assembly (clang, -O0):
<aml_array_dbl_4d_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)
mov    %r9d,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f7 <aml_array_dbl_4d_copy+0xf7>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e4 <aml_array_dbl_4d_copy+0xe4>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d1 <aml_array_dbl_4d_copy+0xd1>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11be <aml_array_dbl_4d_copy+0xbe>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    115a <aml_array_dbl_4d_copy+0x5a>
jmp    11c3 <aml_array_dbl_4d_copy+0xc3>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1147 <aml_array_dbl_4d_copy+0x47>
jmp    11d6 <aml_array_dbl_4d_copy+0xd6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1134 <aml_array_dbl_4d_copy+0x34>
jmp    11e9 <aml_array_dbl_4d_copy+0xe9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1121 <aml_array_dbl_4d_copy+0x21>
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_4d_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8d,-0x4c(%rsp)
mov    %ecx,-0x50(%rsp)
test   %edx,%edx
jle    1370 <aml_array_dbl_4d_copy+0x270>
mov    %edx,%eax
mov    %rax,-0x48(%rsp)
mov    -0x50(%rsp),%eax
mov    %rax,-0x40(%rsp)
mov    -0x4c(%rsp),%r14d
mov    %r9d,%edx
mov    %edx,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x18(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %eax,%r12d
and    $0x3,%r12d
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x38(%rsp)
mov    %edx,%ebp
and    $0x3,%ebp
mov    %r12,-0x28(%rsp)
shl    $0x5,%r12
xor    %r10d,%r10d
mov    %rsi,-0x8(%rsp)
mov    %rdi,-0x10(%rsp)
mov    %rbp,-0x30(%rsp)
jmp    118f <aml_array_dbl_4d_copy+0x8f>
add    $0x1,%r10
cmp    -0x48(%rsp),%r10
je     1370 <aml_array_dbl_4d_copy+0x270>
cmpl   $0x0,-0x50(%rsp)
jle    1180 <aml_array_dbl_4d_copy+0x80>
xor    %r11d,%r11d
jmp    11ab <aml_array_dbl_4d_copy+0xab>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r11
cmp    -0x40(%rsp),%r11
je     1180 <aml_array_dbl_4d_copy+0x80>
cmpl   $0x0,-0x4c(%rsp)
jle    11a0 <aml_array_dbl_4d_copy+0xa0>
xor    %ecx,%ecx
jmp    11c9 <aml_array_dbl_4d_copy+0xc9>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %r14,%rcx
je     11a0 <aml_array_dbl_4d_copy+0xa0>
test   %r9d,%r9d
jle    11c0 <aml_array_dbl_4d_copy+0xc0>
mov    (%rsi,%r10,8),%rax
mov    (%rax,%r11,8),%rax
mov    (%rax,%rcx,8),%r8
mov    (%rdi,%r10,8),%rax
mov    (%rax,%r11,8),%rax
mov    (%rax,%rcx,8),%r15
cmp    $0x4,%r9d
jb     1206 <aml_array_dbl_4d_copy+0x106>
lea    (%r8,%rdx,8),%rax
cmp    %rax,%r15
jae    1284 <aml_array_dbl_4d_copy+0x184>
lea    (%r15,%rdx,8),%rax
cmp    %rax,%r8
jae    1284 <aml_array_dbl_4d_copy+0x184>
xor    %r13d,%r13d
mov    %r13,%rax
not    %rax
add    %rdx,%rax
test   %rbp,%rbp
je     1236 <aml_array_dbl_4d_copy+0x136>
mov    %rbp,%rbx
nopw   0x0(%rax,%rax,1)
movsd  (%r8,%r13,8),%xmm0
movsd  %xmm0,(%r15,%r13,8)
add    $0x1,%r13
add    $0xffffffffffffffff,%rbx
jne    1220 <aml_array_dbl_4d_copy+0x120>
cmp    $0x3,%rax
jb     11c0 <aml_array_dbl_4d_copy+0xc0>
nopl   0x0(%rax)
movsd  (%r8,%r13,8),%xmm0
movsd  %xmm0,(%r15,%r13,8)
movsd  0x8(%r8,%r13,8),%xmm0
movsd  %xmm0,0x8(%r15,%r13,8)
movsd  0x10(%r8,%r13,8),%xmm0
movsd  %xmm0,0x10(%r15,%r13,8)
movsd  0x18(%r8,%r13,8),%xmm0
movsd  %xmm0,0x18(%r15,%r13,8)
add    $0x4,%r13
cmp    %r13,%rdx
jne    1240 <aml_array_dbl_4d_copy+0x140>
jmp    11c0 <aml_array_dbl_4d_copy+0xc0>
cmpq   $0xc,-0x20(%rsp)
jae    1290 <aml_array_dbl_4d_copy+0x190>
xor    %ebx,%ebx
jmp    1308 <aml_array_dbl_4d_copy+0x208>
mov    -0x38(%rsp),%rax
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movups (%r8,%rbx,8),%xmm0
movups 0x10(%r8,%rbx,8),%xmm1
movups %xmm0,(%r15,%rbx,8)
movups %xmm1,0x10(%r15,%rbx,8)
movups 0x20(%r8,%rbx,8),%xmm0
movups 0x30(%r8,%rbx,8),%xmm1
movups %xmm0,0x20(%r15,%rbx,8)
movups %xmm1,0x30(%r15,%rbx,8)
movups 0x40(%r8,%rbx,8),%xmm0
movups 0x50(%r8,%rbx,8),%xmm1
movups %xmm0,0x40(%r15,%rbx,8)
movups %xmm1,0x50(%r15,%rbx,8)
movups 0x60(%r8,%rbx,8),%xmm0
movups 0x70(%r8,%rbx,8),%xmm1
movups %xmm0,0x60(%r15,%rbx,8)
movups %xmm1,0x70(%r15,%rbx,8)
add    $0x10,%rbx
add    $0xfffffffffffffffc,%rax
jne    12a0 <aml_array_dbl_4d_copy+0x1a0>
cmpq   $0x0,-0x28(%rsp)
je     134b <aml_array_dbl_4d_copy+0x24b>
lea    (%r15,%rbx,8),%rax
add    $0x10,%rax
lea    (%r8,%rbx,8),%rbx
add    $0x10,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups -0x10(%rbx,%rbp,1),%xmm0
movups (%rbx,%rbp,1),%xmm1
movups %xmm0,-0x10(%rax,%rbp,1)
movups %xmm1,(%rax,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%r12
jne    1330 <aml_array_dbl_4d_copy+0x230>
mov    -0x18(%rsp),%rax
mov    %rax,%r13
cmp    %rdx,%rax
mov    -0x8(%rsp),%rsi
mov    -0x10(%rsp),%rdi
mov    -0x30(%rsp),%rbp
je     11c0 <aml_array_dbl_4d_copy+0xc0>
jmp    1209 <aml_array_dbl_4d_copy+0x109>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @aml_array_dbl_4d_copy(double**** %0, double**** %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double****
%8 = alloca double****
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store double**** %0, double***** %7
store double**** %1, double***** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store i32 0, i32* %13
br label %17
17: ; preds = %82, %6
%18 = load i32, i32* %13
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %85
21: ; preds = %17
store i32 0, i32* %14
br label %22
22: ; preds = %78, %21
%23 = load i32, i32* %14
%24 = load i32, i32* %10
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %81
26: ; preds = %22
store i32 0, i32* %15
br label %27
27: ; preds = %74, %26
%28 = load i32, i32* %15
%29 = load i32, i32* %11
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %77
31: ; preds = %27
store i32 0, i32* %16
br label %32
32: ; preds = %70, %31
%33 = load i32, i32* %16
%34 = load i32, i32* %12
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %73
36: ; preds = %32
%37 = load double****, double***** %8
%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 i32, i32* %14
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double**, double*** %41, i64 %43
%45 = load double**, double*** %44
%46 = load i32, i32* %15
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double*, double** %45, i64 %47
%49 = load double*, double** %48
%50 = load i32, i32* %16
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = load double****, double***** %7
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double***, double**** %54, i64 %56
%58 = load double***, double**** %57
%59 = load i32, i32* %14
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double**, double*** %58, i64 %60
%62 = load double**, double*** %61
%63 = load i32, i32* %15
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double*, double** %62, i64 %64
%66 = load double*, double** %65
%67 = load i32, i32* %16
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
store double %53, double* %69
br label %70
70: ; preds = %36
%71 = load i32, i32* %16
%72 = add nsw i32 %71, 1
store i32 %72, i32* %16
br label %32
73: ; preds = %32
br label %74
74: ; preds = %73
%75 = load i32, i32* %15
%76 = add nsw i32 %75, 1
store i32 %76, i32* %15
br label %27
77: ; preds = %27
br label %78
78: ; preds = %77
%79 = load i32, i32* %14
%80 = add nsw i32 %79, 1
store i32 %80, i32* %14
br label %22
81: ; preds = %22
br label %82
82: ; preds = %81
%83 = load i32, i32* %13
%84 = add nsw i32 %83, 1
store i32 %84, i32* %13
br label %17
85: ; preds = %17
ret void
}

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