// File: /workspace/github_cpp_makefile_star2_O3/manschga[P]M5GB/M5GB.cpp
// Function: Low_pol(signature const&, Lab_poly const&, int, int)
Lab_poly Low_pol(const signature& smallest_sign, const Lab_poly& uF, const int generation, int n)
{
  term_int LT_low = 0;
  term_int remainder_low = 0;
  Lab_poly Low = uF;
  bool not_yet = true;
#ifdef LARGEST_LT //no sense to do largest lt heuristic here
  return uF;
#endif
  for (auto& it : LT_M)
    {
      if (smallest_sign.Get_index() == it.second.Get_index())
	{
	  if (isDivisible(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first))
	    {
	      polynomial test = M.find(it.first)->second.Multiply(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first));
	      
#ifdef LARGE_GEN
	      if (not_yet) //still uF is best
		{

	       if (Generations_G.find(it.first)->second > generation) //different heuristics to check
		    {
		      not_yet = false;
		      Low = Lab_poly(test,smallest_sign);
		      LT_low = it.first;
		    }
		}
	      else
		{
		  if (Generations_G.find(it.first)->second > Generations_G.find(LT_low)->second) //different heuristics to check
		     {
		       Low = Lab_poly(test,smallest_sign);
		       LT_low = it.first;
		     }
		}
#endif
	      //*
#ifdef NUMBER_OF_TERMS
	      if (not_yet) //still uF is best
		{
		  if (test.size() <= uF.Get_poly().size()) //different heuristics to check
		    {
		      not_yet = false;
		      Low = Lab_poly(test,smallest_sign);
		      LT_low = it.first;
		    }
		}
	      else
		{
		  if (test.size() < Low.Get_poly().size()) //different heuristics to check
		     {
		       Low = Lab_poly(test,smallest_sign);
		       LT_low = it.first;
		     }
		}
#endif
	      //*/
#ifdef SMALLEST_REMAINDER
	      if (not_yet) //still uF is best
		{
		  if (test.size() < uF.Get_poly().size()) //different heuristics to check
		    {
		      not_yet = false;
		      Low = Lab_poly(test,smallest_sign);
		      LT_low = it.first;
		      remainder_low = term_to_int(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first),n);
		    }
		}
	      else
		{
		  if(term_to_int(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first),n) > remainder_low)
		    {
		       Low = Lab_poly(test,smallest_sign);
		       LT_low = it.first;
		       remainder_low = term_to_int(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first),n);
		     }
		}
#endif
#ifdef SMALLEST_LT
	      if (not_yet) //still uF is best
		{
		  if (test.Get_LT() <= uF.Get_LT()) //different heuristics to check
		    {
		      not_yet = false;
		      Low = Lab_poly(test,smallest_sign);
		      LT_low = it.first;
		    }
		}
	      else
		{
		  if (test.Get_LT() <= Low.Get_LT()) //different heuristics to check
		     {
		       Low = Lab_poly(test,smallest_sign);
		       LT_low = it.first;
		     }
		}
#endif
	    }
	}
    }
	  return Low;
	  /*

  
  for (auto& it : LT_M) 
    {
      if (Lab_pol_M.find(it.first)->second == true) //check if correct label!
	{
      if (smallest_sign.Get_index() == it.second.Get_index())
	{
	  if (isDivisible(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first))
	    {
	      polynomial test = M.find(it.first)->second.Multiply(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first));
#ifdef high_gen
	      if (not_yet) //still uF is best
		{

	       if (Generations_M.find(it.first)->second > generation) //different heuristics to check
		    {
		      not_yet = false;
		      Low = Lab_poly(test,smallest_sign);
		      LT_low = it.first;
		    }
		}
	      else
		{
		  if (Generations_M.find(it.first)->second > Generations_M.find(LT_low)->second) //different heuristics to check
		     {
		       Low = Lab_poly(test,smallest_sign);
		       LT_low = it.first;
		     }
		}
#endif

#ifdef smallest_size
	      if (not_yet) //still uF is best
		{
		  if (test.size() <= uF.Get_poly().size()) //different heuristics to check
		    {
		      not_yet = false;
		      Low = Lab_poly(test,smallest_sign);
		      LT_low = it.first;
		    }
		}
	      else
		{
		  if (test.size() < Low.Get_poly().size()) //different heuristics to check
		     {
		       Low = Lab_poly(test,smallest_sign);
		       LT_low = it.first;
		     }
		}
#endif
#ifdef smallest_remainder
	      if (not_yet) //still uF is best
		{
		  if (test.size() <= uF.Get_poly().size()) //different heuristics to check
		    {
		      not_yet = false;
		      Low = Lab_poly(test,smallest_sign);
		      LT_low = it.first;
		      remainder_low = term_to_int(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first),n);
		    }
		}
	      else
		{
		  if(term_to_int(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first),n) > remainder_low)
		    {
		       Low = Lab_poly(test,smallest_sign);
		       LT_low = it.first;
		       remainder_low = term_to_int(get_remainder(table[smallest_sign.Get_term()].first,table[it.second.Get_term()].first),n);
		     }
		}
#endif
	    }
	    }
	}
    }
  return Low;
	  */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rdx, %rsi
callq 0x68a4
movl 0x18(%r14), %eax
movl %eax, 0x18(%rbx)
movl 0x30(%r14), %eax
movl %eax, 0x30(%rbx)
movq %r14, 0x80(%rsp)
movups 0x20(%r14), %xmm0
movq %rbx, 0x8(%rsp)
movups %xmm0, 0x20(%rbx)
movq 0x1188d(%rip), %rbp     # 0x1a2a0
testq %rbp, %rbp
je 0x8da6
movq 0x8(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x18(%rsp)
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0x11739(%rip), %rcx     # 0x1a170
leaq 0x20(%rsp), %r12
movq %r15, 0x10(%rsp)
movl (%r15), %eax
cmpl 0x10(%rbp), %eax
jne 0x8d99
movq 0x8(%r15), %rax
movq %rcx, %r15
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %rcx, %rdi
movq 0x18(%rbp), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
addq %rcx, %rsi
callq 0x3bf9
testb %al, %al
je 0x8d91
movq %r12, %r14
leaq 0x8(%rbp), %rsi
leaq 0x11874(%rip), %rdi     # 0x1a300
callq 0xed1a
movq %rax, %r13
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
movq %r15, %r12
addq (%r15), %rsi
leaq 0x88(%rsp), %rdi
callq 0x4214
movq 0x18(%rbp), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
addq (%r12), %rsi
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x4214
movq %r14, %rdi
leaq 0x88(%rsp), %rsi
movq %rbx, %rdx
callq 0x10d0f
addq $0x10, %r13
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x6780
movq %r14, %r12
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x8b19
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x8b36
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x8b53
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
shrq $0x4, %rax
testb $0x1, 0x4(%rsp)
je 0x8c41
movq 0x80(%rsp), %rdx
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
shrq $0x4, %rcx
movb $0x1, %dl
movl %edx, 0x4(%rsp)
cmpl %ecx, %eax
jg 0x8d7a
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0x68a4
movl 0x78(%rsp), %eax
movl %eax, 0xf0(%rsp)
movq 0x10(%rsp), %rax
movl (%rax), %edx
movq 0x8(%rax), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x50f8
movq 0x8(%rsp), %r14
movq (%r14), %rdi
movq 0x10(%r14), %rsi
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r14)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x8d02
subq %rdi, %rsi
callq 0x2180
movq 0x20(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, 0x18(%r14)
leaq 0x40(%rsp), %rdx
movl 0x10(%rdx), %eax
movq 0x18(%rsp), %rcx
movl %eax, 0x10(%rcx)
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
testq %rdi, %rdi
je 0x8d20
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8d20
movq 0x8(%rsp), %rdx
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
shrq $0x4, %rcx
cmpl %ecx, %eax
jge 0x8d72
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0x68a4
movl 0x78(%rsp), %eax
movl %eax, 0xd0(%rsp)
movq 0x10(%rsp), %rax
movl (%rax), %edx
movq 0x8(%rax), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x50f8
movq 0x8(%rsp), %r14
movq (%r14), %rdi
movq 0x10(%r14), %rsi
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r14)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x8d37
subq %rdi, %rsi
callq 0x2180
movq 0x20(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, 0x18(%r14)
leaq 0x40(%rsp), %rdx
movl 0x10(%rdx), %eax
movq 0x18(%rsp), %rcx
movl %eax, 0x10(%rcx)
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
testq %rdi, %rdi
je 0x8d55
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8d55
movl 0x38(%rsp), %eax
movl %eax, 0x18(%r14)
leaq 0x40(%rsp), %rdx
movl 0x10(%rdx), %eax
movq 0x18(%rsp), %rcx
movl %eax, 0x10(%rcx)
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8d72
movq 0xe8(%rsp), %rsi
jmp 0x8d6a
movl 0x38(%rsp), %eax
movl %eax, 0x18(%r14)
leaq 0x40(%rsp), %rdx
movl 0x10(%rdx), %eax
movq 0x18(%rsp), %rcx
movl %eax, 0x10(%rcx)
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x8d72
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movl $0x0, 0x4(%rsp)
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x8d91
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %r15, %rcx
movq 0x10(%rsp), %r15
movq (%rbp), %rbp
testq %rbp, %rbp
jne 0x8a41
movq 0x8(%rsp), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8dfe
movq 0xe8(%rsp), %rsi
jmp 0x8df1
jmp 0x8dfb
movq %rax, %r14
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x8dfe
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8dfe
movq %rax, %r14
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x8e76
movq 0x70(%rsp), %rsi
jmp 0x8e69
jmp 0x8e73
jmp 0x8e73
movq %rax, %r14
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x8e32
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8e32
movq %rax, %r14
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x8e54
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8e54
movq %rax, %r14
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x8e76
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x8e76
movq %rax, %r14
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x8e94
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2180
movq %r14, %rdi
callq 0x2240