// File: /workspace/github_cpp_makefile_star2_O2/koraa[P]sbcrack/cube/crypto.cpp
// Function: gfield::invert(gfield const&)
bool invert(const gfield &x)
    {
        if(!x.len) return false;
        gfint u(x), v(P), A((gfint::digit)1), C((gfint::digit)0);
        while(!u.iszero())
        {
            int ushift = 0, ashift = 0;
            while(!u.hasbit(ushift))
            {
                ushift++;
                if(A.hasbit(ashift))
                {
                    if(ashift) { A.rshift(ashift); ashift = 0; }
                    A.add(P);
                }
                ashift++;
            }
            if(ushift) u.rshift(ushift);
            if(ashift) A.rshift(ashift);
            int vshift = 0, cshift = 0;
            while(!v.hasbit(vshift))
            {
                vshift++;
                if(C.hasbit(cshift))
                {
                    if(cshift) { C.rshift(cshift); cshift = 0; }
                    C.add(P);
                }
                cshift++;
            }
            if(vshift) v.rshift(vshift);
            if(cshift) C.rshift(cshift);
            if(u >= v)
            {
                u.sub(v);
                if(A < C) A.add(P);
                A.sub(C);
            }
            else
            {
                v.sub(v, u);
                if(C < A) C.add(P);
                C.sub(A);
            }
        }
        if(C >= P) gfint::sub(C, P);
        else { len = C.len; memcpy(digits, C.digits, len*sizeof(digit)); }
        ASSERT(*this < P);
        return true;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl (%rsi), %ebx
testl %ebx, %ebx
je 0x2611
movq %rdi, 0x8(%rsp)
movl %ebx, 0x4(%rsp)
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
leaq 0x30(%rsp), %r14
movaps %xmm1, 0x10(%r14)
movaps %xmm0, (%r14)
movups 0x8d08(%rip), %xmm0     # 0xb134
leaq 0x50(%rsp), %r15
movaps %xmm0, 0x10(%r15)
movups 0x8ce7(%rip), %xmm0     # 0xb124
movaps %xmm0, (%r15)
leaq 0x78(%rsp), %r12
movw $0x1, 0x4(%r12)
movl $0x1, (%r12)
leaq 0x10(%rsp), %r13
andl $0x0, (%r13)
cmpl $0x0, 0x30(%rsp)
je 0x25b1
xorl %ebx, %ebx
xorl %ebp, %ebp
movq %r14, %rdi
movl %ebx, %esi
callq 0x2628
testb %al, %al
jne 0x24b0
movq %r12, %rdi
movl %ebp, %esi
callq 0x2628
testb %al, %al
je 0x24aa
testl %ebp, %ebp
je 0x2499
movq %r12, %rdi
movl %ebp, %esi
callq 0x2648
movq %r12, %rdi
leaq 0x8c81(%rip), %rsi      # 0xb124
callq 0x2652
xorl %ebp, %ebp
incl %ebp
incl %ebx
jmp 0x246f
testl %ebx, %ebx
je 0x24be
movq %r14, %rdi
movl %ebx, %esi
callq 0x2648
testl %ebp, %ebp
je 0x24cc
movq %r12, %rdi
movl %ebp, %esi
callq 0x2648
xorl %ebx, %ebx
xorl %ebp, %ebp
movq %r15, %rdi
movl %ebx, %esi
callq 0x2628
testb %al, %al
jne 0x2511
movq %r13, %rdi
movl %ebp, %esi
callq 0x2628
testb %al, %al
je 0x250b
testl %ebp, %ebp
je 0x24fa
movq %r13, %rdi
movl %ebp, %esi
callq 0x2648
movq %r13, %rdi
leaq 0x8c20(%rip), %rsi      # 0xb124
callq 0x2652
xorl %ebp, %ebp
incl %ebp
incl %ebx
jmp 0x24d0
testl %ebx, %ebx
je 0x251f
movq %r15, %rdi
movl %ebx, %esi
callq 0x2648
testl %ebp, %ebp
je 0x252d
movq %r13, %rdi
movl %ebp, %esi
callq 0x2648
movq %r14, %rdi
movq %r15, %rsi
callq 0x265e
testb %al, %al
je 0x2575
movq %r14, %rdi
movq %r15, %rsi
callq 0x2668
movq %r12, %rdi
movq %r13, %rsi
callq 0x2674
testb %al, %al
je 0x2565
movq %r12, %rdi
leaq 0x8bc4(%rip), %rsi      # 0xb124
callq 0x2652
movq %r12, %rdi
movq %r13, %rsi
callq 0x2668
jmp 0x2460
movq %r15, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x26b4
movq %r13, %rdi
movq %r12, %rsi
callq 0x2674
testb %al, %al
je 0x25a1
movq %r13, %rdi
leaq 0x8b88(%rip), %rsi      # 0xb124
callq 0x2652
movq %r13, %rdi
movq %r12, %rsi
callq 0x2668
jmp 0x2460
leaq 0x8b6c(%rip), %rsi      # 0xb124
leaq 0x10(%rsp), %rdi
callq 0x265e
testb %al, %al
je 0x25e1
leaq 0x8b57(%rip), %rdx      # 0xb124
leaq 0x10(%rsp), %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x26b4
jmp 0x25fe
leaq 0x14(%rsp), %rsi
movslq -0x4(%rsi), %rdx
movq 0x8(%rsp), %r14
movl %edx, (%r14)
leaq 0x4(%r14), %rdi
addq %rdx, %rdx
callq 0x10a0
movl 0x4(%rsp), %ebx
leaq 0x8b1b(%rip), %rsi      # 0xb124
movq %r14, %rdi
callq 0x2674
testl %ebx, %ebx
setne %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq