// File: manschga[P]M5GB/M5GB.cpp
// Function: Init_Spairs(std::vector<Lab_poly, std::allocator<Lab_poly>> const&, std::set<signature, std::less<signature>, std::allocator<signature>>&, std::multimap<signature, std::pair<Lab_poly, int>, std::less<signature>, std::allocator<std::pair<signature const, std::pair<Lab_poly, int>>>>&, int)
Spairs Init_Spairs(const vector<Lab_poly>& F, Signatures& Spol_sign, Spair_map& Spairs_map, int n)
{
  Spairs P = {};
  for (int i = n-1; i < F.size(); ++i)
    {
      for (int j = i+1; j < F.size(); ++j)
	{
	  pair<Lab_poly,Lab_poly> Spair = spair(F[j],F[i]);
	  Spol_sign.insert(spair(F[j],F[i]).first.Get_sign()); //not efficient, only inserted when signature not yet in
	  pair<pair<Lab_poly,int>,pair<Lab_poly,int>> spair_gen = make_pair(make_pair(Spair.first,j+1),make_pair(Spair.second,i+1));//check that, error source?
	  Spairs_map.insert(make_pair(Spair.first.Get_sign(),spair_gen.first));//
	  //Spairs_map.insert(make_pair(spair(F[j],F[i]).first.Get_sign(),spair(F[j],F[i]))); //not efficient, only inserted when signature not yet in
	  //P.insert(spair(F[j],F[i]));
	}
    }

#ifdef PRECISE_DEBUG
  for (auto it = P.begin(); it != P.end(); ++it)
    {
      cout << it->first.Get_sign() << "," <<  it->second.Get_sign() << endl;
    }
#endif
  return P;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x2a0(%rbp)
movq %rdi, %rax
movq %rax, -0x2a8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movb $0x0, -0x25(%rbp)
xorl %esi, %esi
movl $0x30, %edx
callq 0x20e0
movq -0x2a0(%rbp), %rdi
callq 0x16a00
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xbd20
movq %rax, %rcx
movq -0x2b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x15da7
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movslq -0x30(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x10(%rbp), %rdi
callq 0xbd20
movq %rax, %rcx
movq -0x2b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x15d97
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xbdd0
movq %rax, -0x2c0(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0xbdd0
movq -0x2c0(%rbp), %rsi
movq %rax, %rdx
leaq -0xa0(%rbp), %rdi
callq 0xa0a0
jmp 0x15b05
movq -0x18(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xbdd0
movq %rax, -0x2c8(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0xbdd0
movq -0x2c8(%rbp), %rsi
movq %rax, %rdx
leaq -0x120(%rbp), %rdi
callq 0xa0a0
jmp 0x15b49
leaq -0x120(%rbp), %rdi
callq 0xb8d0
movq %rax, -0x2d8(%rbp)
jmp 0x15b5e
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdi
callq 0x17720
movb %dl, -0x2e1(%rbp)
movq %rax, -0x2e0(%rbp)
jmp 0x15b80
movb -0x2e1(%rbp), %al
movq -0x2e0(%rbp), %rcx
movq %rcx, -0x130(%rbp)
movb %al, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x103f0
movl -0x30(%rbp), %eax
incl %eax
movl %eax, -0x1f4(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x1f4(%rbp), %rdx
callq 0x18100
jmp 0x15bcd
leaq -0x68(%rbp), %rsi
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x23c(%rbp)
leaq -0x238(%rbp), %rdi
leaq -0x23c(%rbp), %rdx
callq 0x18100
jmp 0x15bf1
leaq -0x1b0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
leaq -0x238(%rbp), %rdx
callq 0x180c0
jmp 0x15c0d
leaq -0x238(%rbp), %rdi
callq 0x175f0
leaq -0x1f0(%rbp), %rdi
callq 0x175f0
movq -0x20(%rbp), %rax
movq %rax, -0x2f8(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xb8d0
movq %rax, -0x2f0(%rbp)
jmp 0x15c45
movq -0x2f0(%rbp), %rsi
leaq -0x290(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x177a0
jmp 0x15c61
movq -0x2f8(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x17770
movq %rax, -0x300(%rbp)
jmp 0x15c7d
movq -0x300(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x177e0
leaq -0x1b0(%rbp), %rdi
callq 0x176f0
leaq -0xa0(%rbp), %rdi
callq 0x103f0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x15aa5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x15dcd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x15d89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x103f0
jmp 0x15d89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x15d3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x175f0
leaq -0x1f0(%rbp), %rdi
callq 0x175f0
jmp 0x15d89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x15d7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x177e0
leaq -0x1b0(%rbp), %rdi
callq 0x176f0
leaq -0xa0(%rbp), %rdi
callq 0x103f0
jmp 0x15dcd
jmp 0x15d99
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x15a75
movb $0x1, -0x25(%rbp)
testb $0x1, -0x25(%rbp)
jne 0x15dbd
movq -0x2a0(%rbp), %rdi
callq 0x16a20
movq -0x2a8(%rbp), %rax
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq -0x2a0(%rbp), %rdi
callq 0x16a20
movq -0xa8(%rbp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)