// File: manschga[P]M5GB/M5GB.cpp
// Function: Check_TGFT(long, signature const&, int)
bool Check_TGFT(const term_int t_, const signature& T, const int generation)//check only from generation to end
{
  for (auto& it : G_conv) 
    {
      //*
      if (t_ == it.first)
	{
	  signature test = it.second.second;//if divisor divides term, then term = divisor*remainderv);//check: needed whole multiple?
	  if (Smaller_sign(test,T)) //check if S(vG) < T
	    {
	      return true;
	    }
	}
    }
  for (auto& it : G_conv)
    {
      if (t_ > it.first && Generations_G.find(t_)->second > generation)
	{
	  if (isDivisible(table[t_].first,it.second.first))
	    {
	      signature test = it.second.second.Multiply(get_remainder(table[t_].first, it.second.first));//if divisor divides term, then term = divisor*remainderv);//check: needed whole multiple?
	      if (Smaller_sign(test,T)) //check if S(vG) < T
		{
		  return true;
		}
	    }
	}
    }
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq 0x29d03(%rip), %rax     # 0x40250
movq %rax, -0x28(%rbp)
leaq 0x29cf8(%rip), %rdi     # 0x40250
callq 0x172e0
movq %rax, -0x30(%rbp)
leaq 0x29ce8(%rip), %rdi     # 0x40250
callq 0x17310
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x17340
testb $0x1, %al
jne 0x16584
jmp 0x165dd
leaq -0x30(%rbp), %rdi
callq 0x17370
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x165d0
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x2a460
testb $0x1, %al
jne 0x165c5
jmp 0x165ce
movb $0x1, -0x1(%rbp)
jmp 0x167f5
jmp 0x165d0
jmp 0x165d2
leaq -0x30(%rbp), %rdi
callq 0x173a0
jmp 0x16571
leaq 0x29c6c(%rip), %rax     # 0x40250
movq %rax, -0x58(%rbp)
leaq 0x29c61(%rip), %rdi     # 0x40250
callq 0x172e0
movq %rax, -0x60(%rbp)
leaq 0x29c51(%rip), %rdi     # 0x40250
callq 0x17310
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x17340
testb $0x1, %al
jne 0x1661e
jmp 0x167f1
leaq -0x60(%rbp), %rdi
callq 0x17370
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rcx
movq -0x70(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0xdd(%rbp)
jle 0x1666c
leaq 0x29dc9(%rip), %rdi     # 0x40410
leaq -0x10(%rbp), %rsi
callq 0x17220
movq %rax, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x17250
movl 0x8(%rax), %eax
cmpl -0x1c(%rbp), %eax
setg %al
movb %al, -0xdd(%rbp)
movb -0xdd(%rbp), %al
testb $0x1, %al
jne 0x1667b
jmp 0x167e1
movq -0x10(%rbp), %rsi
leaq 0x29b5a(%rip), %rdi     # 0x401e0
callq 0xd480
movq %rax, %rdi
movq -0x70(%rbp), %rsi
addq $0x8, %rsi
callq 0x5880
testb $0x1, %al
jne 0x166a4
jmp 0x167df
movq -0x70(%rbp), %rax
addq $0x20, %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x29b22(%rip), %rdi     # 0x401e0
callq 0xd480
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
callq 0x5ff0
movq -0x70(%rbp), %rsi
addq $0x8, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x5ff0
jmp 0x166e8
leaq -0xa0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x262f0
jmp 0x16704
movq -0xe8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xd0c0
movq %rdx, -0xf8(%rbp)
movl %eax, -0xec(%rbp)
jmp 0x16726
movq -0xf8(%rbp), %rax
movl -0xec(%rbp), %ecx
movl %ecx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3b70
leaq -0xd0(%rbp), %rdi
callq 0x3b70
leaq -0xb8(%rbp), %rdi
callq 0x3b70
movq -0x18(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x2a460
testb $0x1, %al
jne 0x16777
jmp 0x167dd
movb $0x1, -0x1(%rbp)
jmp 0x167f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x167cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x167c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3b70
leaq -0xd0(%rbp), %rdi
callq 0x3b70
leaq -0xb8(%rbp), %rdi
callq 0x3b70
jmp 0x16803
jmp 0x167df
jmp 0x167e1
jmp 0x167e3
leaq -0x60(%rbp), %rdi
callq 0x173a0
jmp 0x16608
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0xd8(%rbp), %rdi
callq 0x2300
nop