// File: markondej[P]phase_correl/phase_correl.cpp
// Function: PhaseCorrelation::Dit2FFT(std::vector<std::complex<double>, std::allocator<std::complex<double>>> const&, std::vector<std::complex<double>, std::allocator<std::complex<double>>>&, bool)
static void Dit2FFT(const std::vector<std::complex<double>> &input, std::vector<std::complex<double>> &output, bool inverse = false) {
        std::size_t stride = 1, size = input.size();
        auto offset = GenInputOrder(size >> 1);
        output.resize(size);

        while (size > 2) {
            stride <<= 1;
            size >>= 1;
        }

        for (std::size_t i = 0; i < stride; i++) {
            Radix2FFT(&input[offset[i]], &output[i * 2], stride);
        }

        while (stride > 1) {
            stride >>= 1;
            size <<= 1;
            for (std::size_t i = 0; i < stride; i++) {
                Sum2FFT(&output[i * size], &output[i * size], size >> 1, inverse);
            }
        }

        if (inverse) {
            for (std::size_t i = 0; i < size; i++) {
                output[i] /= static_cast<double>(size);
            }
        }
    }

// Assembly:
subq $0x88, %rsp
movb %dl, %al
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
andb $0x1, %al
movb %al, 0x77(%rsp)
movq $0x1, 0x68(%rsp)
movq 0x80(%rsp), %rdi
callq 0x2240
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rsi
shrq %rsi
leaq 0x48(%rsp), %rdi
callq 0x33b0
movq 0x78(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x1d10
jmp 0x31aa
jmp 0x31ac
cmpq $0x2, 0x60(%rsp)
jbe 0x31ed
movq 0x68(%rsp), %rax
shlq %rax
movq %rax, 0x68(%rsp)
movq 0x60(%rsp), %rax
shrq %rax
movq %rax, 0x60(%rsp)
jmp 0x31ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x3be0
jmp 0x339d
movq $0x0, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpq 0x68(%rsp), %rax
jae 0x3268
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x3690
movq 0x10(%rsp), %rdi
movq (%rax), %rsi
callq 0x3670
movq %rax, 0x18(%rsp)
movq 0x78(%rsp), %rdi
movq 0x30(%rsp), %rsi
addq %rsi, %rsi
callq 0x1df0
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movq 0x68(%rsp), %rdx
callq 0x3530
jmp 0x3256
jmp 0x3258
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x31f6
jmp 0x326a
cmpq $0x1, 0x68(%rsp)
jbe 0x3310
movq 0x68(%rsp), %rax
shrq %rax
movq %rax, 0x68(%rsp)
movq 0x60(%rsp), %rax
shlq %rax
movq %rax, 0x60(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
cmpq 0x68(%rsp), %rax
jae 0x330b
movq 0x78(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x60(%rsp), %rax
imulq %rax, %rsi
callq 0x1df0
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x60(%rsp), %rax
imulq %rax, %rsi
callq 0x1df0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq 0x60(%rsp), %rdx
shrq %rdx
movzbl 0x77(%rsp), %ecx
andl $0x1, %ecx
callq 0x36b0
jmp 0x32f9
jmp 0x32fb
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x3299
jmp 0x326a
testb $0x1, 0x77(%rsp)
je 0x338b
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0x3389
movaps 0x1d0d(%rip), %xmm1     # 0x5040
movq 0x60(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1d0b(%rip), %xmm1     # 0x5050
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movq 0x78(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x1df0
movsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x3ba0
jmp 0x3377
jmp 0x3379
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x3320
jmp 0x338b
leaq 0x48(%rsp), %rdi
callq 0x3be0
addq $0x88, %rsp
retq
movq 0x40(%rsp), %rdi
callq 0x11c0
nopw (%rax,%rax)