// File: readmapping[P]alfalfa/src/qsufsort.c
// Function: transform
static int transform(int *x, int *p, int n, int k, int l, int q)
{
   int b, c, d, e, i, j, m, s;
   int *pi, *pj;

   for (s=0, i=k-l; i; i>>=1)
      ++s;                      /* s is number of bits in old symbol.*/
   e=INT_MAX>>s;                /* e is for overflow checking.*/
   for (b=d=r=0; r<n && d<=e && (c=d<<s|(k-l))<=q; ++r) {
      b=b<<s|(x[r]-l+1);        /* b is start of x in chunk alphabet.*/
      d=c;                      /* d is max symbol in chunk alphabet.*/
   }
   m=(1<<(r-1)*s)-1;            /* m masks off top old symbol from chunk.*/
   x[n]=l-1;                    /* emulate zero terminator.*/
   if (d<=n) {                  /* if bucketing possible, compact alphabet.*/
      for (pi=p; pi<=p+d; ++pi)
         *pi=0;                 /* zero transformation table.*/
      for (pi=x+r, c=b; pi<=x+n; ++pi) {
         p[c]=1;                /* mark used chunk symbol.*/
         c=(c&m)<<s|(*pi-l+1);  /* shift in next old symbol in chunk.*/
      }
      for (i=1; i<r; ++i) {     /* handle last r-1 positions.*/
         p[c]=1;                /* mark used chunk symbol.*/
         c=(c&m)<<s;            /* shift in next old symbol in chunk.*/
      }
      for (pi=p, j=1; pi<=p+d; ++pi)
         if (*pi)
            *pi=j++;            /* j is new alphabet size.*/
      for (pi=x, pj=x+r, c=b; pj<=x+n; ++pi, ++pj) {
         *pi=p[c];              /* transform to new alphabet.*/
         c=(c&m)<<s|(*pj-l+1);  /* shift in next old symbol in chunk.*/
      }
      while (pi<x+n) {          /* handle last r-1 positions.*/
         *pi++=p[c];            /* transform to new alphabet.*/
         c=(c&m)<<s;            /* shift right-end zero in chunk.*/
      }
   } else {                     /* bucketing not possible, don't compact.*/
      for (pi=x, pj=x+r, c=b; pj<=x+n; ++pi, ++pj) {
         *pi=c;                 /* transform to new alphabet.*/
         c=(c&m)<<s|(*pj-l+1);  /* shift in next old symbol in chunk.*/
      }
      while (pi<x+n) {          /* handle last r-1 positions.*/
         *pi++=c;               /* transform to new alphabet.*/
         c=(c&m)<<s;            /* shift right-end zero in chunk.*/
      }
      j=d+1;                    /* new alphabet size.*/
   }
   x[n]=0;                      /* end-of-string symbol is zero.*/
   return j;                    /* return new alphabet size.*/
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movl %edx, -0x14(%rsp)
movl %ecx, -0x18(%rsp)
movl %r8d, -0x1c(%rsp)
movl %r9d, -0x20(%rsp)
movl $0x0, -0x40(%rsp)
movl -0x18(%rsp), %eax
subl -0x1c(%rsp), %eax
movl %eax, -0x34(%rsp)
cmpl $0x0, -0x34(%rsp)
je 0x7251e
movl -0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rsp)
movl -0x34(%rsp), %eax
sarl %eax
movl %eax, -0x34(%rsp)
jmp 0x72500
movl -0x40(%rsp), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
sarl %cl, %eax
movl %eax, -0x30(%rsp)
movl $0x0, 0x24fdd(%rip)     # 0x97514
movl $0x0, -0x2c(%rsp)
movl $0x0, -0x24(%rsp)
movl 0x24fc7(%rip), %ecx     # 0x97514
xorl %eax, %eax
cmpl -0x14(%rsp), %ecx
movb %al, -0x51(%rsp)
jge 0x7258c
movl -0x2c(%rsp), %ecx
xorl %eax, %eax
cmpl -0x30(%rsp), %ecx
movb %al, -0x51(%rsp)
jg 0x7258c
movl -0x2c(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movl -0x18(%rsp), %ecx
subl -0x1c(%rsp), %ecx
orl %ecx, %eax
movl %eax, -0x28(%rsp)
cmpl -0x20(%rsp), %eax
setle %al
movb %al, -0x51(%rsp)
movb -0x51(%rsp), %al
testb $0x1, %al
jne 0x72596
jmp 0x725d8
movl -0x24(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movq -0x8(%rsp), %rcx
movslq 0x24f68(%rip), %rdx     # 0x97514
movl (%rcx,%rdx,4), %ecx
subl -0x1c(%rsp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x24(%rsp)
movl -0x28(%rsp), %eax
movl %eax, -0x2c(%rsp)
movl 0x24f4a(%rip), %eax     # 0x97514
addl $0x1, %eax
movl %eax, 0x24f41(%rip)     # 0x97514
jmp 0x72547
movl 0x24f36(%rip), %ecx     # 0x97514
subl $0x1, %ecx
imull -0x40(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movl %eax, -0x3c(%rsp)
movl -0x1c(%rsp), %edx
subl $0x1, %edx
movq -0x8(%rsp), %rax
movslq -0x14(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rsp), %eax
cmpl -0x14(%rsp), %eax
jg 0x72864
movq -0x10(%rsp), %rax
movq %rax, -0x48(%rsp)
movq -0x48(%rsp), %rax
movq -0x10(%rsp), %rcx
movslq -0x2c(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x72656
movq -0x48(%rsp), %rax
movl $0x0, (%rax)
movq -0x48(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rsp)
jmp 0x72620
movq -0x8(%rsp), %rax
movslq 0x24eb2(%rip), %rcx     # 0x97514
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rsp)
movl -0x24(%rsp), %eax
movl %eax, -0x28(%rsp)
movq -0x48(%rsp), %rax
movq -0x8(%rsp), %rcx
movslq -0x14(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x726d4
movq -0x10(%rsp), %rax
movslq -0x28(%rsp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x28(%rsp), %eax
andl -0x3c(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movq -0x48(%rsp), %rcx
movl (%rcx), %ecx
subl -0x1c(%rsp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x28(%rsp)
movq -0x48(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rsp)
jmp 0x72676
movl $0x1, -0x34(%rsp)
movl -0x34(%rsp), %eax
cmpl 0x24e2e(%rip), %eax     # 0x97514
jge 0x72718
movq -0x10(%rsp), %rax
movslq -0x28(%rsp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x28(%rsp), %eax
andl -0x3c(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movl %eax, -0x28(%rsp)
movl -0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rsp)
jmp 0x726dc
movq -0x10(%rsp), %rax
movq %rax, -0x48(%rsp)
movl $0x1, -0x38(%rsp)
movq -0x48(%rsp), %rax
movq -0x10(%rsp), %rcx
movslq -0x2c(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x72775
movq -0x48(%rsp), %rax
cmpl $0x0, (%rax)
je 0x72763
movl -0x38(%rsp), %ecx
movl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x38(%rsp)
movq -0x48(%rsp), %rax
movl %ecx, (%rax)
jmp 0x72765
movq -0x48(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rsp)
jmp 0x7272a
movq -0x8(%rsp), %rax
movq %rax, -0x48(%rsp)
movq -0x8(%rsp), %rax
movslq 0x24d89(%rip), %rcx     # 0x97514
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rsp)
movl -0x24(%rsp), %eax
movl %eax, -0x28(%rsp)
movq -0x50(%rsp), %rax
movq -0x8(%rsp), %rcx
movslq -0x14(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x7280e
movq -0x10(%rsp), %rax
movslq -0x28(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x48(%rsp), %rax
movl %ecx, (%rax)
movl -0x28(%rsp), %eax
andl -0x3c(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movq -0x50(%rsp), %rcx
movl (%rcx), %ecx
subl -0x1c(%rsp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x28(%rsp)
movq -0x48(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rsp)
movq -0x50(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rsp)
jmp 0x7279f
jmp 0x72810
movq -0x48(%rsp), %rax
movq -0x8(%rsp), %rcx
movslq -0x14(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x7285f
movq -0x10(%rsp), %rax
movslq -0x28(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x48(%rsp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x48(%rsp)
movl %ecx, (%rax)
movl -0x28(%rsp), %eax
andl -0x3c(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movl %eax, -0x28(%rsp)
jmp 0x72810
jmp 0x72947
movq -0x8(%rsp), %rax
movq %rax, -0x48(%rsp)
movq -0x8(%rsp), %rax
movslq 0x24c9a(%rip), %rcx     # 0x97514
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rsp)
movl -0x24(%rsp), %eax
movl %eax, -0x28(%rsp)
movq -0x50(%rsp), %rax
movq -0x8(%rsp), %rcx
movslq -0x14(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x728f4
movl -0x28(%rsp), %ecx
movq -0x48(%rsp), %rax
movl %ecx, (%rax)
movl -0x28(%rsp), %eax
andl -0x3c(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movq -0x50(%rsp), %rcx
movl (%rcx), %ecx
subl -0x1c(%rsp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x28(%rsp)
movq -0x48(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rsp)
movq -0x50(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rsp)
jmp 0x7288e
jmp 0x728f6
movq -0x48(%rsp), %rax
movq -0x8(%rsp), %rcx
movslq -0x14(%rsp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x7293c
movl -0x28(%rsp), %ecx
movq -0x48(%rsp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x48(%rsp)
movl %ecx, (%rax)
movl -0x28(%rsp), %eax
andl -0x3c(%rsp), %eax
movl -0x40(%rsp), %ecx
shll %cl, %eax
movl %eax, -0x28(%rsp)
jmp 0x728f6
movl -0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rsp)
movq -0x8(%rsp), %rax
movslq -0x14(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x38(%rsp), %eax
retq
nopl (%rax)