void helper_double_3_recursive(double *buf, int depth) {
  if (depth == 3) {
    for (int j = 0; j < 8; j += 8) {
      for (int k = 0; k < 2; k += 2) {
        __asm__ volatile(
            "movupd (%0), %%xmm0\n"
            "movupd (%1), %%xmm1\n"
            "movupd (%2), %%xmm2\n"
            "movupd (%3), %%xmm3\n"
            "movapd %%xmm0, %%xmm8\n"
            "haddpd %%xmm8, %%xmm8\n"
            "movapd %%xmm0, %%xmm9\n"
            "hsubpd %%xmm9, %%xmm9\n"
            "blendpd $1, %%xmm8, %%xmm9\n"
            "movapd %%xmm9, %%xmm0\n"
            "movapd %%xmm1, %%xmm8\n"
            "haddpd %%xmm8, %%xmm8\n"
            "movapd %%xmm1, %%xmm9\n"
            "hsubpd %%xmm9, %%xmm9\n"
            "blendpd $1, %%xmm8, %%xmm9\n"
            "movapd %%xmm9, %%xmm1\n"
            "movapd %%xmm2, %%xmm8\n"
            "haddpd %%xmm8, %%xmm8\n"
            "movapd %%xmm2, %%xmm9\n"
            "hsubpd %%xmm9, %%xmm9\n"
            "blendpd $1, %%xmm8, %%xmm9\n"
            "movapd %%xmm9, %%xmm2\n"
            "movapd %%xmm3, %%xmm8\n"
            "haddpd %%xmm8, %%xmm8\n"
            "movapd %%xmm3, %%xmm9\n"
            "hsubpd %%xmm9, %%xmm9\n"
            "blendpd $1, %%xmm8, %%xmm9\n"
            "movapd %%xmm9, %%xmm3\n"
            "movapd %%xmm0, %%xmm8\n"
            "movapd %%xmm0, %%xmm9\n"
            "addpd %%xmm1, %%xmm8\n"
            "subpd %%xmm1, %%xmm9\n"
            "movapd %%xmm2, %%xmm10\n"
            "movapd %%xmm2, %%xmm11\n"
            "addpd %%xmm3, %%xmm10\n"
            "subpd %%xmm3, %%xmm11\n"
            "movapd %%xmm8, %%xmm0\n"
            "movapd %%xmm8, %%xmm2\n"
            "addpd %%xmm10, %%xmm0\n"
            "subpd %%xmm10, %%xmm2\n"
            "movapd %%xmm9, %%xmm1\n"
            "movapd %%xmm9, %%xmm3\n"
            "addpd %%xmm11, %%xmm1\n"
            "subpd %%xmm11, %%xmm3\n"
            "movupd %%xmm0, (%0)\n"
            "movupd %%xmm1, (%1)\n"
            "movupd %%xmm2, (%2)\n"
            "movupd %%xmm3, (%3)\n" ::"r"(buf + j + k + 0),
            "r"(buf + j + k + 2), "r"(buf + j + k + 4), "r"(buf + j + k + 6)
            : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6",
              "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12", "%xmm13",
              "%xmm14", "%xmm15", "memory");
      }
    }
    return;
  }
}


x86 assembly (clang, -O0):
<helper_double_3_recursive>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jne    12c1 <helper_double_3_recursive+0x1c1>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    12bc <helper_double_3_recursive+0x1bc>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    12a9 <helper_double_3_recursive+0x1a9>
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    $0x10,%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    $0x20,%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    $0x30,%rsi
movupd (%rax),%xmm0
movupd (%rcx),%xmm1
movupd (%rdx),%xmm2
movupd (%rsi),%xmm3
movapd %xmm0,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm0,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm0
movapd %xmm1,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm1,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm1
movapd %xmm2,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm2,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm2
movapd %xmm3,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm3,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm3
movapd %xmm0,%xmm8
movapd %xmm0,%xmm9
addpd  %xmm1,%xmm8
subpd  %xmm1,%xmm9
movapd %xmm2,%xmm10
movapd %xmm2,%xmm11
addpd  %xmm3,%xmm10
subpd  %xmm3,%xmm11
movapd %xmm8,%xmm0
movapd %xmm8,%xmm2
addpd  %xmm10,%xmm0
subpd  %xmm10,%xmm2
movapd %xmm9,%xmm1
movapd %xmm9,%xmm3
addpd  %xmm11,%xmm1
subpd  %xmm11,%xmm3
movupd %xmm0,(%rax)
movupd %xmm1,(%rcx)
movupd %xmm2,(%rdx)
movupd %xmm3,(%rsi)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <helper_double_3_recursive+0x2d>
jmp    12ae <helper_double_3_recursive+0x1ae>
mov    -0x10(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x10(%rbp)
jmp    111c <helper_double_3_recursive+0x1c>
jmp    12c1 <helper_double_3_recursive+0x1c1>
pop    %rbp
ret

x86 assembly (clang, -O2):
<helper_double_3_recursive>:
cmp    $0x3,%esi
jne    1205 <helper_double_3_recursive+0x105>
lea    0x10(%rdi),%rax
lea    0x20(%rdi),%rcx
lea    0x30(%rdi),%rdx
movupd (%rdi),%xmm0
movupd (%rax),%xmm1
movupd (%rcx),%xmm2
movupd (%rdx),%xmm3
movapd %xmm0,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm0,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm0
movapd %xmm1,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm1,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm1
movapd %xmm2,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm2,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm2
movapd %xmm3,%xmm8
haddpd %xmm8,%xmm8
movapd %xmm3,%xmm9
hsubpd %xmm9,%xmm9
blendpd $0x1,%xmm8,%xmm9
movapd %xmm9,%xmm3
movapd %xmm0,%xmm8
movapd %xmm0,%xmm9
addpd  %xmm1,%xmm8
subpd  %xmm1,%xmm9
movapd %xmm2,%xmm10
movapd %xmm2,%xmm11
addpd  %xmm3,%xmm10
subpd  %xmm3,%xmm11
movapd %xmm8,%xmm0
movapd %xmm8,%xmm2
addpd  %xmm10,%xmm0
subpd  %xmm10,%xmm2
movapd %xmm9,%xmm1
movapd %xmm9,%xmm3
addpd  %xmm11,%xmm1
subpd  %xmm11,%xmm3
movupd %xmm0,(%rdi)
movupd %xmm1,(%rax)
movupd %xmm2,(%rcx)
movupd %xmm3,(%rdx)
ret

LLVM IR (-O0):
define void @helper_double_3_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, 3
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, 8
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, 2
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 2
%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 4
%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 6
br label %50
50: ; preds = %17
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 2
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, 8
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_3_recursive(double* %0, i32 %1) {
%3 = icmp eq i32 %1, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds double, double* %0, i64 2
%6 = getelementptr inbounds double, double* %0, i64 4
%7 = getelementptr inbounds double, double* %0, i64 6
tail call void asm sideeffect "movupd ($0), %xmm0\0Amovupd ($1), %xmm1\0Amovupd ($2), %xmm2\0Amovupd ($3), %xmm3\0Amovapd %xmm0, %xmm8\0Ahaddpd %xmm8, %xmm8\0Amovapd %xmm0, %xmm9\0Ahsubpd %xmm9, %xmm9\0Ablendpd $$1, %xmm8, %xmm9\0Amovapd %xmm9, %xmm0\0Amovapd %xmm1, %xmm8\0Ahaddpd %xmm8, %xmm8\0Amovapd %xmm1, %xmm9\0Ahsubpd %xmm9, %xmm9\0Ablendpd $$1, %xmm8, %xmm9\0Amovapd %xmm9, %xmm1\0Amovapd %xmm2, %xmm8\0Ahaddpd %xmm8, %xmm8\0Amovapd %xmm2, %xmm9\0Ahsubpd %xmm9, %xmm9\0Ablendpd $$1, %xmm8, %xmm9\0Amovapd %xmm9, %xmm2\0Amovapd %xmm3, %xmm8\0Ahaddpd %xmm8, %xmm8\0Amovapd %xmm3, %xmm9\0Ahsubpd %xmm9, %xmm9\0Ablendpd $$1, %xmm8, %xmm9\0Amovapd %xmm9, %xmm3\0Amovapd %xmm0, %xmm8\0Amovapd %xmm0, %xmm9\0Aaddpd %xmm1, %xmm8\0Asubpd %xmm1, %xmm9\0Amovapd %xmm2, %xmm10\0Amovapd %xmm2, %xmm11\0Aaddpd %xmm3, %xmm10\0Asubpd %xmm3, %xmm11\0Amovapd %xmm8, %xmm0\0Amovapd %xmm8, %xmm2\0Aaddpd %xmm10, %xmm0\0Asubpd %xmm10, %xmm2\0Amovapd %xmm9, %xmm1\0Amovapd %xmm9, %xmm3\0Aaddpd %xmm11, %xmm1\0Asubpd %xmm11, %xmm3\0Amovupd %xmm0, ($0)\0Amovupd %xmm1, ($1)\0Amovupd %xmm2, ($2)\0Amovupd %xmm3, ($3)\0A", "r,r,r,r,~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{memory},~{dirflag},~{fpsr},~{flags}"(double* %0, double* %5, double* %6, double* %7)
br label %8
8: ; preds = %4, %2
ret void
}