void f4(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 < 500; i += 6)
    for (unsigned int j = 0; j < 500; j += 4) {
      double a = q[j] + p[i];
      double b = q[j + 1] + p[i + 1];
      q[i] = a;
      q[i + 1] = b;
    }
}


x86 assembly (clang, -O0):
<f4>:
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   $0x1f4,-0x14(%rbp)
jae    11d0 <f4+0xd0>
movl   $0x0,-0x18(%rbp)
cmpl   $0x1f4,-0x18(%rbp)
jae    11bd <f4+0xbd>
mov    -0x10(%rbp),%rax
mov    -0x18(%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    -0x18(%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    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <f4+0x37>
jmp    11c2 <f4+0xc2>
mov    -0x14(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <f4+0x23>
pop    %rbp
ret

x86 assembly (clang, -O2):
<f4>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xffffffffffffffec,%rcx
nopw   0x0(%rax,%rax,1)
movapd 0xa0(%rsi,%rcx,8),%xmm0
addpd  (%rdi,%rax,8),%xmm0
movapd %xmm0,(%rsi,%rax,8)
movapd 0xc0(%rsi,%rcx,8),%xmm0
addpd  (%rdi,%rax,8),%xmm0
movapd %xmm0,(%rsi,%rax,8)
movapd 0xe0(%rsi,%rcx,8),%xmm0
addpd  (%rdi,%rax,8),%xmm0
movapd %xmm0,(%rsi,%rax,8)
movapd 0x100(%rsi,%rcx,8),%xmm0
addpd  (%rdi,%rax,8),%xmm0
movapd %xmm0,(%rsi,%rax,8)
movapd 0x120(%rsi,%rcx,8),%xmm0
addpd  (%rdi,%rax,8),%xmm0
movapd %xmm0,(%rsi,%rax,8)
add    $0x14,%rcx
cmp    $0x1e0,%rcx
jb     1120 <f4+0x20>
lea    0x6(%rax),%rcx
cmp    $0x1ee,%rax
mov    %rcx,%rax
jb     1110 <f4+0x10>
ret

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

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