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


x86 assembly (clang, -O0):
<aml_array_dbl_2d_variable_2nd_copy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118c <aml_array_dbl_2d_variable_2nd_copy+0x8c>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1179 <aml_array_dbl_2d_variable_2nd_copy+0x79>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%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    112d <aml_array_dbl_2d_variable_2nd_copy+0x2d>
jmp    117e <aml_array_dbl_2d_variable_2nd_copy+0x7e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111a <aml_array_dbl_2d_variable_2nd_copy+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_2d_variable_2nd_copy>:
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    12ad <aml_array_dbl_2d_variable_2nd_copy+0x1ad>
mov    %edx,%r8d
xor    %r9d,%r9d
jmp    112d <aml_array_dbl_2d_variable_2nd_copy+0x2d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r9
cmp    %r8,%r9
je     12ad <aml_array_dbl_2d_variable_2nd_copy+0x1ad>
mov    (%rcx,%r9,4),%r10d
test   %r10d,%r10d
jle    1120 <aml_array_dbl_2d_variable_2nd_copy+0x20>
mov    (%rsi,%r9,8),%r11
mov    (%rdi,%r9,8),%rax
cmp    $0x4,%r10d
jb     115a <aml_array_dbl_2d_variable_2nd_copy+0x5a>
lea    (%r11,%r10,8),%rdx
cmp    %rdx,%rax
jae    11d0 <aml_array_dbl_2d_variable_2nd_copy+0xd0>
lea    (%rax,%r10,8),%rdx
cmp    %rdx,%r11
jae    11d0 <aml_array_dbl_2d_variable_2nd_copy+0xd0>
xor    %edx,%edx
mov    %rdx,%r14
not    %r14
add    %r10,%r14
mov    %r10,%rbx
and    $0x3,%rbx
je     1185 <aml_array_dbl_2d_variable_2nd_copy+0x85>
xchg   %ax,%ax
movsd  (%r11,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rbx
jne    1170 <aml_array_dbl_2d_variable_2nd_copy+0x70>
cmp    $0x3,%r14
jb     1120 <aml_array_dbl_2d_variable_2nd_copy+0x20>
nopl   0x0(%rax,%rax,1)
movsd  (%r11,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
movsd  0x8(%r11,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rdx,8)
movsd  0x10(%r11,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rax,%rdx,8)
movsd  0x18(%r11,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rax,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%r10
jne    1190 <aml_array_dbl_2d_variable_2nd_copy+0x90>
jmp    1120 <aml_array_dbl_2d_variable_2nd_copy+0x20>
mov    %r10d,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rbx
mov    %rbx,%r15
shr    $0x2,%r15
add    $0x1,%r15
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0xc,%rbx
jae    11f6 <aml_array_dbl_2d_variable_2nd_copy+0xf6>
xor    %ebx,%ebx
jmp    1260 <aml_array_dbl_2d_variable_2nd_copy+0x160>
and    $0xfffffffffffffffc,%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movups (%r11,%rbx,8),%xmm0
movups 0x10(%r11,%rbx,8),%xmm1
movups %xmm0,(%rax,%rbx,8)
movups %xmm1,0x10(%rax,%rbx,8)
movups 0x20(%r11,%rbx,8),%xmm0
movups 0x30(%r11,%rbx,8),%xmm1
movups %xmm0,0x20(%rax,%rbx,8)
movups %xmm1,0x30(%rax,%rbx,8)
movups 0x40(%r11,%rbx,8),%xmm0
movups 0x50(%r11,%rbx,8),%xmm1
movups %xmm0,0x40(%rax,%rbx,8)
movups %xmm1,0x50(%rax,%rbx,8)
movups 0x60(%r11,%rbx,8),%xmm0
movups 0x70(%r11,%rbx,8),%xmm1
movups %xmm0,0x60(%rax,%rbx,8)
movups %xmm1,0x70(%rax,%rbx,8)
add    $0x10,%rbx
add    $0xfffffffffffffffc,%r15
jne    1200 <aml_array_dbl_2d_variable_2nd_copy+0x100>
test   %r14,%r14
je     129f <aml_array_dbl_2d_variable_2nd_copy+0x19f>
lea    (%rax,%rbx,8),%r15
add    $0x10,%r15
lea    (%r11,%rbx,8),%r12
add    $0x10,%r12
shl    $0x5,%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movups -0x10(%r12,%rbx,1),%xmm0
movups (%r12,%rbx,1),%xmm1
movups %xmm0,-0x10(%r15,%rbx,1)
movups %xmm1,(%r15,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r14
jne    1280 <aml_array_dbl_2d_variable_2nd_copy+0x180>
cmp    %r10,%rdx
je     1120 <aml_array_dbl_2d_variable_2nd_copy+0x20>
jmp    115c <aml_array_dbl_2d_variable_2nd_copy+0x5c>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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