// File: /workspace/github_cpp_makefile_star2_O1/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 0x6314
movq %r14, 0xd8(%rsp)
movl 0x18(%r14), %eax
movl %eax, 0x18(%rbx)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x6314
movl 0x100(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0xe8(%rsp), %r13
movq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
cmpq %rax, %r13
je 0x8e6b
leaq 0x68(%rsp), %r12
movslq (%r13), %rbx
movl 0x8(%r13), %r15d
movq 0x11a50(%rip), %rdi     # 0x1a330
movq %rbx, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, %rcx
movq 0x11a36(%rip), %rax     # 0x1a328
movq (%rax,%rdx,8), %r8
movl $0x0, %eax
testq %r8, %r8
je 0x8939
movq (%r8), %r9
movq %r8, %rax
cmpq 0x8(%r9), %rbx
je 0x8939
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x8937
movq 0x8(%r9), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %eax
cmpq %rcx, %rdx
jne 0x8939
movq %r10, %rax
cmpq %rsi, %rbx
jne 0x890c
jmp 0x8939
xorl %eax, %eax
testq %rax, %rax
je 0x8ab6
cmpq $0x0, (%rax)
je 0x8ab6
movq (%r8), %rax
movq %r8, %rdx
cmpq 0x8(%rax), %rbx
je 0x8960
movq %rax, %rdx
movq (%rax), %rax
jmp 0x8952
movq (%rdx), %rax
movq 0x38(%rsp), %r9
movl 0x30(%rsp), %r10d
movl 0x10(%rax), %edx
xorl %esi, %esi
cmpl %edx, %r10d
setl %sil
xorl %r11d, %r11d
cmpq 0x18(%rax), %r9
setne %al
setl %r11b
cmovnel %r11d, %esi
cmpl %r10d, %edx
setne %dl
orb %al, %dl
testb %dl, %sil
je 0x8a5d
movq %rbx, %rax
xorl %edx, %edx
divq 0x11a68(%rip)           # 0x1a410
movq 0x11a59(%rip), %rax     # 0x1a408
movq (%rax,%rdx,8), %rax
movq (%rax), %rcx
cmpq 0x8(%rcx), %rbx
je 0x89c4
movq %rcx, %rax
movq (%rcx), %rcx
jmp 0x89b6
movq (%rax), %rax
movslq 0x10(%rax), %rax
cmpq %rax, 0x118fe(%rip)     # 0x1a2d0
je 0x8e59
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x9da4
testb %al, %al
jne 0x8ab6
movq %rbx, 0x68(%rsp)
leaq 0x11a0f(%rip), %rbp     # 0x1a408
movq %rbp, %rdi
movq %r12, %rsi
callq 0xe152
movq 0x118c5(%rip), %r14     # 0x1a2d0
movq %rbx, 0x68(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0xe934
movl %r14d, (%rax)
movq %rbx, 0x68(%rsp)
leaq 0x118fe(%rip), %rdi     # 0x1a328
movq %r12, %rsi
callq 0xe50c
movq %rbx, %rdi
callq 0x9f88
movl %eax, %r14d
movq %rdx, %rbp
movq %rbx, 0x68(%rsp)
leaq 0x118dc(%rip), %rdi     # 0x1a328
movq %r12, %rsi
callq 0xe9de
movl %r14d, (%rax)
movq %rbp, 0x8(%rax)
jmp 0x8ab6
testq %r8, %r8
je 0x8a97
movq (%r8), %r11
cmpq 0x8(%r11), %rbx
je 0x8a9a
movq %r11, %r14
movq (%r11), %r11
testq %r11, %r11
je 0x8a97
movq 0x8(%r11), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %r8d
cmpq %rcx, %rdx
jne 0x8a9a
movq %r14, %r8
cmpq %rsi, %rbx
jne 0x8a6b
jmp 0x8a9a
xorl %r8d, %r8d
testq %r8, %r8
je 0x8aa4
movq (%r8), %rax
jmp 0x8aa6
xorl %eax, %eax
cmpl %r10d, 0x10(%rax)
jne 0x8ab6
cmpq %r9, 0x18(%rax)
je 0x899c
movq 0x117cb(%rip), %rdi     # 0x1a288
movq %rbx, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, %rcx
movq 0x117b1(%rip), %rax     # 0x1a280
movq (%rax,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x8b16
movq (%rdx), %r8
movq %rdx, %rax
cmpq 0x8(%r8), %rbx
je 0x8b16
movq %r8, %r9
movq (%r8), %r8
testq %r8, %r8
je 0x8b14
movq 0x8(%r8), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %eax
cmpq %rcx, %rdx
jne 0x8b16
movq %r9, %rax
cmpq %rsi, %rbx
jne 0x8ae9
jmp 0x8b16
xorl %eax, %eax
testq %rax, %rax
je 0x8b20
movq (%rax), %r14
jmp 0x8b23
xorl %r14d, %r14d
testq %r14, %r14
je 0x8cbf
leaq 0x8(%r14), %rcx
movq 0x8(%r14), %r8
movq %r8, %rax
xorl %edx, %edx
divq 0x117b8(%rip)           # 0x1a2f8
leaq 0x117a9(%rip), %rdi     # 0x1a2f0
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
callq 0xdd4a
leaq 0x128(%rsp), %rbp
movq (%rax), %rbx
leaq 0x10(%rbx), %rsi
movq %rbp, %rdi
callq 0x6314
movl 0x28(%rbx), %eax
movl %eax, 0x140(%rsp)
movl 0x10(%r14), %edx
movq 0x18(%r14), %rcx
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4bf0
movq %r12, %rdi
movq %rbx, %rsi
leaq 0x30(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0xa15e
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x8bc2
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x8bdf
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movl %r15d, %edx
movl $0x1, %ecx
callq 0x6402
leaq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x6640
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xa8(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
testq %rdi, %rdi
je 0x8c54
subq %rdi, %rsi
callq 0x2180
movl 0xb8(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x8c7c
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x8c93
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
incl 0x11517(%rip)           # 0x1a1b0
incl 0x1150d(%rip)           # 0x1a1ac
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x8e59
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8e59
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x9da4
testb %al, %al
je 0x8e00
movq %rbx, 0x68(%rsp)
leaq 0x11648(%rip), %rdi     # 0x1a328
movq %r12, %rsi
callq 0xe50c
movq %rbx, 0x68(%rsp)
leaq 0x11714(%rip), %rdi     # 0x1a408
movq %r12, %rsi
callq 0xe152
movq %r12, %rdi
movq %rbx, %rsi
leaq 0x30(%rsp), %rbx
movq %rbx, %rdx
callq 0xa2c1
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movl 0xc(%rsp), %ecx
callq 0xa9d4
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
movl $0x1, %ecx
callq 0x6402
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x6640
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
testq %rdi, %rdi
je 0x8d92
subq %rdi, %rsi
callq 0x2180
movl 0x58(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x8db1
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x8dce
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
incl 0x113dc(%rip)           # 0x1a1b0
incl 0x113d2(%rip)           # 0x1a1ac
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x8c9f
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8c9f
movq %rbx, 0x68(%rsp)
leaq 0x1151c(%rip), %rdi     # 0x1a328
movq %r12, %rsi
callq 0xe50c
movq %rbx, %rdi
callq 0x9f88
movl %eax, %ebp
movq %rdx, %r14
movq %rbx, 0x68(%rsp)
leaq 0x114fb(%rip), %rdi     # 0x1a328
movq %r12, %rsi
callq 0xe9de
movl %ebp, (%rax)
movq %r14, 0x8(%rax)
movq 0x1148e(%rip), %r14     # 0x1a2d0
movq %rbx, 0x68(%rsp)
leaq 0x115ba(%rip), %rdi     # 0x1a408
movq %r12, %rsi
callq 0xe934
movl %r14d, (%rax)
addq $0x10, %r13
cmpq 0xe0(%rsp), %r13
jne 0x88d1
leaq 0x108(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x6314
movl 0x28(%rsp), %eax
leaq 0x108(%rsp), %rsi
movl %eax, 0x18(%rsi)
movl 0x30(%rsp), %edx
movq 0x38(%rsp), %rcx
leaq 0x68(%rsp), %rdi
callq 0x4bf0
movq 0xd8(%rsp), %r15
leaq 0x20(%r15), %r14
leaq 0x68(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x60a8
movl 0x18(%rbx), %eax
movl %eax, 0x18(%r15)
movl 0x30(%rbx), %eax
movl %eax, 0x10(%r14)
movups 0x20(%rbx), %xmm0
movups %xmm0, (%r14)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x8ee6
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x8f03
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8f1a
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x8f37
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 0x9060
movq 0x118(%rsp), %rsi
jmp 0x9053
jmp 0x905d
movq %rax, %rbx
jmp 0x9077
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
movq %rax, %rbx
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x8fba
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8fba
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x902a
movq 0xb0(%rsp), %rsi
jmp 0x8ffb
jmp 0x9027
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
jmp 0x905d
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x902a
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x902a
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x903e
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x903e
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x9060
movq 0x78(%rsp), %rsi
jmp 0x9053
movq %rax, %rbx
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x9060
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x9060
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9077
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x9094
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2240