double *vector_subtract_to(int n, double *x, double *y) {
  int i;
  for (i = 0; i < n; i++)
    y[i] = x[i] - y[i];
  return y;
}


x86 assembly (clang, -O0):
<vector_subtract_to>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1157 <vector_subtract_to+0x57>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <vector_subtract_to+0x16>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_subtract_to>:
mov    %rdx,%rax
test   %edi,%edi
jle    1297 <vector_subtract_to+0x197>
mov    %edi,%r9d
cmp    $0x4,%edi
jb     112d <vector_subtract_to+0x2d>
lea    (%rsi,%r9,8),%rcx
cmp    %rax,%rcx
jbe    11d3 <vector_subtract_to+0xd3>
lea    (%rax,%r9,8),%rcx
cmp    %rsi,%rcx
jbe    11d3 <vector_subtract_to+0xd3>
xor    %edx,%edx
mov    %rdx,%rcx
not    %rcx
add    %r9,%rcx
mov    %r9,%rdi
and    $0x3,%rdi
je     1169 <vector_subtract_to+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsi,%rdx,8),%xmm0
subsd  (%rax,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rdi
jne    1150 <vector_subtract_to+0x50>
cmp    $0x3,%rcx
jb     1297 <vector_subtract_to+0x197>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rsi,%rdx,8),%xmm0
subsd  (%rax,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
movsd  0x8(%rsi,%rdx,8),%xmm0
subsd  0x8(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rdx,8)
movsd  0x10(%rsi,%rdx,8),%xmm0
subsd  0x10(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rax,%rdx,8)
movsd  0x18(%rsi,%rdx,8),%xmm0
subsd  0x18(%rax,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rax,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%r9
jne    1180 <vector_subtract_to+0x80>
jmp    1297 <vector_subtract_to+0x197>
mov    %r9d,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rcx
mov    %rcx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rcx,%rcx
je     1298 <vector_subtract_to+0x198>
mov    %r8,%rcx
and    $0xfffffffffffffffe,%rcx
xor    %edi,%edi
nopw   0x0(%rax,%rax,1)
movupd (%rsi,%rdi,8),%xmm0
movupd 0x10(%rsi,%rdi,8),%xmm1
movupd (%rax,%rdi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rax,%rdi,8),%xmm2
subpd  %xmm2,%xmm1
movupd 0x20(%rax,%rdi,8),%xmm2
movupd 0x30(%rax,%rdi,8),%xmm3
movupd %xmm0,(%rax,%rdi,8)
movupd %xmm1,0x10(%rax,%rdi,8)
movupd 0x20(%rsi,%rdi,8),%xmm0
subpd  %xmm2,%xmm0
movupd 0x30(%rsi,%rdi,8),%xmm1
subpd  %xmm3,%xmm1
movupd %xmm0,0x20(%rax,%rdi,8)
movupd %xmm1,0x30(%rax,%rdi,8)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rcx
jne    1200 <vector_subtract_to+0x100>
test   $0x1,%r8b
je     128e <vector_subtract_to+0x18e>
movupd (%rsi,%rdi,8),%xmm0
movupd 0x10(%rsi,%rdi,8),%xmm1
movupd (%rax,%rdi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rax,%rdi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rax,%rdi,8)
movupd %xmm1,0x10(%rax,%rdi,8)
cmp    %r9,%rdx
jne    112f <vector_subtract_to+0x2f>
ret
xor    %edi,%edi
test   $0x1,%r8b
jne    1265 <vector_subtract_to+0x165>
jmp    128e <vector_subtract_to+0x18e>

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

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