// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
leal -0x1(%r15), %r12d
movl %r12d, %esi
callq 0x107151
movl $0x1, %eax
movl %r12d, %ecx
shll %cl, %eax
movl %eax, -0x2c(%rbp)
cmpl %r15d, 0x34fbae(%rip)   # 0x457038
je 0x107508
movl %r15d, 0x34fba5(%rip)   # 0x457038
cmpl $0x2, -0x2c(%rbp)
jl 0x107508
movl -0x2c(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x4370(%rip), %xmm1     # 0x10b818
divsd %xmm0, %xmm1
movsd %xmm1, -0x38(%rbp)
movl %eax, %r15d
movl $0x1, %r12d
leaq 0x2388ef(%rip), %r13    # 0x33fdb0
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x9710
cvtsd2ss %xmm0, %xmm0
movq (%r13), %rax
movss %xmm0, -0x8(%rax,%r12,8)
movsd -0x40(%rbp), %xmm0
callq 0x9080
cvtsd2ss %xmm0, %xmm0
movq (%r13), %rax
movss %xmm0, -0x4(%rax,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0x1074c1
movss (%r14), %xmm0
addss 0x4(%r14), %xmm0
movss %xmm0, (%rbx)
movl $0x0, 0x4(%rbx)
movl -0x2c(%rbp), %eax
cmpl $0x2, %eax
jl 0x1075cc
movl %eax, %eax
leaq 0x23887d(%rip), %rcx    # 0x33fdb0
movq (%rcx), %rcx
decq %rax
movl $0xc, %edx
movss 0x5a9e(%rip), %xmm0     # 0x10cfe4
movss -0x4(%r14,%rdx), %xmm1
movss (%r14,%rdx), %xmm2
movss (%r14,%rax,8), %xmm3
movss 0x4(%r14,%rax,8), %xmm4
movaps %xmm1, %xmm5
addss %xmm3, %xmm5
mulss %xmm0, %xmm5
movaps %xmm2, %xmm6
addss %xmm4, %xmm6
mulss %xmm0, %xmm6
subss %xmm3, %xmm1
mulss %xmm0, %xmm1
subss %xmm4, %xmm2
mulss %xmm0, %xmm2
movss -0xc(%rcx,%rdx), %xmm3
mulss %xmm6, %xmm3
addss %xmm5, %xmm3
movss -0x8(%rcx,%rdx), %xmm4
mulss %xmm4, %xmm6
mulss %xmm1, %xmm4
subss %xmm4, %xmm3
movss %xmm3, -0x4(%rbx,%rdx)
subss %xmm6, %xmm2
mulss -0xc(%rcx,%rdx), %xmm1
subss %xmm1, %xmm2
movss %xmm2, (%rbx,%rdx)
addq $0x8, %rdx
decq %rax
jne 0x107546
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq