// File: /workspace/github_cpp_makefile_star2_O3/manschga[P]M5GB/M5GB.cpp
// Function: Full_S_Reduce(Lab_poly&, int)
void Full_S_Reduce(Lab_poly &F, const int n)
{
  //number_of_reductions++;
#ifdef PRECISE_DEBUG
  cout << "doing full-reduce with " << F << endl;
#endif
  signature T = F.Get_sign();
  polynomial f = F.Get_poly();
  polynomial f_ = f;
  for (auto& monom : f.Get_monomials())
    {
#ifdef PRECISE_DEBUG
      cout << "t = " << monom.Get_term() << endl;
#endif
      int t = monom.Get_term();
       int c = monom.Get_coeff();
       if (Flags_T.find(t) != Flags_T.end() &&  (Flags_T.find(t)->second > T || Flags_T.find(t)->second == T))
	 {
         if (Generations_T.find(t)->second == G_.size())//t is known to be irreducible -> nothing needs to be done!
	     {
	       continue;
	     }
	   else if (!Check_TGFT(t,T))//if not reducible by G, possible improvement: check only for newer elements, nothing for counting argument!
	     {
	       Generations_T.erase(t);
	       Generations_T[t] = G_.size();
	       Flags_T.erase(t);//update signature flag since new generation, improvement: take only newer ons and do min with old flag
	       Flags_T[t] = Create_term_flag(t);
	     }
	 }
       //bool compatible = false; -> improvement to save some div by G operations
      auto itr = LT_M.find(t);
      if (itr != LT_M.end()) //element in M found
	{
	  Lab_poly m_ = Update_m(Lab_poly(M.find(itr->first)->second,itr->second),T,n); //bring m in right form such that it is tail-irreducible again
	  f_ = f_ - m_.Get_poly().Multiply(c,true); //f - c_t(f)*m_t
	  number_of_reductions++;
	  full_red_steps ++;
	}
      else if (Check_TGFT(t,T))//if reducible by G
	{
	  Flags_T.erase(t);//t is no longer irreducible (only first one needed, rest for less storage) 
	  Generations_T.erase(t);
	  Lab_poly vM = Div_by_M(t,T);//find best divisor in M, improvment: map G -> M, only need to check that m's on divisibility, if not by M -> reduce by G, inside implemented!
	  Lab_poly m_ = Tail_S_Reduce(vM,T,n); //create new element in M such that it is tail-irreducible
	  f_ = f_ - m_.Get_poly().Multiply(c,true); //f - c_t(f)*m_t
	  number_of_reductions++;
	  full_red_steps ++;
	}
      else
	{
	  Flags_T.erase(t);//update signature flag since new generation, improvement: take only newer ons and do min with old flag
	  Flags_T[t] = Create_term_flag(t);
	  Generations_T[t] = G_.size();
      }
    }
  F = Lab_poly(f_,T);
#ifdef DEBUG
  //cout << "Full_reduce element: " << F << endl;
#endif
  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %esi, 0xc(%rsp)
movq %rdi, %r14
movups 0x20(%rdi), %xmm0
movaps %xmm0, 0x30(%rsp)
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x68a4
movq %r14, 0xd8(%rsp)
movl 0x18(%r14), %eax
movl %eax, 0x18(%rbx)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x68a4
movl 0x100(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0xe8(%rsp), %r14
movq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
cmpq %rax, %r14
je 0x9404
leaq 0x40(%rsp), %r15
movslq (%r14), %rbp
movl 0x8(%r14), %r13d
movq %rbp, 0x40(%rsp)
leaq 0x11408(%rip), %rdi     # 0x1a338
movq %r15, %rsi
callq 0xed76
testq %rax, %rax
je 0x9070
movq %rbp, 0xa0(%rsp)
leaq 0x113e8(%rip), %rdi     # 0x1a338
leaq 0xa0(%rsp), %rsi
callq 0xed76
movq 0x38(%rsp), %rcx
movl 0x30(%rsp), %edx
movl 0x10(%rax), %esi
xorl %edi, %edi
cmpl %esi, %edx
setl %dil
xorl %r8d, %r8d
cmpq 0x18(%rax), %rcx
setne %al
setl %r8b
cmovnel %r8d, %edi
cmpl %edx, %esi
setne %cl
orb %al, %cl
testb %cl, %dil
je 0x903c
movq %rbp, 0x40(%rsp)
leaq 0x11479(%rip), %rdi     # 0x1a418
movq %r15, %rsi
callq 0xedd2
movslq 0x10(%rax), %rax
cmpq %rax, 0x1132e(%rip)     # 0x1a2e0
je 0x9396
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0xa330
testb %al, %al
jne 0x9070
movq %rbp, 0x40(%rsp)
leaq 0x1143f(%rip), %r12     # 0x1a418
movq %r12, %rdi
movq %r15, %rsi
callq 0xe59e
movq 0x112f5(%rip), %rbx     # 0x1a2e0
movq %rbp, 0x40(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0xee2e
movl %ebx, (%rax)
movq %rbp, 0x40(%rsp)
leaq 0x1132f(%rip), %rdi     # 0x1a338
movq %r15, %rsi
callq 0xe926
movq %rbp, %rdi
callq 0xa4f6
movl %eax, %r12d
movq %rdx, %rbx
movq %rbp, 0x40(%rsp)
leaq 0x1130d(%rip), %rdi     # 0x1a338
movq %r15, %rsi
callq 0xeeec
movl %r12d, (%rax)
movq %rbx, 0x8(%rax)
jmp 0x9070
movq %rbp, 0x80(%rsp)
leaq 0x112ed(%rip), %rdi     # 0x1a338
leaq 0x80(%rsp), %rsi
callq 0xed76
movl 0x10(%rax), %ecx
cmpl 0x30(%rsp), %ecx
jne 0x9070
movq 0x18(%rax), %rax
cmpq 0x38(%rsp), %rax
je 0x8f93
movq %rbp, 0x40(%rsp)
leaq 0x11214(%rip), %rdi     # 0x1a290
movq %r15, %rsi
callq 0xed76
movq %rax, %r12
testq %rax, %rax
je 0x91da
leaq 0x8(%r12), %rsi
leaq 0x11264(%rip), %rdi     # 0x1a300
callq 0xed1a
leaq 0x128(%rsp), %rbp
movq %rax, %rbx
leaq 0x10(%rax), %rsi
movq %rbp, %rdi
callq 0x68a4
movl 0x28(%rbx), %eax
movl %eax, 0x140(%rsp)
movl 0x10(%r12), %edx
movq 0x18(%r12), %rcx
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x50f8
leaq 0x30(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
movl 0xc(%rsp), %ecx
callq 0xa6cc
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x9110
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x912d
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x6992
leaq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x6bd0
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movaps 0xa0(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
testq %rdi, %rdi
je 0x92f1
subq %rdi, %rsi
callq 0x2180
movq 0xa0(%rsp), %rdi
movl 0xb8(%rsp), %eax
movl %eax, 0x28(%rsp)
testq %rdi, %rdi
je 0x92fc
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x92fc
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0xa330
testb %al, %al
je 0x933e
movq %rbp, 0x40(%rsp)
leaq 0x1113d(%rip), %rdi     # 0x1a338
movq %r15, %rsi
callq 0xe926
movq %rbp, 0x40(%rsp)
leaq 0x11209(%rip), %rdi     # 0x1a418
movq %r15, %rsi
callq 0xe59e
movq %r15, %rdi
movq %rbp, %rsi
leaq 0x30(%rsp), %rbx
movq %rbx, %rdx
callq 0xa822
leaq 0xa0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl 0xc(%rsp), %ecx
callq 0xaf68
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x6992
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x6bd0
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movaps 0x80(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
testq %rdi, %rdi
je 0x93aa
subq %rdi, %rsi
callq 0x2180
movq 0x80(%rsp), %rdi
movl 0x98(%rsp), %eax
movl %eax, 0x28(%rsp)
testq %rdi, %rdi
je 0x93b5
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x93b5
movl 0xb8(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x9319
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
incl 0x10ea1(%rip)           # 0x1a1c0
incl 0x10e97(%rip)           # 0x1a1bc
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x9396
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x9396
movq %rbp, 0x40(%rsp)
leaq 0x10fee(%rip), %rdi     # 0x1a338
movq %r15, %rsi
callq 0xe926
movq %rbp, %rdi
callq 0xa4f6
movl %eax, %ebx
movq %rdx, %r12
movq %rbp, 0x40(%rsp)
leaq 0x10fcd(%rip), %rdi     # 0x1a338
movq %r15, %rsi
callq 0xeeec
movl %ebx, (%rax)
movq %r12, 0x8(%rax)
movq 0x10f60(%rip), %rbx     # 0x1a2e0
movq %rbp, 0x40(%rsp)
leaq 0x1108c(%rip), %rdi     # 0x1a418
movq %r15, %rsi
callq 0xee2e
movl %ebx, (%rax)
addq $0x10, %r14
cmpq 0xe0(%rsp), %r14
jne 0x8f1d
jmp 0x9404
movl 0x98(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x93d2
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
incl 0x10de8(%rip)           # 0x1a1c0
incl 0x10dde(%rip)           # 0x1a1bc
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x9325
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x9325
leaq 0x108(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x68a4
movl 0x28(%rsp), %eax
leaq 0x108(%rsp), %rsi
movl %eax, 0x18(%rsi)
movl 0x30(%rsp), %edx
movq 0x38(%rsp), %rcx
leaq 0x40(%rsp), %rdi
callq 0x50f8
movq 0xd8(%rsp), %r14
leaq 0x20(%r14), %rbx
movq (%r14), %rdi
movq 0x10(%r14), %rsi
movaps 0x40(%rsp), %xmm0
movups %xmm0, (%r14)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
testq %rdi, %rdi
je 0x94ab
subq %rdi, %rsi
callq 0x2180
movq 0x40(%rsp), %rdi
movl 0x58(%rsp), %eax
movl %eax, 0x18(%r14)
movl 0x70(%rsp), %eax
movl %eax, 0x10(%rbx)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rbx)
testq %rdi, %rdi
je 0x94c2
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x94c2
movl 0x58(%rsp), %eax
movl %eax, 0x18(%r14)
movl 0x70(%rsp), %eax
movl %eax, 0x10(%rbx)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rbx)
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x94df
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x94f6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x9513
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x9664
movq 0x118(%rsp), %rsi
jmp 0x9651
jmp 0x9661
movq %rax, %rbx
jmp 0x967b
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
movq %rax, %rbx
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x9591
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x9591
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x960b
movq 0xb0(%rsp), %rsi
jmp 0x9603
jmp 0x95e1
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
jmp 0x9661
movq %rax, %rbx
jmp 0x960b
movq %rax, %rbx
jmp 0x963c
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x960b
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x9664
movq 0x50(%rsp), %rsi
jmp 0x9651
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x963c
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x9664
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x9664
jmp 0x9661
jmp 0x9661
jmp 0x9661
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x967b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x9698
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2240