void rdft(int n, int isgn, double *a, int *ip, double *w) {
  void makewt(int nw, int *ip, double *w);
  void makect(int nc, int *ip, double *c);
  void cftfsub(int n, double *a, int *ip, int nw, double *w);
  void cftbsub(int n, double *a, int *ip, int nw, double *w);
  void rftfsub(int n, double *a, int nc, double *c);
  void rftbsub(int n, double *a, int nc, double *c);
  int nw, nc;
  double xi;
  nw = ip[0];
  if (n > (nw << 2)) {
    nw = n >> 2;
    makewt(nw, ip, w);
  }
  nc = ip[1];
  if (n > (nc << 2)) {
    nc = n >> 2;
    makect(nc, ip, w + nw);
  }
  if (isgn >= 0) {
    if (n > 4) {
      cftfsub(n, a, ip, nw, w);
      rftfsub(n, a, nc, w + nw);
    } else if (n == 4) {
      cftfsub(n, a, ip, nw, w);
    }
    xi = a[0] - a[1];
    a[0] += a[1];
    a[1] = xi;
  } else {
    a[1] = ((double)0.5) * (a[0] - a[1]);
    a[0] -= a[1];
    if (n > 4) {
      rftbsub(n, a, nc, w + nw);
      cftbsub(n, a, ip, nw, w);
    } else if (n == 4) {
      cftbsub(n, a, ip, nw, w);
    }
  }
}


x86 assembly (clang, -O0):
<rdft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jle    11ad <rdft+0x4d>
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <makewt@plt>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jle    11ec <rdft+0x8c>
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
call   1070 <makect@plt>
cmpl   $0x0,-0x8(%rbp)
jl     129e <rdft+0x13e>
cmpl   $0x4,-0x4(%rbp)
jle    123a <rdft+0xda>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1080 <cftfsub@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1040 <rftfsub@plt>
jmp    1260 <rdft+0x100>
cmpl   $0x4,-0x4(%rbp)
jne    125b <rdft+0xfb>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1080 <cftfsub@plt>
jmp    1260 <rdft+0x100>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    134c <rdft+0x1ec>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
movsd  0xd49(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
cmpl   $0x4,-0x4(%rbp)
jle    1321 <rdft+0x1c1>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1060 <rftbsub@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1050 <cftbsub@plt>
jmp    1347 <rdft+0x1e7>
cmpl   $0x4,-0x4(%rbp)
jne    1342 <rdft+0x1e2>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1050 <cftbsub@plt>
jmp    1347 <rdft+0x1e7>
jmp    134c <rdft+0x1ec>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdft>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
mov    (%rcx),%r13d
lea    0x0(,%r13,4),%eax
cmp    %edi,%eax
jge    11a0 <rdft+0x40>
mov    %ebp,%r13d
sar    $0x2,%r13d
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r8,%rdx
mov    %r8,%rbx
call   1030 <makewt@plt>
mov    %rbx,%r8
mov    0x4(%r12),%ebx
lea    0x0(,%rbx,4),%eax
cmp    %ebp,%eax
jge    11d6 <rdft+0x76>
mov    %ebp,%ebx
sar    $0x2,%ebx
movslq %r13d,%rax
lea    (%r8,%rax,8),%rdx
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r14d,0x4(%rsp)
mov    %r8,%r14
call   1070 <makect@plt>
mov    %r14,%r8
mov    0x4(%rsp),%r14d
test   %r14d,%r14d
js     1208 <rdft+0xa8>
cmp    $0x5,%ebp
jl     1259 <rdft+0xf9>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13d,%ecx
mov    %r8,%r14
call   1080 <cftfsub@plt>
movslq %r13d,%rax
lea    (%r14,%rax,8),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <rftfsub@plt>
jmp    1271 <rdft+0x111>
movsd  (%r15),%xmm0
movapd %xmm0,%xmm1
subsd  0x8(%r15),%xmm1
mulsd  0xde1(%rip),%xmm1
movsd  %xmm1,0x8(%r15)
subsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
cmp    $0x5,%ebp
jl     12a2 <rdft+0x142>
movslq %r13d,%rax
lea    (%r8,%rax,8),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r8,%rbx
call   1060 <rftbsub@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13d,%ecx
mov    %rbx,%r8
jmp    12b5 <rdft+0x155>
cmp    $0x4,%ebp
jne    1271 <rdft+0x111>
mov    $0x4,%edi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13d,%ecx
call   1080 <cftfsub@plt>
movsd  (%r15),%xmm0
movsd  0x8(%r15),%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
movsd  %xmm2,0x8(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x4,%ebp
jne    1293 <rdft+0x133>
mov    $0x4,%edi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <cftbsub@plt>

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

LLVM IR (-O2):
define void @rdft(i32 %0, i32 %1, double* %2, i32* %3, double* %4) {
%6 = load i32, i32* %3
%7 = shl i32 %6, 2
%8 = icmp slt i32 %7, %0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = ashr i32 %0, 2
tail call void @makewt(i32 %10, i32* %3, double* %4)
br label %11
11: ; preds = %9, %5
%12 = phi i32 [ %10, %9 ], [ %6, %5 ]
%13 = getelementptr inbounds i32, i32* %3, i64 1
%14 = load i32, i32* %13
%15 = shl i32 %14, 2
%16 = icmp slt i32 %15, %0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = ashr i32 %0, 2
%19 = sext i32 %12 to i64
%20 = getelementptr inbounds double, double* %4, i64 %19
tail call void @makect(i32 %18, i32* %3, double* %20)
br label %21
21: ; preds = %17, %11
%22 = phi i32 [ %18, %17 ], [ %14, %11 ]
%23 = icmp sgt i32 %1, -1
br i1 %23, label %24, label %38
24: ; preds = %21
%25 = icmp sgt i32 %0, 4
br i1 %25, label %26, label %29
26: ; preds = %24
tail call void @cftfsub(i32 %0, double* %2, i32* %3, i32 %12, double* %4)
%27 = sext i32 %12 to i64
%28 = getelementptr inbounds double, double* %4, i64 %27
tail call void @rftfsub(i32 %0, double* %2, i32 %22, double* %28)
br label %32
29: ; preds = %24
%30 = icmp eq i32 %0, 4
br i1 %30, label %31, label %32
31: ; preds = %29
tail call void @cftfsub(i32 4, double* %2, i32* %3, i32 %12, double* %4)
br label %32
32: ; preds = %29, %31, %26
%33 = load double, double* %2
%34 = getelementptr inbounds double, double* %2, i64 1
%35 = load double, double* %34
%36 = fsub double %33, %35
%37 = fadd double %33, %35
store double %37, double* %2
store double %36, double* %34
br label %52
38: ; preds = %21
%39 = load double, double* %2
%40 = getelementptr inbounds double, double* %2, i64 1
%41 = load double, double* %40
%42 = fsub double %39, %41
%43 = fmul double %42, 5.000000e-01
store double %43, double* %40
%44 = fsub double %39, %43
store double %44, double* %2
%45 = icmp sgt i32 %0, 4
br i1 %45, label %46, label %49
46: ; preds = %38
%47 = sext i32 %12 to i64
%48 = getelementptr inbounds double, double* %4, i64 %47
tail call void @rftbsub(i32 %0, double* %2, i32 %22, double* %48)
tail call void @cftbsub(i32 %0, double* %2, i32* %3, i32 %12, double* %4)
br label %52
49: ; preds = %38
%50 = icmp eq i32 %0, 4
br i1 %50, label %51, label %52
51: ; preds = %49
tail call void @cftbsub(i32 4, double* %2, i32* %3, i32 %12, double* %4)
br label %52
52: ; preds = %46, %51, %49, %32
ret void
}