// File: /workspace/github_cpp_makefile_star2_O2/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 $0x158, %rsp            # imm = 0x158
movl %esi, 0x4(%rsp)
movq %rdi, %rsi
movups 0x20(%rdi), %xmm0
movaps %xmm0, 0x40(%rsp)
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq %rsi, 0x50(%rsp)
callq 0x57a2
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x57a2
movq 0xa0(%rsp), %r12
movq 0xa8(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x40(%rsp), %r15
leaq 0xe0(%rsp), %r14
leaq 0x60(%rsp), %rbx
cmpq 0x58(%rsp), %r12
je 0x7320
movslq (%r12), %r13
movl 0x8(%r12), %ebp
movq %r13, 0x8(%rsp)
leaq 0x11373(%rip), %rdi     # 0x18330
leaq 0x8(%rsp), %rsi
callq 0xbc02
testq %rax, %rax
je 0x70d9
movq %r13, 0xe0(%rsp)
leaq 0x11351(%rip), %rdi     # 0x18330
movq %r14, %rsi
callq 0xbc02
addq $0x10, %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0x984e
testb %al, %al
je 0x70ad
movq %r13, 0x8(%rsp)
leaq 0x11406(%rip), %rdi     # 0x18410
leaq 0x8(%rsp), %rsi
callq 0xbc20
movslq 0x10(%rax), %rax
cmpq %rax, 0x112b9(%rip)     # 0x182d8
je 0x7317
movq %r13, %rdi
movq %r15, %rsi
callq 0x7c7f
testb %al, %al
jne 0x70d9
movq %r13, 0x8(%rsp)
leaq 0x113cc(%rip), %rdi     # 0x18410
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0xb374
movq 0x11280(%rip), %rbx     # 0x182d8
movq %r13, 0x8(%rsp)
leaq 0x113ac(%rip), %rdi     # 0x18410
movq %r14, %rsi
callq 0xbc3e
movl %ebx, (%rax)
movq %r13, 0x8(%rsp)
leaq 0x112b6(%rip), %rdi     # 0x18330
movq %r14, %rsi
callq 0xb7bc
movq %r13, %rdi
callq 0x7df9
movl %eax, %ebx
movq %rdx, %r14
movq %r13, 0x8(%rsp)
leaq 0x11295(%rip), %rdi     # 0x18330
leaq 0x8(%rsp), %rsi
callq 0xbd0e
movl %ebx, (%rax)
movq %r14, 0x8(%rax)
jmp 0x70d9
movq %r13, 0x60(%rsp)
leaq 0x11277(%rip), %rdi     # 0x18330
movq %rbx, %rsi
callq 0xbc02
movl 0x10(%rax), %ecx
cmpl 0x40(%rsp), %ecx
jne 0x70d9
movq 0x18(%rax), %rax
cmpq 0x48(%rsp), %rax
je 0x6ffe
movq %r13, 0x8(%rsp)
leaq 0x111a3(%rip), %rdi     # 0x18288
leaq 0x8(%rsp), %rsi
callq 0xbc02
movq %rax, %rbx
testq %rax, %rax
je 0x71cc
leaq 0x8(%rbx), %rsi
leaq 0x111f2(%rip), %rdi     # 0x182f8
callq 0xbbe4
leaq 0x118(%rsp), %r13
addq $0x10, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0x57a2
movl 0x10(%rbx), %edx
movq 0x18(%rbx), %rcx
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x4524
movq %r15, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl 0x4(%rsp), %ecx
callq 0x7f4e
movq %r14, %rdi
callq 0x2f74
leaq 0x118(%rsp), %rdi
callq 0x2f74
leaq 0x60(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movl %ebp, %edx
pushq $0x1
popq %rcx
callq 0x54e6
movq %r14, %rdi
leaq 0x80(%rsp), %rbp
movq %rbp, %rsi
movq %r13, %rdx
callq 0x56ba
movq %r13, %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4ef0
movq %r14, %rdi
callq 0x2f74
movq %r13, %rdi
callq 0x2f74
incl 0x11001(%rip)           # 0x181b8
incl 0x10ff7(%rip)           # 0x181b4
leaq 0x8(%rsp), %rdi
callq 0x2f74
jmp 0x7317
movq %r13, %rdi
movq %r15, %rsi
callq 0x7c7f
testb %al, %al
je 0x72ab
movq %r13, 0x8(%rsp)
leaq 0x11145(%rip), %rdi     # 0x18330
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0xb7bc
movq %r13, 0x8(%rsp)
leaq 0x1120c(%rip), %rdi     # 0x18410
movq %r14, %rsi
callq 0xb374
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rbx
movq %r15, %rdx
callq 0x805b
leaq 0xe0(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movl 0x4(%rsp), %ecx
callq 0x84e9
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movl %ebp, %edx
pushq $0x1
popq %rcx
callq 0x54e6
movq %r13, %r14
leaq 0x60(%rsp), %r13
movq %r13, %rdi
leaq 0x80(%rsp), %rbp
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x56ba
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4ef0
movq %r13, %rdi
callq 0x2f74
movq %rbx, %rdi
callq 0x2f74
incl 0x10f2a(%rip)           # 0x181b8
incl 0x10f20(%rip)           # 0x181b4
movq %r14, %rdi
callq 0x2f74
leaq 0x8(%rsp), %rdi
callq 0x2f74
movq %r13, %rbx
jmp 0x7317
movq %r13, 0x8(%rsp)
leaq 0x11079(%rip), %rdi     # 0x18330
leaq 0x8(%rsp), %rsi
callq 0xb7bc
movq %r13, %rdi
callq 0x7df9
movl %eax, %ebx
movq %rdx, %r14
movq %r13, 0x8(%rsp)
leaq 0x11056(%rip), %rdi     # 0x18330
leaq 0x8(%rsp), %rbp
movq %rbp, %rsi
callq 0xbd0e
movl %ebx, (%rax)
movq %r14, 0x8(%rax)
movq 0x10fe4(%rip), %rbx     # 0x182d8
movq %r13, 0x8(%rsp)
leaq 0x11110(%rip), %rdi     # 0x18410
movq %rbp, %rsi
callq 0xbc3e
movl %ebx, (%rax)
leaq 0xe0(%rsp), %r14
leaq 0x60(%rsp), %rbx
addq $0x10, %r12
jmp 0x6f9d
leaq 0xc0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x57a2
movl 0x40(%rsp), %edx
movq 0x48(%rsp), %rcx
leaq 0x8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x4524
leaq 0x8(%rsp), %rbx
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x511e
movq %rbx, %rdi
callq 0x2f74
leaq 0xc0(%rsp), %rdi
callq 0x2f74
leaq 0x80(%rsp), %rdi
callq 0x2f74
leaq 0xa0(%rsp), %rdi
callq 0x2f74
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x743d
jmp 0x744a
movq %rax, %rbx
jmp 0x745a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x2f74
jmp 0x73e5
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x7433
jmp 0x740c
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
jmp 0x744a
movq %rax, %rbx
jmp 0x7421
movq %rax, %rbx
jmp 0x7438
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x2f74
leaq 0x118(%rsp), %rdi
jmp 0x743d
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x2f74
leaq 0x8(%rsp), %rdi
callq 0x2f74
jmp 0x744d
jmp 0x744a
jmp 0x744a
jmp 0x744a
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x2f74
leaq 0xa0(%rsp), %rdi
callq 0x2f74
movq %rbx, %rdi
callq 0x2260