// File: /workspace/github_c_makefile_star2_O3/felipelouza[P]egap/tools/src/gsacak.c
// Function: putSubstr1
void putSubstr1(int_t *SA, int_t *s, int_t n, int cs) {
  int_t h, i, j;

  for(i=0; i<n; i++) SA[i]=EMPTY_k;

  int_t c, c1, t, t1;
  c1=chr(n-2);
  t1=0; 
  for(i=n-2; i>0; i--) {
    c=c1; t=t1; 
    c1=chr(i-1);
    t1=c1<c || (c1==c && t);
    if(t && !t1) {
      if(SA[c]>=0) {
        // SA[c] is borrowed by the right
        //   neighbor bucket.
        // shift-right the items in the
        //   right neighbor bucket.
        int_t foo, bar;
        foo=SA[c];
        for(h=c+1; SA[h]>=0; h++)
        { bar=SA[h]; SA[h]=foo; foo=bar; }
        SA[h]=foo;

        SA[c]=EMPTY_k;
      }

      int_t d=SA[c];
      if(d==EMPTY_k) { // SA[c] is empty.
        if(SA[c-1]==EMPTY_k) {
          SA[c]=-1; // init the counter.
          SA[c-1]=i;
        }
        else
          SA[c]=i; // a size-1 bucket.
      }
      else { // SA[c] is reused as a counter
          int_t pos=c+d-1;
          if(SA[pos]!=EMPTY_k) {
            // we are running into the left
            //   neighbor bucket.
            // shift-right one step the items 
            //   of bucket(SA, S, i).
            for(h=0; h<-d; h++)
              SA[c-h]=SA[c-h-1];
            pos++;
          }
          else
            SA[c]--;

          SA[pos]=i;
      }
    }
  }

  // scan to shift-right the items in each bucket
  //   with its head being reused as a counter.
  for(i=n-1; i>0; i--) {
    j=SA[i];
    if(j<0 && j!=EMPTY_k) { // is SA[i] a counter?
      for(h=0; h<-j; h++)
        SA[i-h]=SA[i-h-1];
      SA[i-h]=EMPTY_k;
    }
  }

  // put the single sentinel LMS-substring.
  SA[0]=n-1;
}

// Assembly:
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
testq %rdx, %rdx
jle 0x825d
leaq 0x1(%rdx), %r8
andq $-0x2, %r8
leaq -0x1(%rdx), %r9
movq %r9, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x38c8(%rip), %xmm1     # 0xbab0
xorl %r9d, %r9d
movdqa 0x38cd(%rip), %xmm2     # 0xbac0
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x38cd(%rip), %xmm4     # 0xbad0
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %r10d
notl %r10d
testb $0x1, %r10b
je 0x823b
movq %rax, (%rdi,%r9,8)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %r10d
testb $0x1, %r10b
je 0x8250
movq %rax, 0x8(%rdi,%r9,8)
addq $0x2, %r9
paddq %xmm4, %xmm1
cmpq %r9, %r8
jne 0x8203
cmpl $0x8, %ecx
jne 0x8269
movq -0x10(%rsi,%rdx,8), %r8
jmp 0x826f
movzbl -0x2(%rsi,%rdx), %r8d
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpq $0x3, %rdx
jl 0x835e
leaq -0x2(%rdx), %r9
xorl %r11d, %r11d
movq %r8, %r14
cmpl $0x8, %ecx
jne 0x8296
movq -0x8(%rsi,%r9,8), %r8
jmp 0x829c
movzbl -0x1(%rsi,%r9), %r8d
movb $0x1, %r10b
cmpq %r14, %r8
jl 0x8349
sete %bl
testq %r11, %r11
setne %r10b
sete %r11b
andb %bl, %r10b
orb %bl, %r11b
jne 0x8349
leaq (%rdi,%r14,8), %r11
movq (%r11), %rbx
testq %rbx, %rbx
js 0x82f6
leaq (%rdi,%r14,8), %r14
addq $0x8, %r14
movq (%r14), %r15
testq %r15, %r15
js 0x8315
movq %r15, %r12
movq %rbx, (%r14)
movq 0x8(%r14), %r15
addq $0x8, %r14
movq %r12, %rbx
testq %r15, %r15
jns 0x82de
jmp 0x8318
cmpq %rax, %rbx
je 0x831b
leaq (%rbx,%r14), %r15
cmpq %rax, -0x8(%rdi,%r15,8)
jne 0x832e
leaq (%rbx,%r14), %r15
decq %r15
decq %rbx
movq %rbx, (%r11)
jmp 0x8342
movq %rbx, %r12
movq %r12, (%r14)
cmpq %rax, -0x8(%r11)
jne 0x8346
movq $-0x1, (%r11)
addq $-0x8, %r11
jmp 0x8346
xorl %r14d, %r14d
movq -0x8(%r11,%r14,8), %r12
movq %r12, (%r11,%r14,8)
decq %r14
cmpq %r14, %rbx
jne 0x8331
leaq (%rdi,%r15,8), %r11
movq %r9, (%r11)
movzbl %r10b, %r11d
leaq -0x1(%r9), %r10
cmpq $0x1, %r9
movq %r10, %r9
jg 0x8287
leaq -0x1(%rdx), %rcx
cmpq $0x2, %rdx
jl 0x83a9
leaq (%rdi,%rdx,8), %rdx
addq $-0x8, %rdx
movq %rcx, %rsi
movq (%rdi,%rsi,8), %r8
cmpq %rax, %r8
jbe 0x8398
xorl %r9d, %r9d
movq -0x8(%rdx,%r9,8), %r10
movq %r10, (%rdx,%r9,8)
decq %r9
cmpq %r9, %r8
jne 0x837f
leaq (%rdi,%rsi,8), %r9
movq %rax, (%r9,%r8,8)
leaq -0x1(%rsi), %r8
addq $-0x8, %rdx
cmpq $0x1, %rsi
movq %r8, %rsi
jg 0x8373
movq %rcx, (%rdi)
popq %rbx
popq %r12
popq %r14
popq %r15
retq