// File: /workspace/github_cpp_makefile_star2_O2/ushitora-anqou[P]aqtfhe2/./aqtfhe2.hpp
// Function: aqtfhe2::trlwe_lvl1<aqtfhe2::params::CGGI16>::trgswfft_external_product(aqtfhe2::trlwe_lvl1<aqtfhe2::params::CGGI16>&, aqtfhe2::trgswfft_lvl1<aqtfhe2::params::CGGI16> const&) const
void trlwe_lvl1<P>::trgswfft_external_product(
    trlwe_lvl1<P> &out, const trgswfft_lvl1<P> &trgswfft) const
{
    constexpr uint32_t Bgbit = P::Bgbit(), N = P::N(), l = P::l(), Bg = P::Bg();
    thread_local detail::fft_processor<N> fftproc;

    ///// offset gen/////
    uint32_t offset = 0;
    for (size_t i = 1; i <= l; i++)
        offset += Bg / 2 * (1U << (32 - i * Bgbit));

    ///// decomposition /////
    constexpr uint32_t mask = static_cast<uint32_t>((1UL << Bgbit) - 1);
    constexpr uint32_t halfBg = (1UL << (Bgbit - 1));
    detail::nd_array<uint32_t, 2 * l, N> decvec;
    for (size_t i = 0; i < N; i++) {
        decvec(0, i) = poly0_[i] + offset;
        decvec(l, i) = poly1_[i] + offset;
    }
    for (int i = l - 1; i >= 0; i--) {
        for (size_t j = 0; j < N; j++) {
            decvec(i, j) =
                ((decvec(0, j) >> (32 - (i + 1) * Bgbit)) & mask) - halfBg;
            decvec(i + l, j) =
                ((decvec(l, j) >> (32 - (i + 1) * Bgbit)) & mask) - halfBg;
        }
    }

    ///// ifft /////
    detail::nd_array<double, 2 * P::l(), P::N()> decvecfft;
    for (size_t i = 0; i < 2 * l; i++)
        fftproc.twist_ifft_lvl1(decvecfft.slice(i), decvec.slice(i));

    ///// mul and fma in fd /////
    detail::nd_array<double, P::N()> poly0 =
        detail::mul_in_fd<P::N()>(decvecfft.slice(0), trgswfft.slice(0, 0));
    detail::nd_array<double, P::N()> poly1 =
        detail::mul_in_fd<P::N()>(decvecfft.slice(0), trgswfft.slice(0, 1));
    for (size_t i = 1; i < 2 * P::l(); i++) {
        detail::fma_in_fd(poly0.slice(), decvecfft.cslice(i),
                          trgswfft.slice(i, 0));
        detail::fma_in_fd(poly1.slice(), decvecfft.cslice(i),
                          trgswfft.slice(i, 1));
    }

    ///// twsit fft /////
    fftproc.twist_fft_lvl1(/* out */ out.poly0_.slice(), poly0.slice());
    fftproc.twist_fft_lvl1(/* out */ out.poly1_.slice(), poly1.slice());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10008, %rsp          # imm = 0x10008
cmpb $0x0, %fs:-0x18020
movq %rdx, %r14
movq %rdi, %r15
movq %rsi, (%rsp)
je 0x5d63
movl $0x80200000, %ecx       # imm = 0x80200000
xorl %eax, %eax
cmpq $0x400, %rax            # imm = 0x400
je 0x5beb
movl (%r15,%rax,4), %edx
addl %ecx, %edx
movl %edx, 0x8(%rsp,%rax,4)
movl 0x1000(%r15,%rax,4), %edx
addl %ecx, %edx
movl %edx, 0x2008(%rsp,%rax,4)
incq %rax
jmp 0x5bc3
pushq $0x1
popq %rax
leaq 0x3008(%rsp), %rcx
movl $0x3ff, %edx            # imm = 0x3FF
movl $0xfffffe00, %esi       # imm = 0xFFFFFE00
testl %eax, %eax
js 0x5c58
imull $-0xa, %eax, %r8d
movl %eax, %edi
shlq $0xc, %rdi
xorl %r9d, %r9d
leaq 0x8(%rsp,%rdi), %rdi
addl $0x16, %r8d
cmpq $0x400, %r9             # imm = 0x400
je 0x5c4d
shrxl %r8d, 0x8(%rsp,%r9,4), %r10d
andl %edx, %r10d
addl %esi, %r10d
movl %r10d, (%rdi,%r9,4)
shrxl %r8d, 0x2008(%rsp,%r9,4), %r10d
andl %edx, %r10d
addl %esi, %r10d
movl %r10d, (%rcx,%r9,4)
incq %r9
jmp 0x5c1a
decl %eax
addq $-0x1000, %rcx          # imm = 0xF000
jmp 0x5c00
movq %fs:0x0, %rax
leaq 0x8008(%rsp), %r12
xorl %ebx, %ebx
leaq -0x20020(%rax), %r15
cmpq $0x4000, %rbx           # imm = 0x4000
je 0x5c9b
leaq 0x8(%rsp,%rbx), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x40d2
addq $0x1000, %rbx           # imm = 0x1000
addq $0x2000, %r12           # imm = 0x2000
jmp 0x5c72
leaq 0x6008(%rsp), %r12
leaq 0x8008(%rsp), %rbp
movq %r14, %rdx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x43ca
leaq 0x4008(%rsp), %r13
leaq 0x2000(%r14), %rdx
movq %rbp, %rsi
movq %r13, %rdi
callq 0x43ca
addq $0x6000, %r14           # imm = 0x6000
movl $0x2000, %ebx           # imm = 0x2000
cmpq $0x8000, %rbx           # imm = 0x8000
je 0x5d20
leaq 0x8008(%rsp,%rbx), %rbp
leaq -0x2000(%r14), %rdx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5edd
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x5edd
addq $0x2000, %rbx           # imm = 0x2000
addq $0x4000, %r14           # imm = 0x4000
jmp 0x5cdf
movq (%rsp), %rbx
leaq 0x6008(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4428
addq $0x1000, %rbx           # imm = 0x1000
leaq 0x4008(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4428
addq $0x10008, %rsp          # imm = 0x10008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %fs:0x0, %rax
leaq -0x20020(%rax), %rdi
callq 0x3e90
movb $0x1, %fs:-0x18020
jmp 0x5bbc