// File: /workspace/github_cpp_makefile_star2_O1/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:
movl (%rsi), %eax
testl %eax, %eax
je 0x2917
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, 0x78(%rsp)
movl %eax, 0xc(%rsp)
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movaps %xmm1, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movups 0x8b8a(%rip), %xmm0     # 0xb134
movaps %xmm0, 0x90(%rsp)
movups 0x8b6b(%rip), %xmm0     # 0xb124
movaps %xmm0, 0x80(%rsp)
movl $0x1, 0x58(%rsp)
movw $0x1, 0x5c(%rsp)
movl $0x0, 0x10(%rsp)
cmpl $0x0, 0x30(%rsp)
je 0x2885
xorl %ebx, %ebx
leaq 0x80(%rsp), %r14
leaq 0x8b30(%rip), %r12      # 0xb124
leaq 0x10(%rsp), %r13
leaq 0x58(%rsp), %rbp
xorl %r15d, %r15d
movl %ebx, %eax
shrl $0x4, %eax
cmpl 0x30(%rsp), %eax
jge 0x26c7
movl %eax, %eax
movzwl 0x34(%rsp,%rax,2), %eax
movl %ebx, %ecx
andl $0xf, %ecx
btl %ecx, %eax
jae 0x26c7
testl %ebx, %ebx
je 0x2638
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl %ebx, %edx
callq 0x29e6
testl %r15d, %r15d
je 0x264b
movq %rbp, %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0x29e6
xorl %ebx, %ebx
xorl %r15d, %r15d
movl %ebx, %eax
shrl $0x4, %eax
cmpl 0x80(%rsp), %eax
jge 0x2676
movl %eax, %eax
movzwl 0x84(%rsp,%rax,2), %eax
movl %ebx, %ecx
andl $0xf, %ecx
btl %ecx, %eax
jb 0x271b
leal 0xf(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
sarl $0x4, %eax
cmpl 0x10(%rsp), %eax
jge 0x26c0
cltq
movzwl 0x14(%rsp,%rax,2), %eax
movl %r15d, %ecx
andl $0xf, %ecx
btl %ecx, %eax
jae 0x26c0
testl %r15d, %r15d
je 0x26af
movq %r13, %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x29e6
movq %r13, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2ae6
xorl %r15d, %r15d
incl %r15d
incl %ebx
jmp 0x2650
leal 0xf(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
sarl $0x4, %eax
cmpl 0x58(%rsp), %eax
jge 0x2711
cltq
movzwl 0x5c(%rsp,%rax,2), %eax
movl %r15d, %ecx
andl $0xf, %ecx
btl %ecx, %eax
jae 0x2711
testl %r15d, %r15d
je 0x2700
movq %rbp, %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0x29e6
movq %rbp, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x2ae6
xorl %r15d, %r15d
incl %ebx
incl %r15d
jmp 0x2601
testl %ebx, %ebx
je 0x272c
movq %r14, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x29e6
testl %r15d, %r15d
je 0x273f
movq %r13, %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x29e6
movl 0x30(%rsp), %eax
movl 0x80(%rsp), %ecx
cmpl %ecx, %eax
jge 0x277d
movq %r14, %rdi
movq %r14, %rsi
leaq 0x30(%rsp), %rdx
callq 0x291e
movl 0x10(%rsp), %eax
movl 0x58(%rsp), %ecx
cmpl %ecx, %eax
jge 0x27a5
movq %r13, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2ae6
jmp 0x2849
cmpl %ecx, %eax
jg 0x27e4
movl %eax, %ecx
testl %eax, %eax
jle 0x27d4
movzwl 0x32(%rsp,%rax,2), %edx
movzwl 0x82(%rsp,%rax,2), %esi
cmpw %si, %dx
jb 0x27d2
decq %rax
cmpw %si, %dx
jbe 0x2781
movb $0x1, %dl
jmp 0x27d4
cmpl %ecx, %eax
jg 0x2849
movl %eax, %ecx
testl %eax, %eax
jle 0x2837
movzwl 0x12(%rsp,%rax,2), %edx
movzwl 0x5a(%rsp,%rax,2), %esi
cmpw %si, %dx
jb 0x2835
decq %rax
cmpw %si, %dx
jbe 0x27ad
xorl %edx, %edx
jmp 0x2837
xorl %edx, %edx
testl %ecx, %ecx
setg %al
xorb $0x1, %dl
testb %dl, %al
jne 0x274e
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movq %r14, %rdx
callq 0x291e
movl 0x58(%rsp), %eax
movl 0x10(%rsp), %ecx
cmpl %ecx, %eax
jge 0x2810
movq %rbp, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x2ae6
jmp 0x2864
cmpl %ecx, %eax
jg 0x2864
movl %eax, %ecx
testl %eax, %eax
jle 0x2856
movzwl 0x5a(%rsp,%rax,2), %edx
movzwl 0x12(%rsp,%rax,2), %esi
cmpw %si, %dx
jb 0x2854
decq %rax
cmpw %si, %dx
jbe 0x2814
xorl %edx, %edx
jmp 0x2856
movb $0x1, %dl
testl %ecx, %ecx
setle %al
notb %dl
orb %al, %dl
testb $0x1, %dl
je 0x276a
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
jmp 0x286d
movb $0x1, %dl
testl %ecx, %ecx
setle %al
notb %dl
orb %al, %dl
testb $0x1, %dl
je 0x2800
movq %rbp, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x291e
xorl %ebx, %ebx
cmpl $0x0, 0x30(%rsp)
movl $0x0, %r15d
jne 0x2601
movl 0x10(%rsp), %eax
cmpl 0x8895(%rip), %eax      # 0xb124
movq 0x78(%rsp), %rdi
jge 0x28ae
movslq %eax, %rdx
movl %edx, (%rdi)
addq $0x4, %rdi
leaq 0x14(%rsp), %rsi
addq %rdx, %rdx
callq 0x10a0
jmp 0x2902
jg 0x28f1
leaq 0x886d(%rip), %rdx      # 0xb124
movq %rax, %rsi
movl %esi, %ecx
testl %esi, %esi
jle 0x28e3
movzwl 0x12(%rsp,%rsi,2), %r9d
movzwl 0x2(%rdx,%rsi,2), %r8d
cmpw %r8w, %r9w
jb 0x28e0
decq %rsi
cmpw %r8w, %r9w
jbe 0x28ba
movb $0x1, %r8b
jmp 0x28e3
xorl %r8d, %r8d
testl %ecx, %ecx
setg %cl
xorb $0x1, %r8b
testb %r8b, %cl
jne 0x2896
leaq 0x882c(%rip), %rdx      # 0xb124
leaq 0x10(%rsp), %rsi
callq 0x291e
movl 0xc(%rsp), %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
testl %eax, %eax
setne %al
retq
nop