// File: /workspace/github_c_makefile_star2_O1/pavel-demin[P]ft8d-c/pffft.c
// Function: pffft_transform_internal
void pffft_transform_internal(PFFFT_Setup *setup, const float *finput, float *foutput, v4sf *scratch,
                             pffft_direction_t direction, int ordered) {
  int k, Ncvec   = setup->Ncvec;
  int nf_odd = (setup->ifac[1] & 1);

  // temporary buffer is allocated on the stack if the scratch pointer is NULL
  int stack_allocate = (scratch == 0 ? Ncvec*2 : 1);
  VLA_ARRAY_ON_STACK(v4sf, scratch_on_stack, stack_allocate);

  const v4sf *vinput = (const v4sf*)finput;
  v4sf *voutput      = (v4sf*)foutput;
  v4sf *buff[2]      = { voutput, scratch ? scratch : scratch_on_stack };
  int ib = (nf_odd ^ ordered ? 1 : 0);

  assert(VALIGNED(finput) && VALIGNED(foutput));

  //assert(finput != foutput);
  if (direction == PFFFT_FORWARD) {
    ib = !ib;
    if (setup->transform == PFFFT_REAL) {
      ib = (rfftf1_ps(Ncvec*2, vinput, buff[ib], buff[!ib],
                      setup->twiddle, &setup->ifac[0]) == buff[0] ? 0 : 1);
      pffft_real_finalize(Ncvec, buff[ib], buff[!ib], (v4sf*)setup->e);
    } else {
      v4sf *tmp = buff[ib];
      for (k=0; k < Ncvec; ++k) {
        UNINTERLEAVE2(vinput[k*2], vinput[k*2+1], tmp[k*2], tmp[k*2+1]);
      }
      ib = (cfftf1_ps(Ncvec, buff[ib], buff[!ib], buff[ib],
                      setup->twiddle, &setup->ifac[0], -1) == buff[0] ? 0 : 1);
      pffft_cplx_finalize(Ncvec, buff[ib], buff[!ib], (v4sf*)setup->e);
    }
    if (ordered) {
      pffft_zreorder(setup, (float*)buff[!ib], (float*)buff[ib], PFFFT_FORWARD);
    } else ib = !ib;
  } else {
    if (vinput == buff[ib]) {
      ib = !ib; // may happen when finput == foutput
    }
    if (ordered) {
      pffft_zreorder(setup, (float*)vinput, (float*)buff[ib], PFFFT_BACKWARD);
      vinput = buff[ib]; ib = !ib;
    }
    if (setup->transform == PFFFT_REAL) {
      pffft_real_preprocess(Ncvec, vinput, buff[ib], (v4sf*)setup->e);
      ib = (rfftb1_ps(Ncvec*2, buff[ib], buff[0], buff[1],
                      setup->twiddle, &setup->ifac[0]) == buff[0] ? 0 : 1);
    } else {
      pffft_cplx_preprocess(Ncvec, vinput, buff[ib], (v4sf*)setup->e);
      ib = (cfftf1_ps(Ncvec, buff[ib], buff[0], buff[1],
                      setup->twiddle, &setup->ifac[0], +1) == buff[0] ? 0 : 1);
      for (k=0; k < Ncvec; ++k) {
        INTERLEAVE2(buff[ib][k*2], buff[ib][k*2+1], buff[ib][k*2], buff[ib][k*2+1]);
      }
    }
  }

  if (buff[ib] != voutput) {
    /* extra copy required -- this situation should only happen when finput == foutput */
    assert(finput==foutput);
    for (k=0; k < Ncvec; ++k) {
      v4sf a = buff[ib][2*k], b = buff[ib][2*k+1];
      voutput[2*k] = a; voutput[2*k+1] = b;
    }
    ib = !ib;
  }
  assert(buff[ib] == voutput);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r13
movq %rdx, %rbx
movl 0x4(%rdi), %r14d
movl 0xc(%rdi), %eax
leal (%r14,%r14), %r11d
testq %rcx, %rcx
movl $0x1, %ecx
cmoveq %r11, %rcx
shlq $0x4, %rcx
movq %rsp, %rdx
subq %rcx, %rdx
testq %r13, %r13
cmoveq %rdx, %r13
movq %rdx, %rsp
movq %rbx, -0x40(%rbp)
movq %r13, -0x38(%rbp)
movl %ebx, %ecx
orl %esi, %ecx
testb $0xf, %cl
jne 0x34f8
movq %rdi, %r15
leaq 0x8(%rdi), %r10
andl $0x1, %eax
testl %r8d, %r8d
movq %rsi, -0x50(%rbp)
je 0x32a9
movq %r11, -0x60(%rbp)
movq %r10, -0x58(%rbp)
xorl %r12d, %r12d
cmpl %r9d, %eax
setne %r12b
cmpq %rsi, -0x40(%rbp,%r12,8)
sete %al
xorb %al, %r12b
testl %r9d, %r9d
je 0x3354
movzbl %r12b, %r12d
movq -0x40(%rbp,%r12,8), %rdx
movq %r15, %rdi
movq %rdx, -0x48(%rbp)
movl $0x1, %ecx
callq 0x2a3b
xorb $0x1, %r12b
jmp 0x3358
xorl %ecx, %ecx
cmpl %r9d, %eax
sete %cl
cmpl $0x0, 0x44(%r15)
movq -0x40(%rbp,%rcx,8), %rcx
movl %r9d, -0x48(%rbp)
je 0x3424
testl %r14d, %r14d
jle 0x32fe
movq %r14, %rdx
shlq $0x5, %rdx
xorl %r8d, %r8d
movaps (%rsi,%r8), %xmm0
movaps 0x10(%rsi,%r8), %xmm1
movaps %xmm0, %xmm2
shufps $0x88, %xmm1, %xmm2     # xmm2 = xmm2[0,2],xmm1[0,2]
shufps $0xdd, %xmm1, %xmm0     # xmm0 = xmm0[1,3],xmm1[1,3]
movaps %xmm0, 0x10(%rcx,%r8)
movaps %xmm2, (%rcx,%r8)
addq $0x20, %r8
cmpq %r8, %rdx
jne 0x32d4
xorl %edx, %edx
cmpl %r9d, %eax
setne %dl
movq -0x40(%rbp,%rdx,8), %rdx
movq 0x58(%r15), %r8
subq $0x8, %rsp
movl %r14d, %edi
movq %rcx, %rsi
movq %r10, %r9
pushq $-0x1
callq 0x1784
addq $0x10, %rsp
xorl %ecx, %ecx
xorl %r12d, %r12d
cmpq %rbx, %rax
sete %cl
setne %r12b
movq -0x40(%rbp,%r12,8), %rsi
movq -0x40(%rbp,%rcx,8), %rdx
movq %r15, %r13
movq 0x50(%r15), %rcx
movl %r14d, %edi
callq 0x2e6f
jmp 0x346e
movq %rsi, -0x48(%rbp)
cmpl $0x0, 0x44(%r15)
movzbl %r12b, %eax
movq -0x40(%rbp,%rax,8), %r12
movq 0x50(%r15), %rcx
movl %r14d, %edi
je 0x33f5
movq -0x48(%rbp), %rsi
movq %r12, %rdx
callq 0x3033
movq 0x58(%r15), %r8
subq $0x8, %rsp
movl %r14d, %edi
movq %r12, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq -0x58(%rbp), %r9
pushq $0x1
callq 0x1784
addq $0x10, %rsp
cmpq %rbx, %rax
setne %r12b
testl %r14d, %r14d
jle 0x3499
xorl %ecx, %ecx
cmpq %rbx, %rax
setne %cl
movq -0x40(%rbp,%rcx,8), %rax
movq %r14, %rcx
shlq $0x5, %rcx
xorl %edx, %edx
movq -0x50(%rbp), %rsi
movaps (%rax,%rdx), %xmm0
movaps 0x10(%rax,%rdx), %xmm1
movaps %xmm0, %xmm2
unpcklps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
unpckhps %xmm1, %xmm0            # xmm0 = xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movaps %xmm0, 0x10(%rax,%rdx)
movaps %xmm2, (%rax,%rdx)
addq $0x20, %rdx
cmpq %rdx, %rcx
jne 0x33cc
jmp 0x349d
movq -0x48(%rbp), %rsi
movq %r12, %rdx
callq 0x45ad
movq 0x58(%r15), %r8
movq -0x60(%rbp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq -0x58(%rbp), %r9
callq 0x49d8
cmpq %rbx, %rax
setne %r12b
jmp 0x3499
xorl %edx, %edx
cmpl %r9d, %eax
setne %dl
movq -0x40(%rbp,%rdx,8), %rax
movq 0x58(%r15), %r8
movl %r11d, %edi
movq %rcx, %rdx
movq %rax, %rcx
movq %r10, %r9
callq 0x3555
xorl %ecx, %ecx
xorl %r12d, %r12d
cmpq %rbx, %rax
sete %cl
setne %r12b
movq -0x40(%rbp,%r12,8), %rsi
movq -0x40(%rbp,%rcx,8), %rdx
movq %r15, %r13
movq 0x50(%r15), %rcx
movl %r14d, %edi
callq 0x4175
movl %r12d, %eax
xorb $0x1, %al
cmpl $0x0, -0x48(%rbp)
je 0x3496
movzbl %al, %eax
movq -0x40(%rbp,%rax,8), %rsi
movzbl %r12b, %eax
movq -0x40(%rbp,%rax,8), %rdx
movq %r13, %rdi
xorl %ecx, %ecx
callq 0x2a3b
jmp 0x3499
movl %eax, %r12d
movq -0x50(%rbp), %rsi
movzbl %r12b, %eax
movq -0x40(%rbp,%rax,8), %rax
cmpq %rbx, %rax
je 0x34de
cmpq %rbx, %rsi
jne 0x3536
testl %r14d, %r14d
jle 0x34da
shlq $0x5, %r14
xorl %ecx, %ecx
movaps (%rax,%rcx), %xmm0
movaps 0x10(%rax,%rcx), %xmm1
movaps %xmm0, (%rbx,%rcx)
movaps %xmm1, 0x10(%rbx,%rcx)
addq $0x20, %rcx
cmpq %rcx, %r14
jne 0x34bf
xorb $0x1, %r12b
movzbl %r12b, %eax
cmpq %rbx, -0x40(%rbp,%rax,8)
jne 0x3517
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x504b(%rip), %rdi      # 0x854a
leaq 0x4d23(%rip), %rsi      # 0x8229
leaq 0x5063(%rip), %rcx      # 0x8570
movl $0x657, %edx            # imm = 0x657
callq 0x1090
leaq 0x50c7(%rip), %rdi      # 0x85e5
leaq 0x4d04(%rip), %rsi      # 0x8229
leaq 0x5044(%rip), %rcx      # 0x8570
movl $0x68b, %edx            # imm = 0x68B
callq 0x1090
leaq 0x5098(%rip), %rdi      # 0x85d5
leaq 0x4ce5(%rip), %rsi      # 0x8229
leaq 0x5025(%rip), %rcx      # 0x8570
movl $0x684, %edx            # imm = 0x684
callq 0x1090