void div_mat2D_double(double **mat2D_double, int x, int y, double a) {
  unsigned int i, j;
  for (i = 0; i < x; ++i) {
    for (j = 0; j < y; ++j) {
      mat2D_double[i][j] /= a;
    }
  }
}


x86 assembly (clang, -O0):
<div_mat2D_double>:
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
jae    117b <div_mat2D_double+0x7b>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1168 <div_mat2D_double+0x68>
movsd  -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <div_mat2D_double+0x2d>
jmp    116d <div_mat2D_double+0x6d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111a <div_mat2D_double+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<div_mat2D_double>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
je     11e6 <div_mat2D_double+0xe6>
mov    %esi,%r14d
mov    %edx,%ecx
mov    %ecx,%r11d
and    $0xfffffffe,%r11d
lea    -0x2(%r11),%r8
mov    %r8,%r9
shr    %r9
add    $0x1,%r9
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %r15d,%r15d
jmp    114d <div_mat2D_double+0x4d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r14,%r15
je     11e6 <div_mat2D_double+0xe6>
test   %edx,%edx
je     1140 <div_mat2D_double+0x40>
mov    (%rdi,%r15,8),%rbx
cmp    $0x1,%edx
jne    1160 <div_mat2D_double+0x60>
xor    %eax,%eax
jmp    11c0 <div_mat2D_double+0xc0>
xchg   %ax,%ax
test   %r8,%r8
je     11dc <div_mat2D_double+0xdc>
mov    %r10,%rsi
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movupd (%rbx,%rax,8),%xmm2
movupd 0x10(%rbx,%rax,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rax,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%rbx,%rax,8)
add    $0x4,%rax
add    $0xfffffffffffffffe,%rsi
jne    1170 <div_mat2D_double+0x70>
test   $0x1,%r9b
je     11ac <div_mat2D_double+0xac>
movupd (%rbx,%rax,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rax,8)
mov    %r11,%rax
cmp    %rcx,%r11
je     1140 <div_mat2D_double+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rax,8),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rbx,%rax,8)
add    $0x1,%rax
cmp    %rax,%rcx
jne    11c0 <div_mat2D_double+0xc0>
jmp    1140 <div_mat2D_double+0x40>
xor    %eax,%eax
test   $0x1,%r9b
jne    119e <div_mat2D_double+0x9e>
jmp    11ac <div_mat2D_double+0xac>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @div_mat2D_double(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 = %36, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %6
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
store i32 0, i32* %10
br label %16
16: ; preds = %32, %15
%17 = load i32, i32* %10
%18 = load i32, i32* %7
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load double, double* %8
%22 = load double**, double*** %5
%23 = load i32, i32* %9
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds double*, double** %22, i64 %24
%26 = load double*, double** %25
%27 = load i32, i32* %10
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = fdiv double %30, %21
store double %31, double* %29
br label %32
32: ; preds = %20
%33 = load i32, i32* %10
%34 = add i32 %33, 1
store i32 %34, i32* %10
br label %16
35: ; preds = %16
br label %36
36: ; preds = %35
%37 = load i32, i32* %9
%38 = add i32 %37, 1
store i32 %38, i32* %9
br label %11
39: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @div_mat2D_double(double** nocapture %0, i32 %1, i32 %2, double %3) {
%5 = icmp eq i32 %1, 0
br i1 %5, label %67, label %6
6: ; preds = %4
%7 = icmp eq i32 %2, 0
%8 = zext i32 %1 to i64
%9 = zext i32 %2 to i64
%10 = and i64 %9, 4294967294
%11 = add nsw i64 %10, -2
%12 = lshr exact i64 %11, 1
%13 = add nuw i64 %12, 1
%14 = icmp eq i32 %2, 1
%15 = and i64 %9, 4294967294
%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 = and i64 %13, 1
%19 = icmp eq i64 %11, 0
%20 = and i64 %13, -2
%21 = icmp eq i64 %18, 0
%22 = icmp eq i64 %15, %9
br label %23
23: ; preds = %6, %64
%24 = phi i64 [ 0, %6 ], [ %65, %64 ]
br i1 %7, label %64, label %25
25: ; preds = %23
%26 = getelementptr inbounds double*, double** %0, i64 %24
%27 = load double*, double** %26
br i1 %14, label %55, label %28
28: ; preds = %25
br i1 %19, label %46, label %29
29: ; preds = %28, %29
%30 = phi i64 [ %43, %29 ], [ 0, %28 ]
%31 = phi i64 [ %44, %29 ], [ 0, %28 ]
%32 = getelementptr inbounds double, double* %27, i64 %30
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = fdiv <2 x double> %34, %17
%36 = bitcast double* %32 to <2 x double>*
store <2 x double> %35, <2 x double>* %36
%37 = or i64 %30, 2
%38 = getelementptr inbounds double, double* %27, i64 %37
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = fdiv <2 x double> %40, %17
%42 = bitcast double* %38 to <2 x double>*
store <2 x double> %41, <2 x double>* %42
%43 = add nuw i64 %30, 4
%44 = add nuw i64 %31, 2
%45 = icmp eq i64 %44, %20
br i1 %45, label %46, label %29
46: ; preds = %29, %28
%47 = phi i64 [ 0, %28 ], [ %43, %29 ]
br i1 %21, label %54, label %48
48: ; preds = %46
%49 = getelementptr inbounds double, double* %27, i64 %47
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = fdiv <2 x double> %51, %17
%53 = bitcast double* %49 to <2 x double>*
store <2 x double> %52, <2 x double>* %53
br label %54
54: ; preds = %46, %48
br i1 %22, label %64, label %55
55: ; preds = %25, %54
%56 = phi i64 [ 0, %25 ], [ %15, %54 ]
br label %57
57: ; preds = %55, %57
%58 = phi i64 [ %62, %57 ], [ %56, %55 ]
%59 = getelementptr inbounds double, double* %27, i64 %58
%60 = load double, double* %59
%61 = fdiv double %60, %3
store double %61, double* %59
%62 = add nuw nsw i64 %58, 1
%63 = icmp eq i64 %62, %9
br i1 %63, label %64, label %57
64: ; preds = %57, %54, %23
%65 = add nuw nsw i64 %24, 1
%66 = icmp eq i64 %65, %8
br i1 %66, label %67, label %23
67: ; preds = %64, %4
ret void
}