// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/eis-seqblocktranslate.c
// Function: nextPermutation
static void
nextPermutation(Symbol *permutation, unsigned blockSize)
{
  /*
   * Every permutation represents a leaf in the decision tree
   * generating all permutations, thus given one permutation, we
   * ascend in the tree until we can make a decision resulting in a
   * lexically larger value.
   */
  unsigned upLvl = blockSize - 1;
  {
    Symbol maxSymInSuf = permutation[blockSize - 1];
    do
    {
      if (upLvl == 0 || maxSymInSuf > permutation[--upLvl])
        break;
      if (permutation[upLvl] > maxSymInSuf)
        maxSymInSuf = permutation[upLvl];
    } while (1);
  }
  /* now that we have found the branch point, descend again,
   * selecting first the next largest symbol */
  {
    Symbol saved = permutation[upLvl];
    Symbol swap = permutation[upLvl + 1];
    unsigned swapIdx = upLvl + 1;
    unsigned i;
    for (i = swapIdx + 1; i < blockSize; ++i)
    {
      if (permutation[i] > saved && permutation[i] < swap)
        swap = permutation[i], swapIdx = i;
    }
    permutation[upLvl] = swap;
    permutation[swapIdx] = saved;
  }
  for (++upLvl;upLvl < blockSize - 1; ++upLvl)
  {
    /* find minimal remaining symbol */
    unsigned i, minIdx = upLvl;
    Symbol minSym = permutation[upLvl];
    for (i = upLvl + 1; i < blockSize; ++i)
      if (permutation[i] < minSym)
        minSym = permutation[i], minIdx = i;
    permutation[minIdx] = permutation[upLvl];
    permutation[upLvl] = minSym;
  }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movl -0xc(%rsp), %eax
subl $0x1, %eax
movl %eax, -0x10(%rsp)
movq -0x8(%rsp), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x11(%rsp)
cmpl $0x0, -0x10(%rsp)
je 0x4afa4f
movzbl -0x11(%rsp), %eax
movq -0x8(%rsp), %rcx
movl -0x10(%rsp), %edx
addl $-0x1, %edx
movl %edx, -0x10(%rsp)
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jle 0x4afa51
jmp 0x4afa81
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x11(%rsp), %ecx
cmpl %ecx, %eax
jle 0x4afa77
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x11(%rsp)
jmp 0x4afa79
movb $0x1, %al
testb $0x1, %al
jne 0x4afa29
jmp 0x4afa81
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x12(%rsp)
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x13(%rsp)
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rsp)
movl -0x1c(%rsp), %eax
cmpl -0xc(%rsp), %eax
jae 0x4afb19
movq -0x8(%rsp), %rax
movl -0x1c(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x12(%rsp), %ecx
cmpl %ecx, %eax
jle 0x4afb0a
movq -0x8(%rsp), %rax
movl -0x1c(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x13(%rsp), %ecx
cmpl %ecx, %eax
jge 0x4afb0a
movq -0x8(%rsp), %rax
movl -0x1c(%rsp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x13(%rsp)
movl -0x1c(%rsp), %eax
movl %eax, -0x18(%rsp)
jmp 0x4afb0c
movl -0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rsp)
jmp 0x4afabc
movb -0x13(%rsp), %dl
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
movb %dl, (%rax,%rcx)
movb -0x12(%rsp), %dl
movq -0x8(%rsp), %rax
movl -0x18(%rsp), %ecx
movb %dl, (%rax,%rcx)
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
movl -0x10(%rsp), %eax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x4afbf9
movl -0x10(%rsp), %eax
movl %eax, -0x24(%rsp)
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x25(%rsp)
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rsp)
movl -0x20(%rsp), %eax
cmpl -0xc(%rsp), %eax
jae 0x4afbc1
movq -0x8(%rsp), %rax
movl -0x20(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x25(%rsp), %ecx
cmpl %ecx, %eax
jge 0x4afbb2
movq -0x8(%rsp), %rax
movl -0x20(%rsp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x25(%rsp)
movl -0x20(%rsp), %eax
movl %eax, -0x24(%rsp)
jmp 0x4afbb4
movl -0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rsp)
jmp 0x4afb7a
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
movb (%rax,%rcx), %dl
movq -0x8(%rsp), %rax
movl -0x24(%rsp), %ecx
movb %dl, (%rax,%rcx)
movb -0x25(%rsp), %dl
movq -0x8(%rsp), %rax
movl -0x10(%rsp), %ecx
movb %dl, (%rax,%rcx)
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
jmp 0x4afb44
retq
nopw (%rax,%rax)