// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdx, %r14
movq %rsi, (%rsp)
movq %rdi, %r15
cmpb $0x0, %fs:-0x18020
je 0x6392
xorl %eax, %eax
vpbroadcastd 0x2144(%rip), %zmm0 # 0x8174
vpaddd (%r15,%rax,4), %zmm0, %zmm1
vmovdqu64 %zmm1, 0x4008(%rsp,%rax,4)
vpaddd 0x1000(%r15,%rax,4), %zmm0, %zmm1
vmovdqu64 %zmm1, 0x6008(%rsp,%rax,4)
addq $0x10, %rax
cmpq $0x400, %rax            # imm = 0x400
jne 0x6030
movl $0x1, %eax
leaq 0x7008(%rsp), %rcx
movl $0x3ff, %edx            # imm = 0x3FF
movl $0xfffffe00, %esi       # imm = 0xFFFFFE00
leal (%rax,%rax), %edi
leal (%rdi,%rdi,4), %r8d
movl $0x16, %edi
subl %r8d, %edi
xorl %r8d, %r8d
shrxl %edi, 0x4008(%rsp,%r8,4), %r9d
andl %edx, %r9d
addl %esi, %r9d
movl %r9d, -0x2000(%rcx,%r8,4)
shrxl %edi, 0x6008(%rsp,%r8,4), %r9d
andl %edx, %r9d
addl %esi, %r9d
movl %r9d, (%rcx,%r8,4)
incq %r8
cmpq $0x400, %r8             # imm = 0x400
jne 0x608a
addq $-0x1000, %rcx          # imm = 0xF000
subq $0x1, %rax
jae 0x6078
movq %fs:0x0, %rax
leaq -0x20020(%rax), %r15
leaq 0x4008(%rsp), %rbp
xorl %ebx, %ebx
leaq 0x8(%rsp), %r12
movq %rbx, %rax
shlq $0xd, %rax
xorl %ecx, %ecx
vcvtdq2pd (%rbp,%rcx,4), %zmm0
vmovdqu64 %zmm0, 0x8(%rsp,%rcx,8)
addq $0x8, %rcx
cmpq $0x400, %rcx            # imm = 0x400
jne 0x60f7
leaq 0x8008(%rsp,%rax), %r13
movq %r15, %rdi
movq %r12, %rsi
vzeroupper
callq 0x4e6e
movl $0x2000, %edx           # imm = 0x2000
movq %r13, %rdi
movq %r12, %rsi
callq 0x2140
incq %rbx
addq $0x1000, %rbp           # imm = 0x1000
cmpq $0x4, %rbx
jne 0x60ee
movl $0x200, %eax            # imm = 0x200
vmovupd 0x8008(%rsp,%rax,8), %zmm0
vmovupd (%r14,%rax,8), %zmm1
vmulpd %zmm0, %zmm1, %zmm2
vmovupd 0x7008(%rsp,%rax,8), %zmm3
vmulpd %zmm1, %zmm3, %zmm1
vmovupd -0x1000(%r14,%rax,8), %zmm4
vfmsub231pd %zmm3, %zmm4, %zmm2 # zmm2 = (zmm4 * zmm3) - zmm2
vmovupd %zmm2, -0xff8(%rsp,%rax,8)
vfmadd231pd %zmm0, %zmm4, %zmm1 # zmm1 = (zmm4 * zmm0) + zmm1
vmovupd %zmm1, 0x8(%rsp,%rax,8)
addq $0x8, %rax
cmpq $0x400, %rax            # imm = 0x400
jne 0x6152
movl $0x200, %eax            # imm = 0x200
vmovupd 0x8008(%rsp,%rax,8), %zmm0
vmovupd 0x2000(%r14,%rax,8), %zmm1
vmulpd %zmm0, %zmm1, %zmm2
vmovupd 0x7008(%rsp,%rax,8), %zmm3
vmulpd %zmm1, %zmm3, %zmm1
vmovupd 0x1000(%r14,%rax,8), %zmm4
vfmsub231pd %zmm3, %zmm4, %zmm2 # zmm2 = (zmm4 * zmm3) - zmm2
vmovupd %zmm2, 0x1008(%rsp,%rax,8)
vfmadd231pd %zmm0, %zmm4, %zmm1 # zmm1 = (zmm4 * zmm0) + zmm1
vmovupd %zmm1, 0x2008(%rsp,%rax,8)
addq $0x8, %rax
cmpq $0x400, %rax            # imm = 0x400
jne 0x61b6
leaq 0x5000(%r14), %rax
leaq 0xb008(%rsp), %rcx
addq $0x7000, %r14           # imm = 0x7000
movl $0x1, %edx
movl $0x4000, %esi           # imm = 0x4000
xorl %edi, %edi
vmovupd (%rcx,%rdi,8), %zmm0
vmovupd (%rax,%rdi,8), %zmm1
vmovupd 0x8(%rsp,%rdi,8), %zmm2
vfmsub231pd %zmm0, %zmm1, %zmm2 # zmm2 = (zmm1 * zmm0) - zmm2
vmovupd %zmm2, 0x8(%rsp,%rdi,8)
vmovupd -0x1000(%rcx,%rdi,8), %zmm3
vmovupd -0x1000(%rax,%rdi,8), %zmm4
vfmsub231pd %zmm3, %zmm4, %zmm2 # zmm2 = (zmm4 * zmm3) - zmm2
vmovupd %zmm2, 0x8(%rsp,%rdi,8)
vfmadd213pd 0x1008(%rsp,%rdi,8), %zmm3, %zmm1 # zmm1 = (zmm3 * zmm1) + mem
vfmadd231pd %zmm0, %zmm4, %zmm1 # zmm1 = (zmm4 * zmm0) + zmm1
vmovupd %zmm1, 0x1008(%rsp,%rdi,8)
addq $0x8, %rdi
cmpq $0x200, %rdi            # imm = 0x200
jne 0x623b
xorl %edi, %edi
vmovupd (%rcx,%rdi,8), %zmm0
vmovupd (%r14,%rdi,8), %zmm1
vmovupd 0x2008(%rsp,%rdi,8), %zmm2
vfmsub231pd %zmm0, %zmm1, %zmm2 # zmm2 = (zmm1 * zmm0) - zmm2
vmovupd %zmm2, 0x2008(%rsp,%rdi,8)
vmovupd -0x1000(%rcx,%rdi,8), %zmm3
vmovupd -0x1000(%r14,%rdi,8), %zmm4
vfmsub231pd %zmm3, %zmm4, %zmm2 # zmm2 = (zmm4 * zmm3) - zmm2
vmovupd %zmm2, 0x2008(%rsp,%rdi,8)
vfmadd213pd 0x3008(%rsp,%rdi,8), %zmm3, %zmm1 # zmm1 = (zmm3 * zmm1) + mem
vfmadd231pd %zmm0, %zmm4, %zmm1 # zmm1 = (zmm4 * zmm0) + zmm1
vmovupd %zmm1, 0x3008(%rsp,%rdi,8)
addq $0x8, %rdi
cmpq $0x200, %rdi            # imm = 0x200
jne 0x62b1
incq %rdx
addq %rsi, %rax
addq $0x2000, %rcx           # imm = 0x2000
addq %rsi, %r14
cmpq $0x4, %rdx
jne 0x6239
movq %fs:0x0, %rax
leaq -0x20020(%rax), %r14
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
vzeroupper
callq 0x4be2
addq $0x1000, %rbx           # imm = 0x1000
leaq 0x2008(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4be2
addq $0x10008, %rsp          # imm = 0x10008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2290
jmp 0x6024