// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r13
cmpl $0x1, %edi
jne 0x3478c
leaq 0x651a1(%rip), %r14     # 0x99900
pushq $0x8
popq %rdi
pushq $0x4
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, %r15
pushq $0x4
popq %rdi
pushq $0x5
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, (%r15)
andl $0x0, (%rax)
pushq $0x1
popq %rax
jmp 0x348b5
movl %edi, %r14d
leal -0x1(%r14), %edi
movl %edi, 0xc(%rsp)
movq %r13, %rsi
callq 0x34742
movslq (%r13), %rsi
movslq %r14d, %rbx
imulq %rbx, %rsi
shlq $0x3, %rsi
movq %rax, %rdi
movl %r14d, %edx
callq 0x34f30
movq %rax, %r15
movq %rbx, 0x20(%rsp)
leaq (,%rbx,4), %rax
movq %rax, 0x10(%rsp)
xorl %ebx, %ebx
movq %r15, 0x18(%rsp)
movslq (%r13), %rax
cmpq %rax, %rbx
jge 0x3486b
xorl %ebp, %ebp
pushq $0x1
popq %r12
cmpq 0x20(%rsp), %r12
jge 0x3485e
movq %r13, %r15
movl (%r13), %r13d
imull %r12d, %r13d
addl %ebx, %r13d
movq 0x10(%rsp), %rdi
leaq 0x650f7(%rip), %rsi     # 0x99900
pushq $0x11
popq %rdx
callq 0x34f59
movslq %r13d, %rcx
movq 0x18(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
movq (%rdx,%rbx,8), %rcx
xorl %edx, %edx
cmpq %rdx, %r12
je 0x34833
movl (%rcx,%rdx,4), %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
jmp 0x34823
movq %rbp, %rdx
movq %r15, %r13
leal 0x2(%rdx), %esi
cmpl %r14d, %esi
jge 0x3484e
movl 0x4(%rcx,%rdx,4), %esi
movl %esi, 0x8(%rax,%rdx,4)
incq %rdx
jmp 0x34839
movl 0xc(%rsp), %ecx
movl %ecx, (%rax,%r12,4)
incq %r12
incq %rbp
jmp 0x347e8
incq %rbx
movq 0x18(%rsp), %r15
jmp 0x347d5
movl 0xc(%rsp), %ebx
xorl %r12d, %r12d
movslq %eax, %rcx
cmpq %rcx, %r12
jge 0x348b1
movq (%r15,%r12,8), %rdi
movq 0x10(%rsp), %rsi
movl %r14d, %edx
callq 0x34f30
movq %rax, (%r15,%r12,8)
movq %rbx, %rcx
testl %ecx, %ecx
jle 0x348a2
movl -0x4(%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
decq %rcx
jmp 0x34892
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
incq %r12
movl (%r13), %eax
jmp 0x34872
imull %r14d, %eax
movl %eax, (%r13)
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq