// File: /workspace/github_cpp_makefile_star2_O2/asd00012334[P]Abstract-Algebra-2018/main.cpp
// Function: DivisionSpecialized<prime::Zp, prime::ZpElement, true>::operator%(Polynomial<prime::Zp, prime::ZpElement>) const
Polynomial<ring,ringElement> operator%(Polynomial<ring,ringElement> p2)const{
        Polynomial<ring,ringElement> out;
        auto This = static_cast<Polynomial<ring,ringElement>const*>(this);
        out.canonicalType.scalar = This->canonicalType.scalar;
        out.coef = This->coef;

        /// Reduce to monic polynomial
        out.reduce();
        for(int i=0;i<p2.coef.size();++i)
            p2.coef[i] = p2.coef[i]/p2.coef.back();

        for(int i=out.coef.size()-1;i>=(int)p2.coef.size()-1;--i){
            auto tmp = out.coef[i];
            for(int j=0;j<p2.coef.size();++j)
                out.coef[i-j] = out.coef[i-j] - p2.coef.rbegin()[j] * tmp;
        }
        out.reduce();
        return out;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, -0x38(%rbp)
movq %rdi, %r13
movq %rdi, 0x8(%rdi)
addq $0x10, %rdi
xorps %xmm0, %xmm0
andq $0x0, 0x20(%r13)
movups %xmm0, 0x10(%r13)
movq (%rsi), %rax
movq %rax, (%r13)
addq $0x10, %rsi
movq %rdi, -0x30(%rbp)
callq 0x5c00
movq %r13, %rdi
callq 0x3970
xorl %ebx, %ebx
leaq -0x60(%rbp), %r14
xorl %r12d, %r12d
movq -0x38(%rbp), %rdx
movq 0x10(%rdx), %rsi
movq 0x18(%rdx), %rcx
movq %rcx, %rax
subq %rsi, %rax
cqto
pushq $0x18
popq %rdi
idivq %rdi
cmpq %r12, %rax
jbe 0x591f
addq %rbx, %rsi
addq $-0x18, %rcx
movq %r14, %rdi
movq %rcx, %rdx
callq 0x5cdc
movq -0x38(%rbp), %rdx
movq 0x10(%rdx), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x10(%rax,%rbx)
movups -0x60(%rbp), %xmm0
movups %xmm0, (%rax,%rbx)
incq %r12
addq $0x18, %rbx
jmp 0x58d0
movq 0x18(%r13), %rax
subq 0x10(%r13), %rax
cqto
idivq %rdi
movq %rax, %r8
leal -0x1(%rax), %r9d
leaq -0xa0(%rbp), %r15
movq %r13, -0x68(%rbp)
decl %r8d
movq %rcx, %rax
subq %rsi, %rax
cqto
pushq $0x18
popq %rdi
idivq %rdi
decl %eax
cmpl %eax, %r8d
jl 0x5a1c
movl %r9d, -0x3c(%rbp)
movslq %r9d, %rax
imulq $0x18, %rax, %r12
movq %r8, -0x70(%rbp)
movslq %r8d, %rax
movq -0x30(%rbp), %rdx
movq (%rdx), %rdx
imulq $0x18, %rax, %rax
movq 0x10(%rdx,%rax), %rdi
movq %rdi, -0x50(%rbp)
movups (%rdx,%rax), %xmm0
movaps %xmm0, -0x60(%rbp)
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %rcx, %rax
subq %rsi, %rax
cqto
pushq $0x18
popq %rdi
idivq %rdi
cmpq %rbx, %rax
jbe 0x5a08
movq -0x30(%rbp), %rax
movq (%rax), %r14
leaq (%rcx,%r13), %rsi
addq $-0x18, %rsi
movq %r15, %rdi
leaq -0x60(%rbp), %rdx
callq 0x5d82
addq %r12, %r14
addq %r13, %r14
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5d30
movq -0x30(%rbp), %rax
movq (%rax), %rax
addq %r12, %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x10(%r13,%rax)
movups -0x88(%rbp), %xmm0
movups %xmm0, (%r13,%rax)
incq %rbx
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rcx
addq $-0x18, %r13
jmp 0x598d
movl -0x3c(%rbp), %r9d
decl %r9d
movq -0x68(%rbp), %r13
movq -0x70(%rbp), %r8
jmp 0x593e
movq %r13, %rdi
callq 0x3970
movq %r13, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5a3a
jmp 0x5a3a
movq %rax, %r14
movq -0x30(%rbp), %rdi
callq 0x4a9e
movq %r14, %rdi
callq 0x22b0