#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ bitrv2(int, int *, double *);
int /*<<< orphan*/ cftbsub(int, double *, double *);
int /*<<< orphan*/ cftfsub(int, double *, double *);
int /*<<< orphan*/ makect(int, int *, double *);
int /*<<< orphan*/ makewt(int, int *, double *);
int /*<<< orphan*/ rftbsub(int, double *, int, double *);
int /*<<< orphan*/ rftfsub(int, double *, int, double *);
void lsx_rdft(int n, int isgn, double *a, int *ip, double *w) {
  int nw, nc;
  double xi;
  if (n > 262144)
    return;
  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) {
      bitrv2(n, ip + 2, a);
      cftfsub(n, a, w);
      rftfsub(n, a, nc, w + nw);
    } else if (n == 4) {
      cftfsub(n, a, w);
    }
    xi = a[0] - a[1];
    a[0] += a[1];
    a[1] = xi;
  } else {
    a[1] = 0.5 * (a[0] - a[1]);
    a[0] -= a[1];
    if (n > 4) {
      rftbsub(n, a, nc, w + nw);
      bitrv2(n, ip + 2, a);
      cftbsub(n, a, w);
    } else if (n == 4) {
      cftfsub(n, a, w);
    }
  }
}


x86 assembly (clang, -O0):
<lsx_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)
cmpl   $0x40000,-0x4(%rbp)
jle    119c <lsx_rdft+0x2c>
jmp    137a <lsx_rdft+0x20a>
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    11cf <lsx_rdft+0x5f>
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    120e <lsx_rdft+0x9e>
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   1080 <makect@plt>
cmpl   $0x0,-0x8(%rbp)
jl     12c6 <lsx_rdft+0x156>
cmpl   $0x4,-0x4(%rbp)
jle    1269 <lsx_rdft+0xf9>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
add    $0x8,%rsi
mov    -0x10(%rbp),%rdx
call   1050 <bitrv2@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <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    1288 <lsx_rdft+0x118>
cmpl   $0x4,-0x4(%rbp)
jne    1283 <lsx_rdft+0x113>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <cftfsub@plt>
jmp    1288 <lsx_rdft+0x118>
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    137a <lsx_rdft+0x20a>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
movsd  0xd21(%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    1356 <lsx_rdft+0x1e6>
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   1070 <rftbsub@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
add    $0x8,%rsi
mov    -0x10(%rbp),%rdx
call   1050 <bitrv2@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <cftbsub@plt>
jmp    1375 <lsx_rdft+0x205>
cmpl   $0x4,-0x4(%rbp)
jne    1370 <lsx_rdft+0x200>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <cftfsub@plt>
jmp    1375 <lsx_rdft+0x205>
jmp    137a <lsx_rdft+0x20a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lsx_rdft>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x40000,%edi
jg     12de <lsx_rdft+0x16e>
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
mov    (%rcx),%r12d
lea    0x0(,%r12,4),%eax
cmp    %edi,%eax
jge    11bc <lsx_rdft+0x4c>
mov    %ebp,%r12d
sar    $0x2,%r12d
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r8,%rdx
mov    %r8,%r13
call   1030 <makewt@plt>
mov    %r13,%r8
mov    0x4(%rbx),%r13d
lea    0x0(,%r13,4),%eax
cmp    %ebp,%eax
jge    11ed <lsx_rdft+0x7d>
mov    %ebp,%r13d
sar    $0x2,%r13d
movslq %r12d,%rax
lea    (%r8,%rax,8),%rdx
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %r8,(%rsp)
call   1080 <makect@plt>
mov    (%rsp),%r8
test   %r14d,%r14d
js     1235 <lsx_rdft+0xc5>
cmp    $0x5,%ebp
jl     12a7 <lsx_rdft+0x137>
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r8,%rbx
call   1050 <bitrv2@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1090 <cftfsub@plt>
movslq %r12d,%rax
lea    (%rbx,%rax,8),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r13d,%edx
call   1040 <rftfsub@plt>
jmp    12bc <lsx_rdft+0x14c>
movsd  (%r15),%xmm0
movapd %xmm0,%xmm1
subsd  0x8(%r15),%xmm1
mulsd  0xdb4(%rip),%xmm1
movsd  %xmm1,0x8(%r15)
subsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
cmp    $0x5,%ebp
jl     12ed <lsx_rdft+0x17d>
movslq %r12d,%rax
lea    (%r8,%rax,8),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %r8,%r14
call   1070 <rftbsub@plt>
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <bitrv2@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <cftbsub@plt>
cmp    $0x4,%ebp
jne    12bc <lsx_rdft+0x14c>
mov    $0x4,%edi
mov    %r15,%rsi
mov    %r8,%rdx
call   1090 <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    12de <lsx_rdft+0x16e>
mov    $0x4,%edi
mov    %r15,%rsi
mov    %r8,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <cftfsub@plt>

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

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