void inverse_dit_butterfly(double *data, long size, double *cos_ang,
                           double *sin_ang) {
  long angle, astep, dl;
  double xr, yr, xi, yi, wr, wi, dr, di;
  double *l1, *l2, *end, *ol2;
  astep = size >> 1;
  end = data + size + size;
  for (dl = 2; astep > 0; dl += dl, astep >>= 1) {
    l1 = data;
    l2 = data + dl;
    for (; l2 < end; l1 = l2, l2 = l2 + dl) {
      ol2 = l2;
      for (angle = 0; l1 < ol2; l1 += 2, l2 += 2) {
        wr = cos_ang[angle];
        wi = sin_ang[angle];
        xr = *l1;
        xi = *(l1 + 1);
        yr = *l2;
        yi = *(l2 + 1);
        dr = yr * wr - yi * wi;
        di = yr * wi + yi * wr;
        *(l1) = xr + dr;
        *(l1 + 1) = xi + di;
        *(l2) = xr - dr;
        *(l2 + 1) = xi - di;
        angle += astep;
      }
    }
  }
}


x86 assembly (clang, -O0):
<inverse_dit_butterfly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x18,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x90(%rbp)
movq   $0x2,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
jle    1339 <inverse_dit_butterfly+0x239>
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
cmp    -0x90(%rbp),%rax
jae    1317 <inverse_dit_butterfly+0x217>
mov    -0x88(%rbp),%rax
mov    %rax,-0x98(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x80(%rbp),%rax
cmp    -0x98(%rbp),%rax
jae    12e9 <inverse_dit_butterfly+0x1e9>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x80(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x80(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x88(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x88(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
mov    -0x80(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
mov    -0x80(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x40(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
mov    -0x88(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
mov    -0x88(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x80(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x80(%rbp)
mov    -0x88(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x88(%rbp)
jmp    11a0 <inverse_dit_butterfly+0xa0>
jmp    12ee <inverse_dit_butterfly+0x1ee>
mov    -0x88(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x88(%rbp),%rax
mov    -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x88(%rbp)
jmp    1176 <inverse_dit_butterfly+0x76>
jmp    131c <inverse_dit_butterfly+0x21c>
mov    -0x38(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    114d <inverse_dit_butterfly+0x4d>
add    $0x18,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inverse_dit_butterfly>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%rsi
jl     11ed <inverse_dit_butterfly+0xed>
lea    (%rdi,%rsi,8),%rax
lea    (%rax,%rsi,8),%r8
mov    $0x2,%r10d
movapd 0xedb(%rip),%xmm0
mov    %rsi,%r9
jmp    1140 <inverse_dit_butterfly+0x40>
nopw   0x0(%rax,%rax,1)
add    %r10,%r10
cmp    $0x3,%rsi
mov    %r9,%rsi
jle    11ed <inverse_dit_butterfly+0xed>
sar    %r9
lea    (%rdi,%r10,8),%r14
cmp    %r8,%r14
jae    1130 <inverse_dit_butterfly+0x30>
lea    0x0(,%r9,8),%r11
mov    %rdi,%r15
jmp    116c <inverse_dit_butterfly+0x6c>
nopl   0x0(%rax)
mov    %r14,%r15
lea    (%r14,%r10,8),%r14
cmp    %r8,%r14
jae    1130 <inverse_dit_butterfly+0x30>
cmp    %r14,%r15
jae    1160 <inverse_dit_butterfly+0x60>
xor    %ebx,%ebx
mov    %r14,%rax
cs nopw 0x0(%rax,%rax,1)
movupd (%r15),%xmm1
movsd  (%rax),%xmm2
movsd  0x8(%rax),%xmm3
movapd %xmm3,%xmm4
xorpd  %xmm0,%xmm4
movsd  (%rdx,%rbx,1),%xmm5
movsd  (%rcx,%rbx,1),%xmm6
movapd %xmm6,%xmm7
unpcklpd %xmm5,%xmm7
unpcklpd %xmm3,%xmm4
mulpd  %xmm7,%xmm4
unpcklpd %xmm2,%xmm2
unpcklpd %xmm6,%xmm5
mulpd  %xmm2,%xmm5
addpd  %xmm4,%xmm5
movapd %xmm1,%xmm2
addpd  %xmm5,%xmm2
movupd %xmm2,(%r15)
subpd  %xmm5,%xmm1
movupd %xmm1,(%rax)
add    $0x10,%r15
add    $0x10,%rax
add    %r11,%rbx
cmp    %r14,%r15
jb     1180 <inverse_dit_butterfly+0x80>
mov    %rax,%r14
jmp    1160 <inverse_dit_butterfly+0x60>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @inverse_dit_butterfly(double* %0, i64 %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca i64
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double*
%21 = alloca double*
%22 = alloca double*
%23 = alloca double*
store double* %0, double** %5
store i64 %1, i64* %6
store double* %2, double** %7
store double* %3, double** %8
%24 = load i64, i64* %6
%25 = ashr i64 %24, 1
store i64 %25, i64* %10
%26 = load double*, double** %5
%27 = load i64, i64* %6
%28 = getelementptr inbounds double, double* %26, i64 %27
%29 = load i64, i64* %6
%30 = getelementptr inbounds double, double* %28, i64 %29
store double* %30, double** %22
store i64 2, i64* %11
br label %31
31: ; preds = %114, %4
%32 = load i64, i64* %10
%33 = icmp sgt i64 %32, 0
br i1 %33, label %34, label %120
34: ; preds = %31
%35 = load double*, double** %5
store double* %35, double** %20
%36 = load double*, double** %5
%37 = load i64, i64* %11
%38 = getelementptr inbounds double, double* %36, i64 %37
store double* %38, double** %21
br label %39
39: ; preds = %108, %34
%40 = load double*, double** %21
%41 = load double*, double** %22
%42 = icmp ult double* %40, %41
br i1 %42, label %43, label %113
43: ; preds = %39
%44 = load double*, double** %21
store double* %44, double** %23
store i64 0, i64* %9
br label %45
45: ; preds = %102, %43
%46 = load double*, double** %20
%47 = load double*, double** %23
%48 = icmp ult double* %46, %47
br i1 %48, label %49, label %107
49: ; preds = %45
%50 = load double*, double** %7
%51 = load i64, i64* %9
%52 = getelementptr inbounds double, double* %50, i64 %51
%53 = load double, double* %52
store double %53, double* %16
%54 = load double*, double** %8
%55 = load i64, i64* %9
%56 = getelementptr inbounds double, double* %54, i64 %55
%57 = load double, double* %56
store double %57, double* %17
%58 = load double*, double** %20
%59 = load double, double* %58
store double %59, double* %12
%60 = load double*, double** %20
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
store double %62, double* %14
%63 = load double*, double** %21
%64 = load double, double* %63
store double %64, double* %13
%65 = load double*, double** %21
%66 = getelementptr inbounds double, double* %65, i64 1
%67 = load double, double* %66
store double %67, double* %15
%68 = load double, double* %13
%69 = load double, double* %16
%70 = load double, double* %15
%71 = load double, double* %17
%72 = fmul double %70, %71
%73 = fneg double %72
%74 = call double @llvm.fmuladd.f64(double %68, double %69, double %73)
store double %74, double* %18
%75 = load double, double* %13
%76 = load double, double* %17
%77 = load double, double* %15
%78 = load double, double* %16
%79 = fmul double %77, %78
%80 = call double @llvm.fmuladd.f64(double %75, double %76, double %79)
store double %80, double* %19
%81 = load double, double* %12
%82 = load double, double* %18
%83 = fadd double %81, %82
%84 = load double*, double** %20
store double %83, double* %84
%85 = load double, double* %14
%86 = load double, double* %19
%87 = fadd double %85, %86
%88 = load double*, double** %20
%89 = getelementptr inbounds double, double* %88, i64 1
store double %87, double* %89
%90 = load double, double* %12
%91 = load double, double* %18
%92 = fsub double %90, %91
%93 = load double*, double** %21
store double %92, double* %93
%94 = load double, double* %14
%95 = load double, double* %19
%96 = fsub double %94, %95
%97 = load double*, double** %21
%98 = getelementptr inbounds double, double* %97, i64 1
store double %96, double* %98
%99 = load i64, i64* %10
%100 = load i64, i64* %9
%101 = add nsw i64 %100, %99
store i64 %101, i64* %9
br label %102
102: ; preds = %49
%103 = load double*, double** %20
%104 = getelementptr inbounds double, double* %103, i64 2
store double* %104, double** %20
%105 = load double*, double** %21
%106 = getelementptr inbounds double, double* %105, i64 2
store double* %106, double** %21
br label %45
107: ; preds = %45
br label %108
108: ; preds = %107
%109 = load double*, double** %21
store double* %109, double** %20
%110 = load double*, double** %21
%111 = load i64, i64* %11
%112 = getelementptr inbounds double, double* %110, i64 %111
store double* %112, double** %21
br label %39
113: ; preds = %39
br label %114
114: ; preds = %113
%115 = load i64, i64* %11
%116 = load i64, i64* %11
%117 = add nsw i64 %116, %115
store i64 %117, i64* %11
%118 = load i64, i64* %10
%119 = ashr i64 %118, 1
store i64 %119, i64* %10
br label %31
120: ; preds = %31
ret void
}

LLVM IR (-O2):
define void @inverse_dit_butterfly(double* %0, i64 %1, double* nocapture %2, double* nocapture %3) {
%5 = getelementptr inbounds double, double* %0, i64 %1
%6 = getelementptr inbounds double, double* %5, i64 %1
%7 = icmp sgt i64 %1, 1
br i1 %7, label %8, label %57
8: ; preds = %4, %54
%9 = phi i64 [ %11, %54 ], [ %1, %4 ]
%10 = phi i64 [ %55, %54 ], [ 2, %4 ]
%11 = ashr i64 %9, 1
%12 = getelementptr inbounds double, double* %0, i64 %10
%13 = icmp ult double* %12, %6
br i1 %13, label %18, label %54
14: ; preds = %22, %18
%15 = phi double* [ %19, %18 ], [ %52, %22 ]
%16 = getelementptr inbounds double, double* %15, i64 %10
%17 = icmp ult double* %16, %6
br i1 %17, label %18, label %54
18: ; preds = %8, %14
%19 = phi double* [ %16, %14 ], [ %12, %8 ]
%20 = phi double* [ %15, %14 ], [ %0, %8 ]
%21 = icmp ult double* %20, %19
br i1 %21, label %22, label %14
22: ; preds = %18, %22
%23 = phi i64 [ %50, %22 ], [ 0, %18 ]
%24 = phi double* [ %52, %22 ], [ %19, %18 ]
%25 = phi double* [ %51, %22 ], [ %20, %18 ]
%26 = getelementptr inbounds double, double* %2, i64 %23
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %3, i64 %23
%29 = load double, double* %28
%30 = bitcast double* %25 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = load double, double* %24
%33 = getelementptr inbounds double, double* %24, i64 1
%34 = load double, double* %33
%35 = fneg double %34
%36 = insertelement <2 x double> poison, double %29, i64 0
%37 = insertelement <2 x double> %36, double %27, i64 1
%38 = insertelement <2 x double> poison, double %35, i64 0
%39 = insertelement <2 x double> %38, double %34, i64 1
%40 = fmul <2 x double> %37, %39
%41 = insertelement <2 x double> poison, double %32, i64 0
%42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
%43 = insertelement <2 x double> poison, double %27, i64 0
%44 = insertelement <2 x double> %43, double %29, i64 1
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %42, <2 x double> %44, <2 x double> %40)
%46 = fadd <2 x double> %31, %45
%47 = bitcast double* %25 to <2 x double>*
store <2 x double> %46, <2 x double>* %47
%48 = fsub <2 x double> %31, %45
%49 = bitcast double* %24 to <2 x double>*
store <2 x double> %48, <2 x double>* %49
%50 = add nsw i64 %23, %11
%51 = getelementptr inbounds double, double* %25, i64 2
%52 = getelementptr inbounds double, double* %24, i64 2
%53 = icmp ult double* %51, %19
br i1 %53, label %22, label %14
54: ; preds = %14, %8
%55 = shl nsw i64 %10, 1
%56 = icmp sgt i64 %9, 3
br i1 %56, label %8, label %57
57: ; preds = %54, %4
ret void
}