void cftrec4(int n, double *a, int nw, double *w) {
  int cfttree(int n, int j, int k, double *a, int nw, double *w);
  void cftleaf(int n, int isplt, double *a, int nw, double *w);
  void cftmdl1(int n, double *a, double *w);
  int isplt, j, k, m;
  m = n;
  while (m > 512) {
    m >>= 2;
    cftmdl1(m, &a[n - m], &w[nw - (m >> 1)]);
  }
  cftleaf(m, 1, &a[n - m], nw, w);
  k = 0;
  for (j = n - m; j > 0; j -= m) {
    k++;
    isplt = cfttree(m, j, k, a, nw, w);
    cftleaf(m, isplt, &a[j - m], nw, w);
  }
}


x86 assembly (clang, -O0):
<cftrec4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x200,-0x30(%rbp)
jle    119a <cftrec4+0x6a>
mov    -0x30(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%eax
sub    -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%eax
mov    -0x30(%rbp),%ecx
sar    $0x1,%ecx
sub    %ecx,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
call   1040 <cftmdl1@plt>
jmp    114c <cftrec4+0x1c>
mov    -0x30(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%eax
sub    -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    $0x1,%esi
call   1030 <cftleaf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    1236 <cftrec4+0x106>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9
call   1050 <cfttree@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%eax
sub    -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1030 <cftleaf@plt>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
jmp    11d1 <cftrec4+0xa1>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cftrec4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rsi,%r13
mov    %edi,%ebp
mov    %edi,%ebx
cmp    $0x201,%edi
jl     1199 <cftrec4+0x69>
mov    %ebp,%r14d
mov    %ebp,%ebx
nopl   0x0(%rax,%rax,1)
shr    $0x2,%ebx
mov    %ebp,%eax
sub    %ebx,%eax
cltq
lea    0x0(,%rax,8),%rsi
add    %r13,%rsi
mov    %r14d,%eax
shr    $0x3,%eax
mov    %r12d,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
lea    (%r15,%rax,8),%rdx
mov    %ebx,%edi
call   1040 <cftmdl1@plt>
cmp    $0x803,%r14d
mov    %ebx,%r14d
ja     1160 <cftrec4+0x30>
mov    %r15,%r8
mov    %r13,%r15
mov    %ebp,%r13d
sub    %ebx,%r13d
movslq %r13d,%rax
mov    %rax,0x8(%rsp)
lea    (%r15,%rax,8),%rdx
mov    $0x1,%r14d
mov    %ebx,%edi
mov    $0x1,%esi
mov    %r12d,%ecx
mov    %r8,0x10(%rsp)
call   1030 <cftleaf@plt>
cmpl   $0x0,0x8(%rsp)
jle    122d <cftrec4+0xfd>
sub    %ebx,%ebp
sub    %ebx,%ebp
mov    %r15,(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r14d,%edx
mov    %r15,%rcx
mov    %r12d,%r8d
mov    %r12d,%r15d
mov    0x10(%rsp),%r12
mov    %r12,%r9
call   1050 <cfttree@plt>
sub    %ebx,%r13d
movslq %ebp,%rbp
mov    (%rsp),%rcx
lea    (%rcx,%rbp,8),%rdx
mov    %ebx,%edi
mov    %eax,%esi
mov    %r15d,%ecx
mov    %r12,%r8
mov    %r15d,%r12d
mov    (%rsp),%r15
call   1030 <cftleaf@plt>
add    $0x1,%r14d
sub    %ebx,%ebp
test   %r13d,%r13d
jg     11e0 <cftrec4+0xb0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cftrec4(i32 %0, double* %1, i32 %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store i32 %2, i32* %7
store double* %3, double** %8
%13 = load i32, i32* %5
store i32 %13, i32* %12
br label %14
14: ; preds = %17, %4
%15 = load i32, i32* %12
%16 = icmp sgt i32 %15, 512
br i1 %16, label %17, label %34
17: ; preds = %14
%18 = load i32, i32* %12
%19 = ashr i32 %18, 2
store i32 %19, i32* %12
%20 = load i32, i32* %12
%21 = load double*, double** %6
%22 = load i32, i32* %5
%23 = load i32, i32* %12
%24 = sub nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %21, i64 %25
%27 = load double*, double** %8
%28 = load i32, i32* %7
%29 = load i32, i32* %12
%30 = ashr i32 %29, 1
%31 = sub nsw i32 %28, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %27, i64 %32
br label %14
34: ; preds = %14
%35 = load i32, i32* %12
%36 = load double*, double** %6
%37 = load i32, i32* %5
%38 = load i32, i32* %12
%39 = sub nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %36, i64 %40
%42 = load i32, i32* %7
%43 = load double*, double** %8
store i32 0, i32* %11
%44 = load i32, i32* %5
%45 = load i32, i32* %12
%46 = sub nsw i32 %44, %45
store i32 %46, i32* %10
br label %47
47: ; preds = %70, %34
%48 = load i32, i32* %10
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %74
50: ; preds = %47
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
%53 = load i32, i32* %12
%54 = load i32, i32* %10
%55 = load i32, i32* %11
%56 = load double*, double** %6
%57 = load i32, i32* %7
%58 = load double*, double** %8
%59 = call i32 @cfttree(i32 %53, i32 %54, i32 %55, double* %56, i32 %57, double* %58)
store i32 %59, i32* %9
%60 = load i32, i32* %12
%61 = load i32, i32* %9
%62 = load double*, double** %6
%63 = load i32, i32* %10
%64 = load i32, i32* %12
%65 = sub nsw i32 %63, %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %62, i64 %66
%68 = load i32, i32* %7
%69 = load double*, double** %8
br label %70
70: ; preds = %50
%71 = load i32, i32* %12
%72 = load i32, i32* %10
%73 = sub nsw i32 %72, %71
store i32 %73, i32* %10
br label %47
74: ; preds = %47
ret void
}

LLVM IR (-O2):
define void @cftrec4(i32 %0, double* %1, i32 %2, double* %3) {
%5 = icmp sgt i32 %0, 512
br i1 %5, label %6, label %17
6: ; preds = %4, %6
%7 = phi i32 [ %8, %6 ], [ %0, %4 ]
%8 = lshr i32 %7, 2
%9 = sub nsw i32 %0, %8
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = lshr i32 %7, 3
%13 = sub nsw i32 %2, %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %3, i64 %14
tail call void @cftmdl1(i32 %8, double* %11, double* %15)
%16 = icmp ugt i32 %7, 2051
br i1 %16, label %6, label %17
17: ; preds = %6, %4
%18 = phi i32 [ %0, %4 ], [ %8, %6 ]
%19 = sub nsw i32 %0, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %1, i64 %20
tail call void @cftleaf(i32 %18, i32 1, double* %21, i32 %2, double* %3)
%22 = icmp sgt i32 %19, 0
br i1 %22, label %23, label %32
23: ; preds = %17, %23
%24 = phi i32 [ %26, %23 ], [ 0, %17 ]
%25 = phi i32 [ %28, %23 ], [ %19, %17 ]
%26 = add nuw nsw i32 %24, 1
%27 = tail call i32 @cfttree(i32 %18, i32 %25, i32 %26, double* %1, i32 %2, double* %3)
%28 = sub nsw i32 %25, %18
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %1, i64 %29
tail call void @cftleaf(i32 %18, i32 %27, double* %30, i32 %2, double* %3)
%31 = icmp sgt i32 %28, 0
br i1 %31, label %23, label %32
32: ; preds = %23, %17
ret void
}