// File: BenLangmead[P]bowtie/./ls.h
// Function: LarssonSadakane<int>::transform(int*, int*, int, int, int, int)
inline T transform(T *x, T *p, T n, T k, T l, T q)
	{
	   T b, c, d, e, i, j, m, s;
	   T *pi, *pj;

	   for (s=0, i=k-l; i; i>>=1)
		  ++s;                      /* s is number of bits in old symbol.*/
	   e=std::numeric_limits<T>::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=(((T)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:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x20(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x2cdb3
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x38(%rbp), %eax
sarl %eax
movl %eax, -0x38(%rbp)
jmp 0x2cd9a
callq 0x2d310
movl %eax, %edx
movq -0x60(%rbp), %rax
movl -0x44(%rbp), %ecx
sarl %cl, %edx
movl %edx, %ecx
movl %ecx, -0x34(%rbp)
movl $0x0, 0x10(%rax)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x60(%rbp), %rax
movl 0x10(%rax), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x61(%rbp)
jge 0x2ce17
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x34(%rbp), %ecx
movb %al, -0x61(%rbp)
jg 0x2ce17
movl -0x30(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movl -0x20(%rbp), %ecx
subl -0x24(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
cmpl 0x10(%rbp), %eax
setle %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x2ce20
jmp 0x2ce57
movq -0x60(%rbp), %rdx
movl -0x28(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movq -0x10(%rbp), %rcx
movslq 0x10(%rdx), %rdx
movl (%rcx,%rdx,4), %ecx
subl -0x24(%rbp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x60(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0x2cddd
movq -0x60(%rbp), %rax
movl 0x10(%rax), %ecx
subl $0x1, %ecx
imull -0x44(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x24(%rbp), %edx
subl $0x1, %edx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2d090
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x30(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x2cec7
movq -0x50(%rbp), %rax
movl $0x0, (%rax)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
jmp 0x2ce97
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq 0x10(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x2cf35
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
andl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movq -0x50(%rbp), %rcx
movl (%rcx), %ecx
subl -0x24(%rbp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
jmp 0x2cee4
movl $0x1, -0x38(%rbp)
movq -0x60(%rbp), %rcx
movl -0x38(%rbp), %eax
cmpl 0x10(%rcx), %eax
jge 0x2cf70
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
andl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movl %eax, -0x2c(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2cf3c
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x1, -0x3c(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x30(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x2cfc1
movq -0x50(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2cfb1
movl -0x3c(%rbp), %ecx
movl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2cfb3
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
jmp 0x2cf7f
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movslq 0x10(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x2d045
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
andl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movq -0x58(%rbp), %rcx
movl (%rcx), %ecx
subl -0x24(%rbp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
jmp 0x2cfe6
jmp 0x2d047
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x2d08b
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x50(%rbp)
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
andl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2d047
jmp 0x2d153
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movslq 0x10(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x2d10c
movl -0x2c(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
andl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movq -0x58(%rbp), %rcx
movl (%rcx), %ecx
subl -0x24(%rbp), %ecx
addl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
jmp 0x2d0b5
jmp 0x2d10e
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x2d14a
movl -0x2c(%rbp), %ecx
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x50(%rbp)
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
andl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
shll %cl, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2d10e
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)