// File: koraa[P]sbcrack/cube/crypto.cpp
// Function: void gfield::reduce<26>(bigint<26> const&)
void reduce(const bigint<RESULT_DIGITS> &result)
    {
#if GF_BITS==192
        len = min(result.len, GF_DIGITS);
        memcpy(digits, result.digits, len*sizeof(digit));
        shrink();

        if(result.len > 192/BI_DIGIT_BITS)
        {
            gfield s;
            memcpy(s.digits, &result.digits[192/BI_DIGIT_BITS], min(result.len-192/BI_DIGIT_BITS, 64/BI_DIGIT_BITS)*sizeof(digit));
            if(result.len < 256/BI_DIGIT_BITS) memset(&s.digits[result.len-192/BI_DIGIT_BITS], 0, (256/BI_DIGIT_BITS-result.len)*sizeof(digit));
            memcpy(&s.digits[64/BI_DIGIT_BITS], s.digits, 64/BI_DIGIT_BITS*sizeof(digit));
            s.len = 128/BI_DIGIT_BITS;
            s.shrink();
            add(s);

            if(result.len > 256/BI_DIGIT_BITS)
            {
                memset(s.digits, 0, 64/BI_DIGIT_BITS*sizeof(digit));
                memcpy(&s.digits[64/BI_DIGIT_BITS], &result.digits[256/BI_DIGIT_BITS], min(result.len-256/BI_DIGIT_BITS, 64/BI_DIGIT_BITS)*sizeof(digit));
                if(result.len < 320/BI_DIGIT_BITS) memset(&s.digits[result.len+(64-256)/BI_DIGIT_BITS], 0, (320/BI_DIGIT_BITS-result.len)*sizeof(digit));
                memcpy(&s.digits[128/BI_DIGIT_BITS], &s.digits[64/BI_DIGIT_BITS], 64/BI_DIGIT_BITS*sizeof(digit));
                s.len = GF_DIGITS;
                s.shrink();
                add(s);

                if(result.len > 320/BI_DIGIT_BITS)
                {
                    memcpy(s.digits, &result.digits[320/BI_DIGIT_BITS], min(result.len-320/BI_DIGIT_BITS, 64/BI_DIGIT_BITS)*sizeof(digit));
                    if(result.len < 384/BI_DIGIT_BITS) memset(&s.digits[result.len-320/BI_DIGIT_BITS], 0, (384/BI_DIGIT_BITS-result.len)*sizeof(digit));
                    memcpy(&s.digits[64/BI_DIGIT_BITS], s.digits, 64/BI_DIGIT_BITS*sizeof(digit));
                    memcpy(&s.digits[128/BI_DIGIT_BITS], s.digits, 64/BI_DIGIT_BITS*sizeof(digit));
                    s.len = GF_DIGITS;
                    s.shrink();
                    add(s);
                }
            }
        }
        else if(*this >= P) gfint::sub(*this, P);
#else
#error Unsupported GF
#endif
    }

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x58(%rsp), %rax
movl (%rax), %edi
movl $0xc, %esi
callq 0x9200
movl %eax, %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq %rax, %rdi
addq $0x4, %rdi
movq 0x58(%rsp), %rsi
addq $0x4, %rsi
movslq (%rax), %rdx
shlq %rdx
callq 0x10c0
movq 0x30(%rsp), %rdi
callq 0x9a20
movq 0x58(%rsp), %rax
cmpl $0xc, (%rax)
jle 0xac86
leaq 0x38(%rsp), %rdi
callq 0x9d20
leaq 0x38(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x58(%rsp), %rax
addq $0x4, %rax
addq $0x18, %rax
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %rax
movl (%rax), %edi
subl $0xc, %edi
movl $0x4, %esi
callq 0x9200
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movslq %eax, %rdx
shlq %rdx
callq 0x10c0
movq 0x58(%rsp), %rax
cmpl $0x10, (%rax)
jge 0xaab6
leaq 0x38(%rsp), %rdi
addq $0x4, %rdi
movq 0x58(%rsp), %rax
movl (%rax), %eax
subl $0xc, %eax
cltq
shlq %rax
addq %rax, %rdi
movq 0x58(%rsp), %rcx
movl $0x10, %eax
subl (%rcx), %eax
movslq %eax, %rdx
shlq %rdx
xorl %esi, %esi
callq 0x1080
movq 0x3c(%rsp), %rax
movq %rax, 0x44(%rsp)
movl $0x8, 0x38(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x9a20
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xad20
movq 0x58(%rsp), %rax
cmpl $0x10, (%rax)
jle 0xac84
leaq 0x38(%rsp), %rdi
addq $0x4, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x1080
leaq 0x38(%rsp), %rax
addq $0x4, %rax
addq $0x8, %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rax
addq $0x4, %rax
addq $0x20, %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rax
movl (%rax), %edi
subl $0x10, %edi
movl $0x4, %esi
callq 0x9200
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movslq %eax, %rdx
shlq %rdx
callq 0x10c0
movq 0x58(%rsp), %rax
cmpl $0x14, (%rax)
jge 0xab8f
leaq 0x38(%rsp), %rdi
addq $0x4, %rdi
movq 0x58(%rsp), %rax
movl (%rax), %eax
addl $-0xc, %eax
cltq
shlq %rax
addq %rax, %rdi
movq 0x58(%rsp), %rcx
movl $0x14, %eax
subl (%rcx), %eax
movslq %eax, %rdx
shlq %rdx
xorl %esi, %esi
callq 0x1080
movq 0x44(%rsp), %rax
movq %rax, 0x4c(%rsp)
movl $0xc, 0x38(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x9a20
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xad20
movq 0x58(%rsp), %rax
cmpl $0x14, (%rax)
jle 0xac82
leaq 0x38(%rsp), %rax
addq $0x4, %rax
movq %rax, (%rsp)
movq 0x58(%rsp), %rax
addq $0x4, %rax
addq $0x28, %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rax
movl (%rax), %edi
subl $0x14, %edi
movl $0x4, %esi
callq 0x9200
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movslq %eax, %rdx
shlq %rdx
callq 0x10c0
movq 0x58(%rsp), %rax
cmpl $0x18, (%rax)
jge 0xac4d
leaq 0x38(%rsp), %rdi
addq $0x4, %rdi
movq 0x58(%rsp), %rax
movl (%rax), %eax
subl $0x14, %eax
cltq
shlq %rax
addq %rax, %rdi
movq 0x58(%rsp), %rcx
movl $0x18, %eax
subl (%rcx), %eax
movslq %eax, %rdx
shlq %rdx
xorl %esi, %esi
callq 0x1080
movq 0x3c(%rsp), %rax
movq %rax, 0x44(%rsp)
movq 0x3c(%rsp), %rax
movq %rax, 0x4c(%rsp)
movl $0xc, 0x38(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x9a20
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xad20
jmp 0xac84
jmp 0xacb3
movq 0x30(%rsp), %rdi
leaq 0x84b2(%rip), %rsi      # 0x13144
callq 0xa280
testb $0x1, %al
jne 0xac9d
jmp 0xacb1
movq 0x30(%rsp), %rsi
leaq 0x849b(%rip), %rdx      # 0x13144
movq %rsi, %rdi
callq 0xa3b0
jmp 0xacb3
addq $0x68, %rsp
retq
nopl (%rax,%rax)