void _subtract_row_double(double *X, double *row, int M, int N) {
  int i, j, ro;
  for (i = 0; i != M; ++i) {
    ro = i * N;
    for (j = 0; j != N; ++j) {
      X[ro + j] -= row[j];
    }
  }
}


x86 assembly (clang, -O0):
<_subtract_row_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     118b <_subtract_row_double+0x8b>
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1178 <_subtract_row_double+0x78>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1136 <_subtract_row_double+0x36>
jmp    117d <_subtract_row_double+0x7d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1119 <_subtract_row_double+0x19>
pop    %rbp
ret

x86 assembly (clang, -O2):
<_subtract_row_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
je     1313 <_subtract_row_double+0x213>
mov    %ecx,%r12d
movslq %ecx,%r9
mov    %edx,%r13d
lea    (%rsi,%r12,8),%r15
mov    %r12d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x10(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x18(%rsp)
mov    %rax,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %rdx,%rax
mov    %rdx,-0x20(%rsp)
and    $0xfffffffffffffffe,%rdx
mov    %rdx,-0x30(%rsp)
mov    %r12,%r8
neg    %r8
lea    0x30(%rdi),%rbx
lea    0x0(,%r9,8),%r10
lea    0x8(%rdi),%rbp
xor    %r14d,%r14d
mov    %r15,-0x8(%rsp)
mov    %r8,-0x28(%rsp)
jmp    1193 <_subtract_row_double+0x93>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
add    %r10,%rbx
add    %r10,%rbp
cmp    %r13,%r14
je     1313 <_subtract_row_double+0x213>
test   %ecx,%ecx
je     1180 <_subtract_row_double+0x80>
mov    %r14,%r11
imul   %r9,%r11
cmp    $0x4,%ecx
jb     11b9 <_subtract_row_double+0xb9>
lea    (%rdi,%r11,8),%rax
cmp    %r15,%rax
jae    1221 <_subtract_row_double+0x121>
lea    (%r11,%r12,1),%rax
lea    (%rdi,%rax,8),%rax
cmp    %rsi,%rax
jbe    1221 <_subtract_row_double+0x121>
xor    %eax,%eax
mov    %rax,%rdx
test   $0x1,%r12b
je     11df <_subtract_row_double+0xdf>
add    %rax,%r11
movsd  (%rdi,%r11,8),%xmm0
subsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,(%rdi,%r11,8)
mov    %rax,%rdx
or     $0x1,%rdx
not    %rax
cmp    %r8,%rax
je     1180 <_subtract_row_double+0x80>
nopw   0x0(%rax,%rax,1)
movsd  -0x8(%rbp,%rdx,8),%xmm0
subsd  (%rsi,%rdx,8),%xmm0
movsd  0x0(%rbp,%rdx,8),%xmm1
movsd  %xmm0,-0x8(%rbp,%rdx,8)
subsd  0x8(%rsi,%rdx,8),%xmm1
movsd  %xmm1,0x0(%rbp,%rdx,8)
add    $0x2,%rdx
cmp    %rdx,%r12
jne    11f0 <_subtract_row_double+0xf0>
jmp    1180 <_subtract_row_double+0x80>
mov    %r9,%r8
cmpq   $0x0,-0x18(%rsp)
je     1307 <_subtract_row_double+0x207>
mov    -0x30(%rsp),%r15
xor    %r9d,%r9d
nopl   0x0(%rax,%rax,1)
movupd (%rsi,%r9,8),%xmm0
movupd 0x10(%rsi,%r9,8),%xmm1
movupd -0x30(%rbx,%r9,8),%xmm2
subpd  %xmm0,%xmm2
movupd -0x20(%rbx,%r9,8),%xmm0
subpd  %xmm1,%xmm0
movupd -0x10(%rbx,%r9,8),%xmm1
movupd (%rbx,%r9,8),%xmm3
movupd %xmm2,-0x30(%rbx,%r9,8)
movupd %xmm0,-0x20(%rbx,%r9,8)
movupd 0x20(%rsi,%r9,8),%xmm0
subpd  %xmm0,%xmm1
movupd 0x30(%rsi,%r9,8),%xmm0
subpd  %xmm0,%xmm3
movupd %xmm1,-0x10(%rbx,%r9,8)
movupd %xmm3,(%rbx,%r9,8)
add    $0x8,%r9
add    $0xfffffffffffffffe,%r15
jne    1240 <_subtract_row_double+0x140>
testb  $0x1,-0x20(%rsp)
je     12e4 <_subtract_row_double+0x1e4>
movupd (%rsi,%r9,8),%xmm0
movupd 0x10(%rsi,%r9,8),%xmm1
add    %r11,%r9
movupd (%rdi,%r9,8),%xmm2
subpd  %xmm0,%xmm2
movupd 0x10(%rdi,%r9,8),%xmm0
subpd  %xmm1,%xmm0
movupd %xmm2,(%rdi,%r9,8)
movupd %xmm0,0x10(%rdi,%r9,8)
mov    -0x10(%rsp),%rdx
mov    %rdx,%rax
cmp    %r12,%rdx
mov    %r8,%r9
mov    -0x8(%rsp),%r15
mov    -0x28(%rsp),%r8
je     1180 <_subtract_row_double+0x80>
jmp    11bb <_subtract_row_double+0xbb>
xor    %r9d,%r9d
testb  $0x1,-0x20(%rsp)
jne    12b2 <_subtract_row_double+0x1b2>
jmp    12e4 <_subtract_row_double+0x1e4>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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