void f1(double *p, double *q) {
  p = (double *)__builtin_assume_aligned(p, sizeof(double) * 2);
  q = (double *)__builtin_assume_aligned(q, sizeof(double) * 2);
  for (unsigned int i = 0; i < 1000; i += 4) {
    double a = q[i] + p[i];
    double b = q[i + 1] + p[i + 1];
    q[i] = a;
    q[i + 1] = b;
  }
}


x86 assembly (clang, -O0):
<f1>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jae    11a9 <f1+0xa9>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <f1+0x23>
pop    %rbp
ret

x86 assembly (clang, -O2):
<f1>:
mov    $0xffffffffffffffec,%rax
nopw   0x0(%rax,%rax,1)
movapd 0xa0(%rsi,%rax,8),%xmm0
movapd 0xc0(%rsi,%rax,8),%xmm1
movapd 0xe0(%rsi,%rax,8),%xmm2
addpd  0xa0(%rdi,%rax,8),%xmm0
movapd 0x100(%rsi,%rax,8),%xmm3
movapd %xmm0,0xa0(%rsi,%rax,8)
addpd  0xc0(%rdi,%rax,8),%xmm1
movapd %xmm1,0xc0(%rsi,%rax,8)
addpd  0xe0(%rdi,%rax,8),%xmm2
movapd %xmm2,0xe0(%rsi,%rax,8)
addpd  0x100(%rdi,%rax,8),%xmm3
movapd %xmm3,0x100(%rsi,%rax,8)
movapd 0x120(%rsi,%rax,8),%xmm0
addpd  0x120(%rdi,%rax,8),%xmm0
movapd %xmm0,0x120(%rsi,%rax,8)
add    $0x14,%rax
cmp    $0x3d4,%rax
jb     1110 <f1+0x10>
ret

LLVM IR (-O0):
define void @f1(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%8 = load double*, double** %3
%9 = bitcast double* %8 to i8*
%10 = bitcast i8* %9 to double*
store double* %10, double** %3
%11 = load double*, double** %4
%12 = bitcast double* %11 to i8*
%13 = bitcast i8* %12 to double*
store double* %13, double** %4
store i32 0, i32* %5
br label %14
14: ; preds = %53, %2
%15 = load i32, i32* %5
%16 = icmp ult i32 %15, 1000
br i1 %16, label %17, label %56
17: ; preds = %14
%18 = load double*, double** %4
%19 = load i32, i32* %5
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %3
%24 = load i32, i32* %5
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fadd double %22, %27
store double %28, double* %6
%29 = load double*, double** %4
%30 = load i32, i32* %5
%31 = add i32 %30, 1
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds double, double* %29, i64 %32
%34 = load double, double* %33
%35 = load double*, double** %3
%36 = load i32, i32* %5
%37 = add i32 %36, 1
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds double, double* %35, i64 %38
%40 = load double, double* %39
%41 = fadd double %34, %40
store double %41, double* %7
%42 = load double, double* %6
%43 = load double*, double** %4
%44 = load i32, i32* %5
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double %42, double* %46
%47 = load double, double* %7
%48 = load double*, double** %4
%49 = load i32, i32* %5
%50 = add i32 %49, 1
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds double, double* %48, i64 %51
store double %47, double* %52
br label %53
53: ; preds = %17
%54 = load i32, i32* %5
%55 = add i32 %54, 4
store i32 %55, i32* %5
br label %14
56: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @f1(double* %0, double* %1) {
%3 = bitcast double* %0 to i8*
%4 = bitcast double* %1 to i8*
br label %6
5: ; preds = %6
ret void
6: ; preds = %6, %2
%7 = phi i64 [ 0, %2 ], [ %52, %6 ]
%8 = getelementptr inbounds double, double* %1, i64 %7
%9 = getelementptr inbounds double, double* %0, i64 %7
%10 = bitcast double* %8 to <2 x double>*
%11 = load <2 x double>, <2 x double>* %10
%12 = bitcast double* %9 to <2 x double>*
%13 = load <2 x double>, <2 x double>* %12
%14 = fadd <2 x double> %11, %13
%15 = bitcast double* %8 to <2 x double>*
store <2 x double> %14, <2 x double>* %15
%16 = add nuw nsw i64 %7, 4
%17 = getelementptr inbounds double, double* %1, i64 %16
%18 = getelementptr inbounds double, double* %0, i64 %16
%19 = bitcast double* %17 to <2 x double>*
%20 = load <2 x double>, <2 x double>* %19
%21 = bitcast double* %18 to <2 x double>*
%22 = load <2 x double>, <2 x double>* %21
%23 = fadd <2 x double> %20, %22
%24 = bitcast double* %17 to <2 x double>*
store <2 x double> %23, <2 x double>* %24
%25 = add nuw nsw i64 %7, 8
%26 = getelementptr inbounds double, double* %1, i64 %25
%27 = getelementptr inbounds double, double* %0, i64 %25
%28 = bitcast double* %26 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = bitcast double* %27 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = fadd <2 x double> %29, %31
%33 = bitcast double* %26 to <2 x double>*
store <2 x double> %32, <2 x double>* %33
%34 = add nuw nsw i64 %7, 12
%35 = getelementptr inbounds double, double* %1, i64 %34
%36 = getelementptr inbounds double, double* %0, i64 %34
%37 = bitcast double* %35 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = bitcast double* %36 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = fadd <2 x double> %38, %40
%42 = bitcast double* %35 to <2 x double>*
store <2 x double> %41, <2 x double>* %42
%43 = add nuw nsw i64 %7, 16
%44 = getelementptr inbounds double, double* %1, i64 %43
%45 = getelementptr inbounds double, double* %0, i64 %43
%46 = bitcast double* %44 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = bitcast double* %45 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = fadd <2 x double> %47, %49
%51 = bitcast double* %44 to <2 x double>*
store <2 x double> %50, <2 x double>* %51
%52 = add nuw nsw i64 %7, 20
%53 = icmp ult i64 %7, 980
br i1 %53, label %6, label %5
}