// File: Sleepwalking[P]world-octave/fft.cpp
// Function: (anonymous namespace)::ForwardFFT(fft_plan)
void ForwardFFT(fft_plan p) {
  if (p.c_in == NULL) {  // r2c
    for (int i = 0; i < p.n; ++i) p.input[i] = p.in[i];
    rdft(p.n, 1, p.input, p.ip, p.w);
    p.c_out[0][0] = p.input[0];
    p.c_out[0][1] = 0.0;
    for (int i = 1; i < p.n / 2; ++i) {
      p.c_out[i][0] = p.input[i * 2];
      p.c_out[i][1] = p.input[i * 2 + 1];
    }
    p.c_out[p.n / 2][0] = p.input[1];
    p.c_out[p.n / 2][1] = 0.0;
  } else {  // c2c
    for (int i = 0; i < p.n; ++i) {
      p.input[i * 2] = p.c_in[i][0];
      p.input[i * 2 + 1] = p.c_in[i][1];
    }
    cdft(p.n * 2, 1, p.input, p.ip, p.w);
    for (int i = 0; i < p.n; ++i) {
      p.c_out[i][0]   = p.input[i * 2];
      p.c_out[i][1]   = p.input[i * 2 + 1];
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, 0x10(%rax)
jne 0xd72f
movl $0x0, -0x4(%rbp)
movq -0x18(%rbp), %rcx
movl -0x4(%rbp), %eax
cmpl (%rcx), %eax
jge 0xd616
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
movslq -0x4(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x30(%rax), %rax
movslq -0x4(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xd5e2
movq -0x18(%rbp), %rax
movl (%rax), %edi
movq 0x30(%rax), %rdx
movq 0x38(%rax), %rcx
movq 0x40(%rax), %r8
movl $0x1, %esi
callq 0xddd0
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rcx
movsd (%rcx), %xmm0
movq 0x20(%rax), %rcx
movsd %xmm0, (%rcx)
movq 0x20(%rax), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
movl $0x1, -0x8(%rbp)
movq -0x18(%rbp), %rax
movl -0x8(%rbp), %ecx
movl %ecx, -0x1c(%rbp)
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x1c(%rbp), %eax
cmpl %ecx, %eax
jge 0xd6d1
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rcx
movl -0x8(%rbp), %edx
shll %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x20(%rax), %rcx
movslq -0x8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd %xmm0, (%rcx)
movq 0x30(%rax), %rcx
movl -0x8(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x20(%rax), %rax
movslq -0x8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0xd659
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rcx
movsd 0x8(%rcx), %xmm0
movq 0x20(%rax), %rcx
movl (%rax), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0x18(%rbp), %rax
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd %xmm0, (%rcx)
movq 0x20(%rax), %rcx
movq %rcx, -0x28(%rbp)
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
jmp 0xd829
movl $0x0, -0xc(%rbp)
movq -0x18(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl (%rcx), %eax
jge 0xd79c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0xc(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd (%rcx), %xmm0
movq 0x30(%rax), %rcx
movl -0xc(%rbp), %edx
shll %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movq 0x10(%rax), %rcx
movslq -0xc(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd 0x8(%rcx), %xmm0
movq 0x30(%rax), %rax
movl -0xc(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xd736
movq -0x18(%rbp), %rax
movl (%rax), %edi
shll %edi
movq 0x30(%rax), %rdx
movq 0x38(%rax), %rcx
movq 0x40(%rax), %r8
movl $0x1, %esi
callq 0xdb10
movl $0x0, -0x10(%rbp)
movq -0x18(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl (%rcx), %eax
jge 0xd827
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rcx
movl -0x10(%rbp), %edx
shll %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x20(%rax), %rcx
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd %xmm0, (%rcx)
movq 0x30(%rax), %rcx
movl -0x10(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x20(%rax), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xd7c1
jmp 0xd829
addq $0x30, %rsp
popq %rbp
retq
nop