void dif_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 = 1;
  end = data + size + size;
  for (dl = size; dl > 1; dl >>= 1, astep += astep) {
    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 + *l2;
        xi = *(l1 + 1) + *(l2 + 1);
        dr = *l1 - *l2;
        di = *(l1 + 1) - *(l2 + 1);
        yr = dr * wr - di * wi;
        yi = dr * wi + di * wr;
        *(l1) = xr;
        *(l1 + 1) = xi;
        *(l2) = yr;
        *(l2 + 1) = yi;
        angle += astep;
      }
    }
  }
}


x86 assembly (clang, -O0):
<dif_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)
movq   $0x1,-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)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x1,-0x38(%rbp)
jle    1360 <dif_butterfly+0x260>
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    133e <dif_butterfly+0x23e>
mov    -0x88(%rbp),%rax
mov    %rax,-0x98(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x80(%rbp),%rax
cmp    -0x98(%rbp),%rax
jae    1310 <dif_butterfly+0x210>
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
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x80(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x88(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x80(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x88(%rbp),%rax
addsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x80(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x88(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x80(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x88(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x78(%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,-0x48(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x80(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x80(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x88(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%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    119c <dif_butterfly+0x9c>
jmp    1315 <dif_butterfly+0x215>
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    1172 <dif_butterfly+0x72>
jmp    1343 <dif_butterfly+0x243>
mov    -0x38(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1149 <dif_butterfly+0x49>
add    $0x18,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dif_butterfly>:
push   %r14
push   %rbx
cmp    $0x2,%rsi
jl     11e2 <dif_butterfly+0xe2>
lea    (%rdi,%rsi,8),%rax
lea    (%rax,%rsi,8),%r9
mov    $0x1,%r8d
movapd 0xedd(%rip),%xmm0
jmp    1146 <dif_butterfly+0x46>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rsi,%rax
sar    %rax
add    %r8,%r8
cmp    $0x3,%rsi
mov    %rax,%rsi
jle    11e2 <dif_butterfly+0xe2>
lea    (%rdi,%rsi,8),%r11
cmp    %r9,%r11
jae    1130 <dif_butterfly+0x30>
lea    0x0(,%r8,8),%r10
mov    %rdi,%rax
jmp    116f <dif_butterfly+0x6f>
nopl   0x0(%rax)
mov    %r11,%r14
lea    (%r14,%rsi,8),%r11
mov    %r14,%rax
cmp    %r9,%r11
jae    1130 <dif_butterfly+0x30>
cmp    %r11,%rax
jae    1160 <dif_butterfly+0x60>
xor    %ebx,%ebx
mov    %r11,%r14
nopl   0x0(%rax)
movsd  (%rcx,%rbx,1),%xmm1
movapd %xmm1,%xmm2
xorpd  %xmm0,%xmm2
movupd (%rax),%xmm3
movupd (%r14),%xmm4
movapd %xmm3,%xmm5
addpd  %xmm4,%xmm5
subpd  %xmm4,%xmm3
movsd  (%rdx,%rbx,1),%xmm4
unpcklpd %xmm4,%xmm1
movapd %xmm3,%xmm6
unpckhpd %xmm3,%xmm6
mulpd  %xmm1,%xmm6
unpcklpd %xmm3,%xmm3
unpcklpd %xmm2,%xmm4
mulpd  %xmm3,%xmm4
addpd  %xmm6,%xmm4
movupd %xmm5,(%rax)
movupd %xmm4,(%r14)
add    $0x10,%rax
add    $0x10,%r14
add    %r10,%rbx
cmp    %r11,%rax
jb     1180 <dif_butterfly+0x80>
jmp    1163 <dif_butterfly+0x63>
pop    %rbx
pop    %r14
ret

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

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