void f3(double *p, double *q, unsigned int n) {
  p = (double *)__builtin_assume_aligned(p, sizeof(double) * 2);
  q = (double *)__builtin_assume_aligned(q, sizeof(double) * 2);
  for (unsigned int i = 0; i < n; i += 6) {
    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):
<f3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11ab <f3+0xab>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%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    -0x18(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <f3+0x26>
pop    %rbp
ret

x86 assembly (clang, -O2):
<f3>:
test   %edx,%edx
je     1128 <f3+0x28>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ecx
movapd (%rsi,%rcx,8),%xmm0
addpd  (%rdi,%rcx,8),%xmm0
movapd %xmm0,(%rsi,%rcx,8)
add    $0x6,%eax
cmp    %edx,%eax
jb     1110 <f3+0x10>
ret

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

LLVM IR (-O2):
define void @f3(double* %0, double* %1, i32 %2) {
%4 = bitcast double* %0 to i8*
%5 = bitcast double* %1 to i8*
%6 = icmp eq i32 %2, 0
br i1 %6, label %7, label %8
7: ; preds = %8, %3
ret void
8: ; preds = %3, %8
%9 = phi i32 [ %19, %8 ], [ 0, %3 ]
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = getelementptr inbounds double, double* %0, i64 %10
%13 = bitcast double* %11 to <2 x double>*
%14 = load <2 x double>, <2 x double>* %13
%15 = bitcast double* %12 to <2 x double>*
%16 = load <2 x double>, <2 x double>* %15
%17 = fadd <2 x double> %14, %16
%18 = bitcast double* %11 to <2 x double>*
store <2 x double> %17, <2 x double>* %18
%19 = add i32 %9, 6
%20 = icmp ult i32 %19, %2
br i1 %20, label %8, label %7
}