// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: rfft(float*, COMPLEX*, int)
void rfft(float *x, COMPLEX *y, int m)
{
static    int      mstore = 0;
int       p,num,k;
float     Realsum, Realdif, Imagsum, Imagdif;
double    factor, arg;
COMPLEX   *ck, *xk, *xnk, *cx;

   /* First call the fft routine using the x array but with
      half the size of the real fft */

    p = m - 1;
    cx = (COMPLEX *) x;
    fft(cx, p);

    /* Next create the coefficients for recombination, if required */
    num = (1 << p);    /* num is half the real sequence length.  */

    if(m != mstore) { // fft size changed,  redo cf array
       mstore = m;  

       factor = 4.0*atan(1.0)/num;
       for (k = 1; k < num; k++){
         arg = factor*k;
         cf[k-1].real = (float)cos(arg);
         cf[k-1].imag = (float)sin(arg);
       }
    }

    /* DC component, no multiplies */
    y[0].real = cx[0].real + cx[0].imag;
    y[0].imag = 0.0;

    /* other frequencies by trig recombination */
    ck = cf;
    xk = cx + 1;
    xnk = cx + num - 1;
    for (k = 1; k < num; k++){
      Realsum = ( xk->real + xnk->real ) / 2.0F;
      Imagsum = ( xk->imag + xnk->imag ) / 2.0F;
      Realdif = ( xk->real - xnk->real ) / 2.0F;
      Imagdif = ( xk->imag - xnk->imag ) / 2.0F;

      y[k].real = Realsum + ck->real * Imagsum
                          - ck->imag * Realdif ;

      y[k].imag = Imagdif - ck->imag * Imagsum
                          - ck->real * Realdif ;
      ck++;
      xk++;
      xnk--;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x16c050
movl -0x18(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x349ff2(%rip), %eax    # 0x4b6548
je 0x16c60b
movl -0x14(%rbp), %eax
movl %eax, 0x349fe3(%rip)    # 0x4b6548
movsd 0x2afb(%rip), %xmm0     # 0x16f068
callq 0x92e0
movaps %xmm0, %xmm1
movsd 0x5153(%rip), %xmm0     # 0x1716d0
mulsd %xmm1, %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x16c609
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x20(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
callq 0x96f0
cvtsd2ss %xmm0, %xmm0
leaq 0x2329ca(%rip), %rax    # 0x39ef90
movq (%rax), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,8)
movsd -0x40(%rbp), %xmm0
callq 0x9080
cvtsd2ss %xmm0, %xmm0
leaq 0x2329a4(%rip), %rax    # 0x39ef90
movq (%rax), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movss %xmm0, 0x4(%rax,%rcx,8)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x16c596
jmp 0x16c60b
movq -0x60(%rbp), %rax
movss (%rax), %xmm0
movq -0x60(%rbp), %rax
addss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, (%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
leaq 0x232959(%rip), %rax    # 0x39ef90
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x60(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq -0x60(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $-0x8, %rax
movq %rax, -0x58(%rbp)
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x16c7d0
movq -0x50(%rbp), %rax
movss (%rax), %xmm0
movq -0x58(%rbp), %rax
addss (%rax), %xmm0
movss 0x16ce0(%rip), %xmm1    # 0x18336c
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x50(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x58(%rbp), %rax
addss 0x4(%rax), %xmm0
movss 0x16cbd(%rip), %xmm1    # 0x18336c
divss %xmm1, %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x50(%rbp), %rax
movss (%rax), %xmm0
movq -0x58(%rbp), %rax
subss (%rax), %xmm0
movss 0x16c9c(%rip), %xmm1    # 0x18336c
divss %xmm1, %xmm0
movss %xmm0, -0x28(%rbp)
movq -0x50(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x58(%rbp), %rax
subss 0x4(%rax), %xmm0
movss 0x16c79(%rip), %xmm1    # 0x18336c
divss %xmm1, %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x24(%rbp), %xmm0
movq -0x48(%rbp), %rax
movss (%rax), %xmm1
movss -0x2c(%rbp), %xmm2
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq -0x48(%rbp), %rax
movss 0x4(%rax), %xmm0
movss -0x28(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movss %xmm0, (%rax,%rcx,8)
movss -0x30(%rbp), %xmm0
movq -0x48(%rbp), %rax
movss 0x4(%rax), %xmm1
movss -0x2c(%rbp), %xmm2
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq -0x48(%rbp), %rax
movss (%rax), %xmm0
movss -0x28(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movss %xmm0, 0x4(%rax,%rcx,8)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x58(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x16c668
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)