void f5(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 = 2; i < 1000; i += 4) {
    double a = q[i - 2] + p[i - 2];
    double b = q[i - 1] + p[i - 1];
    q[i - 2] = a;
    q[i - 1] = b;
  }
}


x86 assembly (clang, -O0):
<f5>:
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   $0x2,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jae    11b8 <f5+0xb8>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
mov    %ecx,%ecx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $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
sub    $0x2,%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <f5+0x23>
pop    %rbp
ret

x86 assembly (clang, -O2):
<f5>:
mov    $0xfffffffffffffffa,%rax
nopw   0x0(%rax,%rax,1)
movapd 0x30(%rsi,%rax,8),%xmm0
addpd  0x30(%rdi,%rax,8),%xmm0
movapd 0x50(%rsi,%rax,8),%xmm1
movapd %xmm0,0x30(%rsi,%rax,8)
addpd  0x50(%rdi,%rax,8),%xmm1
movapd %xmm1,0x50(%rsi,%rax,8)
add    $0x8,%rax
cmp    $0x3e0,%rax
jb     1110 <f5+0x10>
ret

LLVM IR (-O0):
define void @f5(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 2, i32* %5
br label %14
14: ; preds = %56, %2
%15 = load i32, i32* %5
%16 = icmp ult i32 %15, 1000
br i1 %16, label %17, label %59
17: ; preds = %14
%18 = load double*, double** %4
%19 = load i32, i32* %5
%20 = sub i32 %19, 2
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds double, double* %18, i64 %21
%23 = load double, double* %22
%24 = load double*, double** %3
%25 = load i32, i32* %5
%26 = sub i32 %25, 2
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = load double, double* %28
%30 = fadd double %23, %29
store double %30, double* %6
%31 = load double*, double** %4
%32 = load i32, i32* %5
%33 = sub i32 %32, 1
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds double, double* %31, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %3
%38 = load i32, i32* %5
%39 = sub i32 %38, 1
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds double, double* %37, i64 %40
%42 = load double, double* %41
%43 = fadd double %36, %42
store double %43, double* %7
%44 = load double, double* %6
%45 = load double*, double** %4
%46 = load i32, i32* %5
%47 = sub i32 %46, 2
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds double, double* %45, i64 %48
store double %44, double* %49
%50 = load double, double* %7
%51 = load double*, double** %4
%52 = load i32, i32* %5
%53 = sub i32 %52, 1
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds double, double* %51, i64 %54
store double %50, double* %55
br label %56
56: ; preds = %17
%57 = load i32, i32* %5
%58 = add i32 %57, 4
store i32 %58, i32* %5
br label %14
59: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @f5(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 [ 2, %2 ], [ %26, %6 ]
%8 = add nsw i64 %7, -2
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = getelementptr inbounds double, double* %0, i64 %8
%11 = bitcast double* %9 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = bitcast double* %10 to <2 x double>*
%14 = load <2 x double>, <2 x double>* %13
%15 = fadd <2 x double> %12, %14
%16 = bitcast double* %9 to <2 x double>*
store <2 x double> %15, <2 x double>* %16
%17 = add nuw nsw i64 %7, 2
%18 = getelementptr inbounds double, double* %1, i64 %17
%19 = getelementptr inbounds double, double* %0, i64 %17
%20 = bitcast double* %18 to <2 x double>*
%21 = load <2 x double>, <2 x double>* %20
%22 = bitcast double* %19 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = fadd <2 x double> %21, %23
%25 = bitcast double* %18 to <2 x double>*
store <2 x double> %24, <2 x double>* %25
%26 = add nuw nsw i64 %7, 8
%27 = icmp ult i64 %7, 992
br i1 %27, label %6, label %5
}