void helper_double_4_recursive(double *buf, int depth) {
  if (depth == 4) {
    for (int j = 0; j < 16; j += 16) {
      for (int k = 0; k < 4; k += 4) {
        __asm__ volatile(
            "vmovupd (%0), %%ymm0\n"
            "vmovupd (%1), %%ymm1\n"
            "vmovupd (%2), %%ymm2\n"
            "vmovupd (%3), %%ymm3\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"
            "vpermilpd $0, %%ymm2, %%ymm8\n"
            "vpermilpd $15, %%ymm2, %%ymm9\n"
            "vxorpd %%ymm10, %%ymm10, %%ymm10\n"
            "vsubpd %%ymm9, %%ymm10, %%ymm11\n"
            "vaddsubpd %%ymm11, %%ymm8, %%ymm2\n"
            "vpermilpd $0, %%ymm3, %%ymm8\n"
            "vpermilpd $15, %%ymm3, %%ymm9\n"
            "vxorpd %%ymm10, %%ymm10, %%ymm10\n"
            "vsubpd %%ymm9, %%ymm10, %%ymm11\n"
            "vaddsubpd %%ymm11, %%ymm8, %%ymm3\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"
            "vperm2f128 $0, %%ymm2, %%ymm2, %%ymm8\n"
            "vxorpd %%ymm9, %%ymm9, %%ymm9\n"
            "vsubpd %%ymm2, %%ymm9, %%ymm10\n"
            "vperm2f128 $49, %%ymm10, %%ymm2, %%ymm11\n"
            "vaddpd %%ymm11, %%ymm8, %%ymm2\n"
            "vperm2f128 $0, %%ymm3, %%ymm3, %%ymm8\n"
            "vxorpd %%ymm9, %%ymm9, %%ymm9\n"
            "vsubpd %%ymm3, %%ymm9, %%ymm10\n"
            "vperm2f128 $49, %%ymm10, %%ymm3, %%ymm11\n"
            "vaddpd %%ymm11, %%ymm8, %%ymm3\n"
            "vaddpd %%ymm1, %%ymm0, %%ymm8\n"
            "vsubpd %%ymm1, %%ymm0, %%ymm9\n"
            "vaddpd %%ymm3, %%ymm2, %%ymm10\n"
            "vsubpd %%ymm3, %%ymm2, %%ymm11\n"
            "vaddpd %%ymm10, %%ymm8, %%ymm0\n"
            "vsubpd %%ymm10, %%ymm8, %%ymm2\n"
            "vaddpd %%ymm11, %%ymm9, %%ymm1\n"
            "vsubpd %%ymm11, %%ymm9, %%ymm3\n"
            "vmovupd %%ymm0, (%0)\n"
            "vmovupd %%ymm1, (%1)\n"
            "vmovupd %%ymm2, (%2)\n"
            "vmovupd %%ymm3, (%3)\n" ::"r"(buf + j + k + 0),
            "r"(buf + j + k + 4), "r"(buf + j + k + 8), "r"(buf + j + k + 12)
            : "%ymm0", "%ymm1", "%ymm2", "%ymm3", "%ymm4", "%ymm5", "%ymm6",
              "%ymm7", "%ymm8", "%ymm9", "%ymm10", "%ymm11", "%ymm12", "%ymm13",
              "%ymm14", "%ymm15", "memory");
      }
    }
    return;
  }
}


x86 assembly (clang, -O0):
<helper_double_4_recursive>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jne    12e9 <helper_double_4_recursive+0x1e9>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    12e4 <helper_double_4_recursive+0x1e4>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    12d1 <helper_double_4_recursive+0x1d1>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
shl    $0x3,%rdx
add    %rdx,%rcx
movslq -0x14(%rbp),%rdx
shl    $0x3,%rdx
add    %rdx,%rcx
add    $0x20,%rcx
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rsi
shl    $0x3,%rsi
add    %rsi,%rdx
movslq -0x14(%rbp),%rsi
shl    $0x3,%rsi
add    %rsi,%rdx
add    $0x40,%rdx
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rdi
shl    $0x3,%rdi
add    %rdi,%rsi
movslq -0x14(%rbp),%rdi
shl    $0x3,%rdi
add    %rdi,%rsi
add    $0x60,%rsi
vmovupd (%rax),%ymm0
vmovupd (%rcx),%ymm1
vmovupd (%rdx),%ymm2
vmovupd (%rsi),%ymm3
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
vpermilpd $0x0,%ymm2,%ymm8
vpermilpd $0xf,%ymm2,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm2
vpermilpd $0x0,%ymm3,%ymm8
vpermilpd $0xf,%ymm3,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm3
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
vperm2f128 $0x0,%ymm2,%ymm2,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm2,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm2,%ymm11
vaddpd %ymm11,%ymm8,%ymm2
vperm2f128 $0x0,%ymm3,%ymm3,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm3,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm3,%ymm11
vaddpd %ymm11,%ymm8,%ymm3
vaddpd %ymm1,%ymm0,%ymm8
vsubpd %ymm1,%ymm0,%ymm9
vaddpd %ymm3,%ymm2,%ymm10
vsubpd %ymm3,%ymm2,%ymm11
vaddpd %ymm10,%ymm8,%ymm0
vsubpd %ymm10,%ymm8,%ymm2
vaddpd %ymm11,%ymm9,%ymm1
vsubpd %ymm11,%ymm9,%ymm3
vmovupd %ymm0,(%rax)
vmovupd %ymm1,(%rcx)
vmovupd %ymm2,(%rdx)
vmovupd %ymm3,(%rsi)
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <helper_double_4_recursive+0x2d>
jmp    12d6 <helper_double_4_recursive+0x1d6>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    111c <helper_double_4_recursive+0x1c>
jmp    12e9 <helper_double_4_recursive+0x1e9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<helper_double_4_recursive>:
cmp    $0x4,%esi
jne    122d <helper_double_4_recursive+0x12d>
lea    0x20(%rdi),%rax
lea    0x40(%rdi),%rcx
lea    0x60(%rdi),%rdx
vmovupd (%rdi),%ymm0
vmovupd (%rax),%ymm1
vmovupd (%rcx),%ymm2
vmovupd (%rdx),%ymm3
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
vpermilpd $0x0,%ymm2,%ymm8
vpermilpd $0xf,%ymm2,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm2
vpermilpd $0x0,%ymm3,%ymm8
vpermilpd $0xf,%ymm3,%ymm9
vxorpd %ymm10,%ymm10,%ymm10
vsubpd %ymm9,%ymm10,%ymm11
vaddsubpd %ymm11,%ymm8,%ymm3
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
vperm2f128 $0x0,%ymm2,%ymm2,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm2,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm2,%ymm11
vaddpd %ymm11,%ymm8,%ymm2
vperm2f128 $0x0,%ymm3,%ymm3,%ymm8
vxorpd %ymm9,%ymm9,%ymm9
vsubpd %ymm3,%ymm9,%ymm10
vperm2f128 $0x31,%ymm10,%ymm3,%ymm11
vaddpd %ymm11,%ymm8,%ymm3
vaddpd %ymm1,%ymm0,%ymm8
vsubpd %ymm1,%ymm0,%ymm9
vaddpd %ymm3,%ymm2,%ymm10
vsubpd %ymm3,%ymm2,%ymm11
vaddpd %ymm10,%ymm8,%ymm0
vsubpd %ymm10,%ymm8,%ymm2
vaddpd %ymm11,%ymm9,%ymm1
vsubpd %ymm11,%ymm9,%ymm3
vmovupd %ymm0,(%rdi)
vmovupd %ymm1,(%rax)
vmovupd %ymm2,(%rcx)
vmovupd %ymm3,(%rdx)
ret

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

LLVM IR (-O2):
define void @helper_double_4_recursive(double* %0, i32 %1) {
%3 = icmp eq i32 %1, 4
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds double, double* %0, i64 4
%6 = getelementptr inbounds double, double* %0, i64 8
%7 = getelementptr inbounds double, double* %0, i64 12
tail call void asm sideeffect "vmovupd ($0), %ymm0\0Avmovupd ($1), %ymm1\0Avmovupd ($2), %ymm2\0Avmovupd ($3), %ymm3\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\0Avpermilpd $$0, %ymm2, %ymm8\0Avpermilpd $$15, %ymm2, %ymm9\0Avxorpd %ymm10, %ymm10, %ymm10\0Avsubpd %ymm9, %ymm10, %ymm11\0Avaddsubpd %ymm11, %ymm8, %ymm2\0Avpermilpd $$0, %ymm3, %ymm8\0Avpermilpd $$15, %ymm3, %ymm9\0Avxorpd %ymm10, %ymm10, %ymm10\0Avsubpd %ymm9, %ymm10, %ymm11\0Avaddsubpd %ymm11, %ymm8, %ymm3\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\0Avperm2f128 $$0, %ymm2, %ymm2, %ymm8\0Avxorpd %ymm9, %ymm9, %ymm9\0Avsubpd %ymm2, %ymm9, %ymm10\0Avperm2f128 $$49, %ymm10, %ymm2, %ymm11\0Avaddpd %ymm11, %ymm8, %ymm2\0Avperm2f128 $$0, %ymm3, %ymm3, %ymm8\0Avxorpd %ymm9, %ymm9, %ymm9\0Avsubpd %ymm3, %ymm9, %ymm10\0Avperm2f128 $$49, %ymm10, %ymm3, %ymm11\0Avaddpd %ymm11, %ymm8, %ymm3\0Avaddpd %ymm1, %ymm0, %ymm8\0Avsubpd %ymm1, %ymm0, %ymm9\0Avaddpd %ymm3, %ymm2, %ymm10\0Avsubpd %ymm3, %ymm2, %ymm11\0Avaddpd %ymm10, %ymm8, %ymm0\0Avsubpd %ymm10, %ymm8, %ymm2\0Avaddpd %ymm11, %ymm9, %ymm1\0Avsubpd %ymm11, %ymm9, %ymm3\0Avmovupd %ymm0, ($0)\0Avmovupd %ymm1, ($1)\0Avmovupd %ymm2, ($2)\0Avmovupd %ymm3, ($3)\0A", "r,r,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* %5, double* %6, double* %7)
br label %8
8: ; preds = %4, %2
ret void
}