void Subtract_Vectors(double w[], double u[], double v[], int n) {
  register int i;
  for (i = 0; i < n; i++)
    w[i] = u[i] - v[i];
}


x86 assembly (clang, -O0):
<Subtract_Vectors>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    115b <Subtract_Vectors+0x5b>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <Subtract_Vectors+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<Subtract_Vectors>:
test   %ecx,%ecx
jle    12b7 <Subtract_Vectors+0x1b7>
mov    %ecx,%r8d
cmp    $0x4,%ecx
jae    11b3 <Subtract_Vectors+0xb3>
xor    %ecx,%ecx
mov    %rcx,%r9
not    %r9
add    %r8,%r9
mov    %r8,%rax
and    $0x3,%rax
je     1149 <Subtract_Vectors+0x49>
nopl   0x0(%rax,%rax,1)
movsd  (%rsi,%rcx,8),%xmm0
subsd  (%rdx,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rax
jne    1130 <Subtract_Vectors+0x30>
cmp    $0x3,%r9
jb     12b7 <Subtract_Vectors+0x1b7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rsi,%rcx,8),%xmm0
subsd  (%rdx,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm0
subsd  0x8(%rdx,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rdi,%rcx,8)
movsd  0x10(%rsi,%rcx,8),%xmm0
subsd  0x10(%rdx,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rdi,%rcx,8)
movsd  0x18(%rsi,%rcx,8),%xmm0
subsd  0x18(%rdx,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rdi,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r8
jne    1160 <Subtract_Vectors+0x60>
jmp    12b7 <Subtract_Vectors+0x1b7>
lea    (%rdi,%r8,8),%rcx
lea    (%rsi,%r8,8),%rax
cmp    %rdi,%rax
seta   %r10b
lea    (%rdx,%r8,8),%rax
cmp    %rsi,%rcx
seta   %r11b
cmp    %rdi,%rax
seta   %al
cmp    %rdx,%rcx
seta   %r9b
xor    %ecx,%ecx
test   %r11b,%r10b
jne    1116 <Subtract_Vectors+0x16>
and    %r9b,%al
jne    1116 <Subtract_Vectors+0x16>
mov    %r8d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12b8 <Subtract_Vectors+0x1b8>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movupd (%rsi,%rax,8),%xmm0
movupd 0x10(%rsi,%rax,8),%xmm1
movupd (%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rdi,%rax,8)
movupd %xmm1,0x10(%rdi,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm0
movupd 0x30(%rsi,%rax,8),%xmm1
movupd 0x20(%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x30(%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,0x20(%rdi,%rax,8)
movupd %xmm1,0x30(%rdi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    1220 <Subtract_Vectors+0x120>
test   $0x1,%r9b
je     12ae <Subtract_Vectors+0x1ae>
movupd (%rsi,%rax,8),%xmm0
movupd 0x10(%rsi,%rax,8),%xmm1
movupd (%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rdi,%rax,8)
movupd %xmm1,0x10(%rdi,%rax,8)
cmp    %r8,%rcx
jne    1116 <Subtract_Vectors+0x16>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1285 <Subtract_Vectors+0x185>
jmp    12ae <Subtract_Vectors+0x1ae>

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

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