// File: ushitora-anqou[P]aqtfhe2/./aqtfhe2.hpp
// Function: aqtfhe2::detail::fft_processor<1024ul>::fft(aqtfhe2::detail::array_slice<double, 1024ul>)
void fft(array_slice<double, N> out)
    {
        constexpr size_t n = N * 2, ns4 = n / 4;
        double tmp0[4], tmp1[4], tmp2[4], tmp3[4];
        auto itre = out.begin(), itim = out.begin() + ns4;

        // size 2
        for (size_t block = 0; block < ns4; block += 4) {
            auto re = itre + block;
            auto im = itim + block;

            tmp0[0] = re[0] + re[1];
            tmp0[1] = re[0] - re[1];
            tmp0[2] = re[2] + re[3];
            tmp0[3] = re[2] - re[3];
            copy4(re, tmp0);

            tmp1[0] = im[0] + im[1];
            tmp1[1] = im[0] - im[1];
            tmp1[2] = im[2] + im[3];
            tmp1[3] = im[2] - im[3];
            copy4(im, tmp1);
        }

        // size 4
        for (size_t block = 0; block < ns4; block += 4) {
            auto re = itre + block;
            auto im = itim + block;

            tmp0[0] = re[0] + re[2];
            tmp0[1] = re[1] + im[3];
            tmp0[2] = re[0] - re[2];
            tmp0[3] = re[1] - im[3];

            tmp1[0] = im[0] + im[2];
            tmp1[1] = im[1] - re[3];
            tmp1[2] = im[0] - im[2];
            tmp1[3] = im[1] + re[3];

            copy4(re, tmp0);
            copy4(im, tmp1);
        }

        // general loop
        auto cur_tt = tables_direct_.cbegin();
        for (size_t halfnn = 4; halfnn < ns4; halfnn *= 2) {
            size_t nn = 2 * halfnn;
            for (size_t block = 0; block < ns4; block += nn) {
                for (size_t off = 0; off < halfnn; off += 4) {
                    auto re0 = itre + block + off;
                    auto im0 = itim + block + off;
                    auto re1 = itre + block + halfnn + off;
                    auto im1 = itim + block + halfnn + off;
                    auto tcs = cur_tt + 2 * off;
                    auto tsn = tcs + 4;

                    dotp4(tmp0, re1, tcs);   // re*cos
                    dotp4(tmp1, re1, tsn);   // re*sin
                    dotp4(tmp2, im1, tcs);   // im*cos
                    dotp4(tmp3, im1, tsn);   // im*sin
                    sub4(tmp0, tmp0, tmp3);  // re2
                    add4(tmp1, tmp1, tmp2);  // im2
                    add4(tmp2, re0, tmp0);   // re + re
                    add4(tmp3, im0, tmp1);   // im + im
                    sub4(tmp0, re0, tmp0);   // re - re
                    sub4(tmp1, im0, tmp1);   // im - im
                    copy4(re0, tmp2);
                    copy4(im0, tmp3);
                    copy4(re1, tmp0);
                    copy4(im1, tmp1);
                }
            }
            cur_tt += nn;
        }

        // multiply by omb^j
        for (size_t j = 0; j < ns4; j += 4) {
            auto r0 = cur_tt + 2 * j;
            auto r1 = r0 + 4;
            //(re*cos-im*sin) + i (im*cos+re*sin)
            auto d0 = itre + j;
            auto d1 = itim + j;

            dotp4(tmp0, d0, r0);  // re*cos
            dotp4(tmp1, d1, r0);  // im*cos
            dotp4(tmp2, d0, r1);  // re*sin
            dotp4(tmp3, d1, r1);  // im*sin
            sub4(d0, tmp0, tmp3);
            add4(d1, tmp1, tmp2);
        }
    }

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rsi, 0x170(%rsp)
movq %rdi, 0x168(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x800, 0x160(%rsp) # imm = 0x800
movq $0x200, 0x158(%rsp) # imm = 0x200
leaq 0x170(%rsp), %rdi
callq 0x9900
movq %rax, 0xc8(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x9900
addq $0x1000, %rax           # imm = 0x1000
movq %rax, 0xc0(%rsp)
movq $0x0, 0xb8(%rsp)
cmpq $0x200, 0xb8(%rsp) # imm = 0x200
jae 0x92bf
movq 0xc8(%rsp), %rax
movq 0xb8(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0xb0(%rsp)
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0xb0(%rsp), %rax
vaddsd 0x8(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x130(%rsp)
movq 0xb0(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0xb0(%rsp), %rax
vsubsd 0x8(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x138(%rsp)
movq 0xb0(%rsp), %rax
vmovsd 0x10(%rax), %xmm0
movq 0xb0(%rsp), %rax
vaddsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x140(%rsp)
movq 0xb0(%rsp), %rax
vmovsd 0x10(%rax), %xmm0
movq 0xb0(%rsp), %rax
vsubsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x148(%rsp)
movq 0xb0(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x9910
movq 0xa8(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0xa8(%rsp), %rax
vaddsd 0x8(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x110(%rsp)
movq 0xa8(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0xa8(%rsp), %rax
vsubsd 0x8(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x118(%rsp)
movq 0xa8(%rsp), %rax
vmovsd 0x10(%rax), %xmm0
movq 0xa8(%rsp), %rax
vaddsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x120(%rsp)
movq 0xa8(%rsp), %rax
vmovsd 0x10(%rax), %xmm0
movq 0xa8(%rsp), %rax
vsubsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x128(%rsp)
movq 0xa8(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x9910
movq 0xb8(%rsp), %rax
addq $0x4, %rax
movq %rax, 0xb8(%rsp)
jmp 0x9118
movq $0x0, 0xa0(%rsp)
cmpq $0x200, 0xa0(%rsp) # imm = 0x200
jae 0x9472
movq 0xc8(%rsp), %rax
movq 0xa0(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x98(%rsp)
movq 0xc0(%rsp), %rax
movq 0xa0(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0x98(%rsp), %rax
vaddsd 0x10(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x130(%rsp)
movq 0x98(%rsp), %rax
vmovsd 0x8(%rax), %xmm0
movq 0x90(%rsp), %rax
vaddsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x138(%rsp)
movq 0x98(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0x98(%rsp), %rax
vsubsd 0x10(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x140(%rsp)
movq 0x98(%rsp), %rax
vmovsd 0x8(%rax), %xmm0
movq 0x90(%rsp), %rax
vsubsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x148(%rsp)
movq 0x90(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0x90(%rsp), %rax
vaddsd 0x10(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x110(%rsp)
movq 0x90(%rsp), %rax
vmovsd 0x8(%rax), %xmm0
movq 0x98(%rsp), %rax
vsubsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x118(%rsp)
movq 0x90(%rsp), %rax
vmovsd (%rax), %xmm0
movq 0x90(%rsp), %rax
vsubsd 0x10(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x120(%rsp)
movq 0x90(%rsp), %rax
vmovsd 0x8(%rax), %xmm0
movq 0x98(%rsp), %rax
vaddsd 0x18(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x128(%rsp)
movq 0x98(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x9910
movq 0x90(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x9910
movq 0xa0(%rsp), %rax
addq $0x4, %rax
movq %rax, 0xa0(%rsp)
jmp 0x92cb
movq 0x8(%rsp), %rdi
callq 0x9960
movq %rax, 0x88(%rsp)
movq $0x4, 0x80(%rsp)
cmpq $0x200, 0x80(%rsp) # imm = 0x200
jae 0x9762
movq 0x80(%rsp), %rax
shlq %rax
movq %rax, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
cmpq $0x200, 0x70(%rsp)      # imm = 0x200
jae 0x9731
movq $0x0, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x80(%rsp), %rax
jae 0x971b
movq 0xc8(%rsp), %rax
movq 0x70(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq 0x68(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x60(%rsp)
movq 0xc0(%rsp), %rax
movq 0x70(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq 0x68(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x58(%rsp)
movq 0xc8(%rsp), %rax
movq 0x70(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq 0x80(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq 0x68(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
movq 0xc0(%rsp), %rax
movq 0x70(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq 0x80(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq 0x68(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x88(%rsp), %rax
movq 0x68(%rsp), %rcx
shlq %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x38(%rsp)
leaq 0x130(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x9970
leaq 0x110(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x38(%rsp), %rdx
callq 0x9970
leaq 0xf0(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x9970
leaq 0xd0(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x38(%rsp), %rdx
callq 0x9970
leaq 0x130(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0x99d0
leaq 0x110(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x9a30
leaq 0xf0(%rsp), %rdi
movq 0x60(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x9a30
leaq 0xd0(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x9a30
leaq 0x130(%rsp), %rdi
movq 0x60(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x99d0
leaq 0x110(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x99d0
movq 0x60(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x9910
movq 0x58(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x9910
movq 0x50(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x9910
movq 0x48(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x9910
movq 0x68(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x68(%rsp)
jmp 0x94d3
jmp 0x971d
movq 0x78(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x94bb
movq 0x78(%rsp), %rax
shlq $0x3, %rax
addq 0x88(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x80(%rsp), %rax
shlq %rax
movq %rax, 0x80(%rsp)
jmp 0x9490
movq $0x0, 0x30(%rsp)
cmpq $0x200, 0x30(%rsp)      # imm = 0x200
jae 0x9879
movq 0x88(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x20(%rsp)
movq 0xc8(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0xc0(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
leaq 0x130(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x9970
leaq 0x110(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x9970
leaq 0xf0(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x9970
leaq 0xd0(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x9970
movq 0x18(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0x99d0
movq 0x10(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x9a30
movq 0x30(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x30(%rsp)
jmp 0x976b
addq $0x178, %rsp            # imm = 0x178
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)