void aml_array_dbl_2d_fill(double **arr, int s1, int s2, double val) {
  int i, j;
  for (i = 0; i < s1; i++)
    for (j = 0; j < s2; j++)
      arr[i][j] = val;
}


x86 assembly (clang, -O0):
<aml_array_dbl_2d_fill>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1174 <aml_array_dbl_2d_fill+0x74>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1161 <aml_array_dbl_2d_fill+0x61>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <aml_array_dbl_2d_fill+0x2d>
jmp    1166 <aml_array_dbl_2d_fill+0x66>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111a <aml_array_dbl_2d_fill+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_2d_fill>:
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1243 <aml_array_dbl_2d_fill+0x143>
mov    %esi,%r14d
mov    %edx,%ecx
mov    %ecx,%r11d
and    $0xfffffffc,%r11d
lea    -0x4(%r11),%r8
mov    %r8,%r9
shr    $0x2,%r9
add    $0x1,%r9
movaps %xmm0,%xmm1
movlhps %xmm0,%xmm1
mov    %r9d,%r10d
and    $0x7,%r10d
and    $0xfffffffffffffff8,%r9
mov    %r10,%r15
shl    $0x5,%r15
xor    %r12d,%r12d
jmp    115d <aml_array_dbl_2d_fill+0x5d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r14,%r12
je     1243 <aml_array_dbl_2d_fill+0x143>
test   %edx,%edx
jle    1150 <aml_array_dbl_2d_fill+0x50>
mov    (%rdi,%r12,8),%rax
cmp    $0x4,%edx
jae    1180 <aml_array_dbl_2d_fill+0x80>
xor    %esi,%esi
jmp    1230 <aml_array_dbl_2d_fill+0x130>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x1c,%r8
jae    118a <aml_array_dbl_2d_fill+0x8a>
xor    %esi,%esi
jmp    1201 <aml_array_dbl_2d_fill+0x101>
mov    %r9,%rbx
xor    %esi,%esi
nop
movups %xmm1,(%rax,%rsi,8)
movups %xmm1,0x10(%rax,%rsi,8)
movups %xmm1,0x20(%rax,%rsi,8)
movups %xmm1,0x30(%rax,%rsi,8)
movups %xmm1,0x40(%rax,%rsi,8)
movups %xmm1,0x50(%rax,%rsi,8)
movups %xmm1,0x60(%rax,%rsi,8)
movups %xmm1,0x70(%rax,%rsi,8)
movups %xmm1,0x80(%rax,%rsi,8)
movups %xmm1,0x90(%rax,%rsi,8)
movups %xmm1,0xa0(%rax,%rsi,8)
movups %xmm1,0xb0(%rax,%rsi,8)
movups %xmm1,0xc0(%rax,%rsi,8)
movups %xmm1,0xd0(%rax,%rsi,8)
movups %xmm1,0xe0(%rax,%rsi,8)
movups %xmm1,0xf0(%rax,%rsi,8)
add    $0x20,%rsi
add    $0xfffffffffffffff8,%rbx
jne    1190 <aml_array_dbl_2d_fill+0x90>
test   %r10,%r10
je     1222 <aml_array_dbl_2d_fill+0x122>
lea    (%rax,%rsi,8),%rsi
add    $0x10,%rsi
xor    %ebx,%ebx
movups %xmm1,-0x10(%rsi,%rbx,1)
movups %xmm1,(%rsi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r15
jne    1210 <aml_array_dbl_2d_fill+0x110>
mov    %r11,%rsi
cmp    %rcx,%r11
je     1150 <aml_array_dbl_2d_fill+0x50>
xchg   %ax,%ax
movsd  %xmm0,(%rax,%rsi,8)
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1230 <aml_array_dbl_2d_fill+0x130>
jmp    1150 <aml_array_dbl_2d_fill+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @aml_array_dbl_2d_fill(double** nocapture %0, i32 %1, i32 %2, double %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %99
6: ; preds = %4
%7 = icmp sgt i32 %2, 0
%8 = zext i32 %1 to i64
%9 = zext i32 %2 to i64
%10 = and i64 %9, 4294967292
%11 = add nsw i64 %10, -4
%12 = lshr exact i64 %11, 2
%13 = add nuw nsw i64 %12, 1
%14 = icmp ult i32 %2, 4
%15 = and i64 %9, 4294967292
%16 = insertelement <2 x double> poison, double %3, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = insertelement <2 x double> poison, double %3, i64 0
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%20 = and i64 %13, 7
%21 = icmp ult i64 %11, 28
%22 = and i64 %13, 9223372036854775800
%23 = icmp eq i64 %20, 0
%24 = icmp eq i64 %15, %9
br label %25
25: ; preds = %6, %96
%26 = phi i64 [ 0, %6 ], [ %97, %96 ]
br i1 %7, label %27, label %96
27: ; preds = %25
%28 = getelementptr inbounds double*, double** %0, i64 %26
%29 = load double*, double** %28
br i1 %14, label %89, label %30
30: ; preds = %27
br i1 %21, label %76, label %31
31: ; preds = %30, %31
%32 = phi i64 [ %73, %31 ], [ 0, %30 ]
%33 = phi i64 [ %74, %31 ], [ 0, %30 ]
%34 = getelementptr inbounds double, double* %29, i64 %32
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> %17, <2 x double>* %35
%36 = getelementptr inbounds double, double* %34, i64 2
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> %19, <2 x double>* %37
%38 = or i64 %32, 4
%39 = getelementptr inbounds double, double* %29, i64 %38
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> %17, <2 x double>* %40
%41 = getelementptr inbounds double, double* %39, i64 2
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> %19, <2 x double>* %42
%43 = or i64 %32, 8
%44 = getelementptr inbounds double, double* %29, i64 %43
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> %17, <2 x double>* %45
%46 = getelementptr inbounds double, double* %44, i64 2
%47 = bitcast double* %46 to <2 x double>*
store <2 x double> %19, <2 x double>* %47
%48 = or i64 %32, 12
%49 = getelementptr inbounds double, double* %29, i64 %48
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %17, <2 x double>* %50
%51 = getelementptr inbounds double, double* %49, i64 2
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %19, <2 x double>* %52
%53 = or i64 %32, 16
%54 = getelementptr inbounds double, double* %29, i64 %53
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> %17, <2 x double>* %55
%56 = getelementptr inbounds double, double* %54, i64 2
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> %19, <2 x double>* %57
%58 = or i64 %32, 20
%59 = getelementptr inbounds double, double* %29, i64 %58
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %17, <2 x double>* %60
%61 = getelementptr inbounds double, double* %59, i64 2
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> %19, <2 x double>* %62
%63 = or i64 %32, 24
%64 = getelementptr inbounds double, double* %29, i64 %63
%65 = bitcast double* %64 to <2 x double>*
store <2 x double> %17, <2 x double>* %65
%66 = getelementptr inbounds double, double* %64, i64 2
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> %19, <2 x double>* %67
%68 = or i64 %32, 28
%69 = getelementptr inbounds double, double* %29, i64 %68
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %17, <2 x double>* %70
%71 = getelementptr inbounds double, double* %69, i64 2
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %19, <2 x double>* %72
%73 = add nuw i64 %32, 32
%74 = add i64 %33, 8
%75 = icmp eq i64 %74, %22
br i1 %75, label %76, label %31
76: ; preds = %31, %30
%77 = phi i64 [ 0, %30 ], [ %73, %31 ]
br i1 %23, label %88, label %78
78: ; preds = %76, %78
%79 = phi i64 [ %85, %78 ], [ %77, %76 ]
%80 = phi i64 [ %86, %78 ], [ 0, %76 ]
%81 = getelementptr inbounds double, double* %29, i64 %79
%82 = bitcast double* %81 to <2 x double>*
store <2 x double> %17, <2 x double>* %82
%83 = getelementptr inbounds double, double* %81, i64 2
%84 = bitcast double* %83 to <2 x double>*
store <2 x double> %19, <2 x double>* %84
%85 = add nuw i64 %79, 4
%86 = add i64 %80, 1
%87 = icmp eq i64 %86, %20
br i1 %87, label %88, label %78
88: ; preds = %78, %76
br i1 %24, label %96, label %89
89: ; preds = %27, %88
%90 = phi i64 [ 0, %27 ], [ %15, %88 ]
br label %91
91: ; preds = %89, %91
%92 = phi i64 [ %94, %91 ], [ %90, %89 ]
%93 = getelementptr inbounds double, double* %29, i64 %92
store double %3, double* %93
%94 = add nuw nsw i64 %92, 1
%95 = icmp eq i64 %94, %9
br i1 %95, label %96, label %91
96: ; preds = %91, %88, %25
%97 = add nuw nsw i64 %26, 1
%98 = icmp eq i64 %97, %8
br i1 %98, label %99, label %25
99: ; preds = %96, %4
ret void
}