// File: /workspace/github_cpp_makefile_star2_O2/manschga[P]M5GB/M5GB.cpp
// Function: Div_by_M(long, signature const&)
Lab_poly Div_by_M(const term_int t, const signature& T)
{
  g_reduced++;
  Lab_poly current = Lab_poly();
  polynomial Old_M = polynomial();
  bool m_found = false;
  vector<int> t_ = table[t].first;
    if (!m_found)
    {
      for (auto& it : LT_M) 
	{
	  if (isDivisible(table[t].first,table[it.first].first))
	    {
	      term_vec v = get_remainder(table[t].first, table[it.first].first);//if divisor divides term, then term = divisor*remainder);
	      signature test = it.second.Multiply(v);
	      if (Smaller_sign(test,T)) //check if S(vG) < T
		{
		  m_found = true;
		  polynomial New_M = M.find(it.first)->second;
		  //Lab_poly candidate(G_.find(it.first)->second.Multiply(v),test);
		  if (is_more_reduced(New_M,Old_M)) //check different criteria
		    {
		      current = Lab_poly(New_M.Multiply(v),test);
		      Old_M = New_M;
		      //return candidate;
		    }
		}
	    }
	}
    }
    if (!m_found)
    {
      for (auto& it : LT_G) 
	{
	  if (isDivisible(table[t].first,table[it.first].first))
	    {
	      term_vec v = get_remainder(table[t].first, table[it.first].first);//if divisor divides term, then term = divisor*remainder);
	      signature test = it.second.Multiply(v);
	      if (Smaller_sign(test,T)) //check if S(vG) < T
		{
		  m_found = true;
		  polynomial New_M = G_.find(it.first)->second;
		  //Lab_poly candidate(G_.find(it.first)->second.Multiply(v),test);
		  if (is_more_reduced(New_M,Old_M)) //check different criteria
		    {
		      current = Lab_poly(New_M.Multiply(v),test);
		      Old_M = New_M;
		      //return candidate;
		    }
		}
	    }
	}
      }
  return current;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdx, 0x30(%rsp)
movq %rsi, %rbx
incl 0x1014a(%rip)           # 0x181c4
movq %rdi, 0x8(%rsp)
callq 0x44b4
leaq 0x70(%rsp), %rdi
callq 0xd51a
leaq 0x100db(%rip), %rax     # 0x18170
imulq $0x30, %rbx, %rcx
movq (%rax), %rsi
movq %rcx, 0x10(%rsp)
addq %rcx, %rsi
leaq 0xb0(%rsp), %rdi
callq 0x3a1a
leaq 0x101e0(%rip), %r15     # 0x18298
xorl %r14d, %r14d
leaq 0xf8(%rsp), %rdi
leaq 0x98(%rsp), %r12
leaq 0x130(%rsp), %rcx
leaq 0x150(%rsp), %rdx
leaq 0x1008e(%rip), %rax     # 0x18170
movq (%r15), %r15
testq %r15, %r15
je 0x827a
movq %rdx, %rbp
movq %rcx, %rbx
movq %rdi, %r13
movq (%rax), %rax
movq 0x10(%rsp), %rcx
leaq (%rax,%rcx), %rdi
imulq $0x30, 0x8(%r15), %rsi
addq %rax, %rsi
callq 0x36f2
testb %al, %al
movq %r13, %rdi
leaq 0x10054(%rip), %rax     # 0x18170
movq %rbx, %rcx
movq %rbp, %rdx
je 0x80e2
movl %r14d, 0x28(%rsp)
movq (%rax), %rsi
addq 0x10(%rsp), %rsi
movq %rax, %r14
callq 0x3a1a
leaq 0x8(%r15), %rax
movq %rax, 0x90(%rsp)
imulq $0x30, (%rax), %rsi
addq (%r14), %rsi
movq %r12, %rdi
callq 0x3a1a
leaq 0x58(%rsp), %rdi
movq %r13, %r14
movq %r13, %rsi
movq %r12, %rdx
callq 0xd81b
movq %r12, %rdi
callq 0x2dfe
movq %r14, %rdi
callq 0x2dfe
leaq 0x10(%r15), %rdi
leaq 0x58(%rsp), %rsi
callq 0x538a
leaq 0x18(%rsp), %rdi
movl %eax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq 0x30(%rsp), %rsi
callq 0xebf9
testb %al, %al
leaq 0x98(%rsp), %r12
movl 0x28(%rsp), %r14d
je 0x825b
leaq 0x1013f(%rip), %rdi     # 0x182f8
movq 0x90(%rsp), %rsi
callq 0xbbe4
addq $0x10, %rax
leaq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x57a2
movq 0x70(%rsp), %rax
cmpq %rax, 0x78(%rsp)
je 0x81ee
movq 0x38(%rsp), %rcx
movl (%rcx), %ecx
cmpl (%rax), %ecx
jge 0x824e
movq %rbx, %r14
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x52fe
movl 0x18(%rsp), %edx
movq 0x20(%rsp), %rcx
movq %rbp, %r12
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4524
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x511e
movq %r12, %rdi
callq 0x2f74
movq %r14, %rdi
callq 0x2f74
leaq 0x70(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x4f12
leaq 0x98(%rsp), %r12
leaq 0x38(%rsp), %rdi
callq 0x2f74
movb $0x1, %r14b
leaq 0x58(%rsp), %rdi
callq 0x2dfe
movq %r13, %rdi
leaq 0xff01(%rip), %rax      # 0x18170
movq %rbx, %rcx
movq %rbp, %rdx
jmp 0x80e2
testb $0x1, %r14b
je 0x82ae
leaq 0xb0(%rsp), %rdi
callq 0x2dfe
leaq 0x70(%rsp), %rdi
callq 0x2f74
movq 0x8(%rsp), %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xffab(%rip), %r15      # 0x18260
leaq 0xe0(%rsp), %r13
leaq 0xc8(%rsp), %rbx
leaq 0x58(%rsp), %r12
leaq 0x110(%rsp), %r14
leaq 0x150(%rsp), %rbp
movq (%r15), %r15
testq %r15, %r15
je 0x8280
movq (%rax), %rax
movq 0x10(%rsp), %rcx
leaq (%rax,%rcx), %rdi
imulq $0x30, 0x8(%r15), %rsi
addq %rax, %rsi
callq 0x36f2
testb %al, %al
leaq 0xfe6c(%rip), %rax      # 0x18170
je 0x82da
movq %r13, %rdi
movq (%rax), %rsi
addq 0x10(%rsp), %rsi
callq 0x3a1a
leaq 0x8(%r15), %rax
movq %rax, 0x28(%rsp)
imulq $0x30, (%rax), %rsi
leaq 0xfe46(%rip), %rax      # 0x18170
addq (%rax), %rsi
movq %rbx, %rdi
callq 0x3a1a
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0xd81b
movq %rbx, %rdi
callq 0x2dfe
movq %r13, %rdi
callq 0x2dfe
leaq 0x10(%r15), %rdi
movq %r12, %rsi
callq 0x538a
movl %eax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
leaq 0x18(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0xebf9
testb %al, %al
je 0x8412
leaq 0xff3a(%rip), %rdi      # 0x182c0
movq 0x28(%rsp), %rsi
callq 0xbbe4
addq $0x10, %rax
leaq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x57a2
movq 0x70(%rsp), %rax
cmpq %rax, 0x78(%rsp)
je 0x83b8
movq 0x38(%rsp), %rcx
movl (%rcx), %ecx
cmpl (%rax), %ecx
jge 0x8408
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
movq %r12, %rdx
callq 0x52fe
movl 0x18(%rsp), %edx
movq 0x20(%rsp), %rcx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4524
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x511e
movq %rbp, %rdi
callq 0x2f74
movq %r14, %rdi
callq 0x2f74
leaq 0x70(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x4f12
leaq 0x38(%rsp), %rdi
callq 0x2f74
movq %r12, %rdi
callq 0x2dfe
leaq 0xfd4f(%rip), %rax      # 0x18170
jmp 0x82da
jmp 0x847a
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
jmp 0x8473
jmp 0x847a
jmp 0x84ac
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x2dfe
jmp 0x844e
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0x84b4
jmp 0x84bd
movq %rax, %rbx
jmp 0x84cd
movq %rax, %rbx
jmp 0x84d7
jmp 0x84ac
jmp 0x847a
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x2f74
jmp 0x847d
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x2f74
jmp 0x84af
movq %rax, %rbx
jmp 0x84a2
jmp 0x84ac
jmp 0x84bd
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x2dfe
leaq 0xe0(%rsp), %rdi
jmp 0x84b4
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x2dfe
jmp 0x84c0
jmp 0x84bd
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x2dfe
leaq 0x70(%rsp), %rdi
callq 0x2f74
movq 0x8(%rsp), %rdi
callq 0x2f74
movq %rbx, %rdi
callq 0x2260