// File: permutationlock[P]aes_math/lib/galois_field.cpp
// Function: Polynomial::operator/=(Polynomial const&)
Polynomial & Polynomial::operator/=(const Polynomial & other){
    if(_p != other._p) throw runtime_error("Mismatched prime.");
    
    Polynomial quot(0,_p,1);
    
    Modular<int>::globalSetModulus(_p);
    while(this->size() >= other.size()){
        Modular<int> c =  other._a.back() / _a.back();
        int diff = this->size()-other.size();
        vector<Modular<int>> v;
        for(int i=0; i< diff; i++)
            v.push_back(0);
        v.push_back(c);
        Polynomial p(v,_p);
        quot += p;
        (*this) -= (other * p);
    }
    
    swap(_a,quot._a);
    
    return *this;
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x18(%rax), %eax
movq 0xd8(%rsp), %rcx
cmpl 0x18(%rcx), %eax
je 0x5032
movl $0x10, %edi
callq 0x20a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x28(%rsp)
leaq 0x11014(%rip), %rsi     # 0x16004
callq 0x2070
jmp 0x4ff7
movq 0x28(%rsp), %rdi
movq 0x18fed(%rip), %rsi     # 0x1dff0
movq 0x18fbe(%rip), %rdx     # 0x1dfc8
callq 0x2290
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
callq 0x2130
jmp 0x52c6
movq 0x30(%rsp), %rax
movq %rax, %rcx
addq $0x18, %rcx
movq %rcx, 0x20(%rsp)
movl 0x18(%rax), %edx
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %ecx
callq 0x4370
movq 0x20(%rsp), %rdi
callq 0x68f0
jmp 0x5066
jmp 0x5068
movq 0x30(%rsp), %rdi
callq 0x4700
movl %eax, 0x1c(%rsp)
jmp 0x5078
movq 0xd8(%rsp), %rdi
callq 0x4700
movl %eax, 0x18(%rsp)
jmp 0x508b
movl 0x1c(%rsp), %eax
movl 0x18(%rsp), %ecx
cmpl %ecx, %eax
jl 0x528d
movq 0xd8(%rsp), %rdi
callq 0x6b10
movq 0x30(%rsp), %rdi
movq %rax, 0x8(%rsp)
callq 0x6a00
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x6b60
movl %eax, 0x14(%rsp)
jmp 0x50ca
movq 0x30(%rsp), %rdi
movl 0x14(%rsp), %eax
movl %eax, 0xa4(%rsp)
callq 0x4700
movl %eax, 0x4(%rsp)
jmp 0x50e5
movq 0xd8(%rsp), %rdi
callq 0x4700
movl %eax, (%rsp)
jmp 0x50f7
movl (%rsp), %ecx
movl 0x4(%rsp), %eax
subl %ecx, %eax
movl %eax, 0xa0(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x6720
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
cmpl 0xa0(%rsp), %eax
jge 0x51a9
movl $0x0, 0x7c(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x7c(%rsp), %rsi
callq 0x6760
jmp 0x514b
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x6730
jmp 0x5162
jmp 0x5164
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x511f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x52b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x527e
leaq 0x88(%rsp), %rdi
leaq 0xa4(%rsp), %rsi
callq 0x6860
jmp 0x51c0
movq 0x30(%rsp), %rax
movl 0x18(%rax), %edx
leaq 0x58(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x4570
jmp 0x51dc
leaq 0xa8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x4740
jmp 0x51f0
movq 0xd8(%rsp), %rsi
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x4f00
jmp 0x5209
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x48a0
jmp 0x521a
leaq 0x38(%rsp), %rdi
callq 0x6b50
leaq 0x58(%rsp), %rdi
callq 0x6b50
leaq 0x88(%rsp), %rdi
callq 0x67e0
jmp 0x5068
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x5274
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x6b50
leaq 0x58(%rsp), %rdi
callq 0x6b50
leaq 0x88(%rsp), %rdi
callq 0x67e0
jmp 0x52b9
movq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x69d0
leaq 0xa8(%rsp), %rdi
callq 0x6b50
movq 0x30(%rsp), %rax
addq $0xe8, %rsp
retq
leaq 0xa8(%rsp), %rdi
callq 0x6b50
movq 0xd0(%rsp), %rdi
callq 0x22b0
nopw %cs:(%rax,%rax)