// File: manschga[P]M5GB/other_fct.cpp
// Function: Create_table(int, int)
vector<pair<term_vec,vector<term_int>>> Create_table(int n, int d)//multiplication table
{
  vector<pair<term_vec,vector<term_int>>> table = {};
  term_int max_size = binom(n+d-1,n)+1;
  table.reserve(max_size);
  term_vec term(n,0);
  vector<term_int> multis(n,0);
  for (int j = 0; j < n; ++j)
    {
      multis[j] = n-j;
    }
  table.emplace_back(make_pair(term,multis));
  for (term_int i = 1; i < max_size; ++i)
    {
      next_term(term);
      for (int j = 1; j <= n; ++j)
	{
	  term_vec term_xj = vector_add(term,j); //new term = term*x_j
	  multis[j-1] = term_to_int(term_xj,n)-1; //might be too slow!,
	  //check for over size!
	}
      table.emplace_back(make_pair(term,multis));
    }
  return table;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x120(%rbp)
movq %rdi, %rax
movq %rax, -0x128(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x5eb0
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %eax
movl %eax, %ecx
movl %esi, %eax
leal -0x1(%rax,%rcx), %edi
callq 0x50b0
movq -0x120(%rbp), %rdi
incl %eax
cltq
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
callq 0x6260
jmp 0x596a
movslq -0xc(%rbp), %rax
movq %rax, -0x138(%rbp)
movl $0x0, -0x4c(%rbp)
leaq -0x4d(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x5f30
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rcx
leaq -0x48(%rbp), %rdi
leaq -0x4c(%rbp), %rdx
callq 0x5f50
jmp 0x59a9
leaq -0x4d(%rbp), %rdi
callq 0x3d50
movslq -0xc(%rbp), %rax
movq %rax, -0x148(%rbp)
movq $0x0, -0x70(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x6360
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rcx
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x6380
jmp 0x59f2
leaq -0x71(%rbp), %rdi
callq 0x3670
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x5a80
movl -0xc(%rbp), %eax
subl -0x78(%rbp), %eax
cltq
movq %rax, -0x150(%rbp)
movslq -0x78(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x61c0
movq -0x150(%rbp), %rcx
movq %rcx, (%rax)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x5a02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x5c8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x4d(%rbp), %rdi
callq 0x3d50
jmp 0x5c8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x3670
jmp 0x5c63
leaq -0xa8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x6480
jmp 0x5a96
movq -0x120(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x6400
jmp 0x5aab
leaq -0xa8(%rbp), %rdi
callq 0x3b40
movq $0x1, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x5c3c
leaq -0x48(%rbp), %rdi
callq 0x5ca0
jmp 0x5ade
movl $0x1, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x5bd4
movl -0xb4(%rbp), %edx
leaq -0xd0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5e40
jmp 0x5b0f
leaq -0xe8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x5ff0
jmp 0x5b24
movl -0xc(%rbp), %esi
leaq -0xe8(%rbp), %rdi
callq 0x5250
subq $0x1, %rax
movq %rax, -0x158(%rbp)
movl -0xb4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x61c0
movq -0x158(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xe8(%rbp), %rdi
callq 0x3b70
leaq -0xd0(%rbp), %rdi
callq 0x3b70
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x5ae8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x5c5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3b40
jmp 0x5c5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x3b70
jmp 0x5c5a
leaq -0x118(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x6480
jmp 0x5bea
movq -0x120(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x6400
jmp 0x5bff
leaq -0x118(%rbp), %rdi
callq 0x3b40
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x5ac2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3b40
jmp 0x5c5a
movb $0x1, -0x11(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3490
leaq -0x48(%rbp), %rdi
callq 0x3b70
testb $0x1, -0x11(%rbp)
jne 0x5c7a
jmp 0x5c6e
leaq -0x68(%rbp), %rdi
callq 0x3490
leaq -0x48(%rbp), %rdi
callq 0x3b70
jmp 0x5c8a
movq -0x120(%rbp), %rdi
callq 0x3040
movq -0x128(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x120(%rbp), %rdi
callq 0x3040
movq -0x28(%rbp), %rdi
callq 0x2300
nop