void helper_double_3(double *buf) {
  for (int j = 0; j < 8; j += 8) {
    for (int k = 0; k < 4; k += 4) {
      __asm__ volatile("vmovupd (%0), %%ymm0\n"
                       "vmovupd (%1), %%ymm1\n"
                       "vpermilpd $0, %%ymm0, %%ymm8\n"
                       "vpermilpd $15, %%ymm0, %%ymm9\n"
                       "vxorpd %%ymm10, %%ymm10, %%ymm10\n"
                       "vsubpd %%ymm9, %%ymm10, %%ymm11\n"
                       "vaddsubpd %%ymm11, %%ymm8, %%ymm0\n"
                       "vpermilpd $0, %%ymm1, %%ymm8\n"
                       "vpermilpd $15, %%ymm1, %%ymm9\n"
                       "vxorpd %%ymm10, %%ymm10, %%ymm10\n"
                       "vsubpd %%ymm9, %%ymm10, %%ymm11\n"
                       "vaddsubpd %%ymm11, %%ymm8, %%ymm1\n"
                       "vperm2f128 $0, %%ymm0, %%ymm0, %%ymm8\n"
                       "vxorpd %%ymm9, %%ymm9, %%ymm9\n"
                       "vsubpd %%ymm0, %%ymm9, %%ymm10\n"
                       "vperm2f128 $49, %%ymm10, %%ymm0, %%ymm11\n"
                       "vaddpd %%ymm11, %%ymm8, %%ymm0\n"
                       "vperm2f128 $0, %%ymm1, %%ymm1, %%ymm8\n"
                       "vxorpd %%ymm9, %%ymm9, %%ymm9\n"
                       "vsubpd %%ymm1, %%ymm9, %%ymm10\n"
                       "vperm2f128 $49, %%ymm10, %%ymm1, %%ymm11\n"
                       "vaddpd %%ymm11, %%ymm8, %%ymm1\n"
                       "vaddpd %%ymm1, %%ymm0, %%ymm8\n"
                       "vsubpd %%ymm1, %%ymm0, %%ymm9\n"
                       "vmovupd %%ymm8, (%0)\n"
                       "vmovupd %%ymm9, (%1)\n" ::"r"(buf + j + k + 0),
                       "r"(buf + j + k + 4)
                       : "%ymm0", "%ymm1", "%ymm2", "%ymm3", "%ymm4", "%ymm5",
                         "%ymm6", "%ymm7", "%ymm8", "%ymm9", "%ymm10", "%ymm11",
                         "%ymm12", "%ymm13", "%ymm14", "%ymm15", "memory");
    }
  }
}


x86 assembly (clang, -O0):
<helper_double_3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1205 <helper_double_3+0x105>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11f2 <helper_double_3+0xf2>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
shl    $0x3,%rdx
add    %rdx,%rcx
movslq -0x10(%rbp),%rdx
shl    $0x3,%rdx
add    %rdx,%rcx
add    $0x20,%rcx
vmovupd (%rax),%ymm0
vmovupd (%rcx),%ymm1
vpermilpd $0x0,%ymm0,%ymm8
vpermilpd $0xf,%ymm0,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm0
vpermilpd $0x0,%ymm1,%ymm8
vpermilpd $0xf,%ymm1,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm1
vperm2f128 $0x0,%ymm0,%ymm0,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm0,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm0,%ymm11
vaddpd %ymm11,%ymm8,%ymm0
vperm2f128 $0x0,%ymm1,%ymm1,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm1,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm1,%ymm11
vaddpd %ymm11,%ymm8,%ymm1
vaddpd %ymm1,%ymm0,%ymm8
vsubpd %ymm1,%ymm0,%ymm9
vmovupd %ymm8,(%rax)
vmovupd %ymm9,(%rcx)
mov    -0x10(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x10(%rbp)
jmp    1120 <helper_double_3+0x20>
jmp    11f7 <helper_double_3+0xf7>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <helper_double_3+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<helper_double_3>:
lea    0x20(%rdi),%rax
vmovupd (%rdi),%ymm0
vmovupd (%rax),%ymm1
vpermilpd $0x0,%ymm0,%ymm8
vpermilpd $0xf,%ymm0,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm0
vpermilpd $0x0,%ymm1,%ymm8
vpermilpd $0xf,%ymm1,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm1
vperm2f128 $0x0,%ymm0,%ymm0,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm0,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm0,%ymm11
vaddpd %ymm11,%ymm8,%ymm0
vperm2f128 $0x0,%ymm1,%ymm1,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm1,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm1,%ymm11
vaddpd %ymm11,%ymm8,%ymm1
vaddpd %ymm1,%ymm0,%ymm8
vsubpd %ymm1,%ymm0,%ymm9
vmovupd %ymm8,(%rdi)
vmovupd %ymm9,(%rax)
ret

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

LLVM IR (-O2):
define void @helper_double_3(double* %0) {
%2 = getelementptr inbounds double, double* %0, i64 4
tail call void asm sideeffect "vmovupd ($0), %ymm0\0Avmovupd ($1), %ymm1\0Avpermilpd $$0, %ymm0, %ymm8\0Avpermilpd $$15, %ymm0, %ymm9\0Avxorpd %ymm10, %ymm10, %ymm10\0Avsubpd %ymm9, %ymm10, %ymm11\0Avaddsubpd %ymm11, %ymm8, %ymm0\0Avpermilpd $$0, %ymm1, %ymm8\0Avpermilpd $$15, %ymm1, %ymm9\0Avxorpd %ymm10, %ymm10, %ymm10\0Avsubpd %ymm9, %ymm10, %ymm11\0Avaddsubpd %ymm11, %ymm8, %ymm1\0Avperm2f128 $$0, %ymm0, %ymm0, %ymm8\0Avxorpd %ymm9, %ymm9, %ymm9\0Avsubpd %ymm0, %ymm9, %ymm10\0Avperm2f128 $$49, %ymm10, %ymm0, %ymm11\0Avaddpd %ymm11, %ymm8, %ymm0\0Avperm2f128 $$0, %ymm1, %ymm1, %ymm8\0Avxorpd %ymm9, %ymm9, %ymm9\0Avsubpd %ymm1, %ymm9, %ymm10\0Avperm2f128 $$49, %ymm10, %ymm1, %ymm11\0Avaddpd %ymm11, %ymm8, %ymm1\0Avaddpd %ymm1, %ymm0, %ymm8\0Avsubpd %ymm1, %ymm0, %ymm9\0Avmovupd %ymm8, ($0)\0Avmovupd %ymm9, ($1)\0A", "r,r,~{ymm0},~{ymm1},~{ymm2},~{ymm3},~{ymm4},~{ymm5},~{ymm6},~{ymm7},~{ymm8},~{ymm9},~{ymm10},~{ymm11},~{ymm12},~{ymm13},~{ymm14},~{ymm15},~{memory},~{dirflag},~{fpsr},~{flags}"(double* %0, double* %2)
ret void
}