// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/libiteration.c
// Function: generate_permutations
int** generate_permutations(int howmany, int*total)
{
 /*!Last Changed 27.04.2004*/
 int **result, i, j, k, index;
 if (howmany == 1)
  {
   result = safemalloc(sizeof(int *), "generate_permutations", 4);
   result[0] = safemalloc(sizeof(int), "generate_permutations", 5);
   result[0][0] = 0;
   *total = 1;
  }
 else
  {
   result = generate_permutations(howmany - 1, total);
   result = alloc(result, (*total) * howmany * sizeof(int *), howmany);
   for (i = 0; i < *total; i++)
     for (j = 1; j < howmany; j++)
      {
       index = (*total)*j + i; 
       result[index] = safemalloc(howmany * sizeof(int), "generate_permutations", 17);
       for (k = 0; k < j; k++)
         result[index][k] = result[i][k];
       for (k = j + 1; k < howmany; k++)
         result[index][k] = result[i][k - 1];
       result[index][j] = howmany - 1;
      }
   for (i = 0; i < *total; i++)
    {
     result[i] = alloc(result[i], howmany * sizeof(int), howmany);
     for (j = howmany - 1; j > 0; j--)
       result[i][j] = result[i][j - 1];
     result[i][0] = howmany - 1;
    }
   *total *= howmany;
  }
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x1, -0x4(%rbp)
jne 0x51d5b
movl $0x8, %edi
leaq 0x94829(%rip), %rsi     # 0xe653a
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x18(%rbp)
movl $0x4, %edi
leaq 0x9480f(%rip), %rsi     # 0xe653a
movl $0x5, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
jmp 0x51f62
movl -0x4(%rbp), %edi
subl $0x1, %edi
movq -0x10(%rbp), %rsi
callq 0x51cf0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %eax
imull -0x4(%rbp), %eax
movslq %eax, %rsi
shlq $0x3, %rsi
movl -0x4(%rbp), %edx
callq 0x52d10
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x51eae
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x51e9e
movq -0x10(%rbp), %rax
movl (%rax), %eax
imull -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
movslq -0x4(%rbp), %rdi
shlq $0x2, %rdi
leaq 0x94763(%rip), %rsi     # 0xe653a
movl $0x11, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x51e30
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x51df7
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x51e77
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x51e39
movl -0x4(%rbp), %edx
subl $0x1, %edx
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x51dac
jmp 0x51ea0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x51d96
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x51f56
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x4(%rbp), %rsi
shlq $0x2, %rsi
movl -0x4(%rbp), %edx
callq 0x52d10
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x4(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jle 0x51f34
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x51ef8
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x51eb5
movl -0x4(%rbp), %ecx
movq -0x10(%rbp), %rax
imull (%rax), %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)