// File: readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::init(long, bool, bool, bool)
void sparseSA::init(long K_, bool _hasSufLink, bool _hasChild, bool _hasKmer){
  hasSufLink = _hasSufLink;
  hasChild = _hasChild;
  hasKmer = _hasKmer;
  K = K_;

  // Increase string length so divisible by K.
  // Don't forget to count $ termination character.
  S.reserve(S.length()+2*K);
  if(S.length() % K != 0) {
    long appendK = K - S.length() % K ;
    for(long i = 0; i < appendK; i++) S += '$';
  }
  // Make sure last K-sampled characeter is this special character as well!!
  for(long i = 0; i < K; i++) S += '$'; // Append "special" end character. Note: It must be lexicographically less.
  N = S.length();
  std::string(S.data(), S.size()).swap(S);

  // Adjust to "sampled" size.
  logN = (long)ceil(log(N/K) / log(2.0));
  NKm1 = N/K-1;
}

// Assembly:
subq $0xa8, %rsp
movb %r8b, %al
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
andb $0x1, %dl
movb %dl, 0x97(%rsp)
andb $0x1, %cl
movb %cl, 0x96(%rsp)
andb $0x1, %al
movb %al, 0x95(%rsp)
movq 0xa0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movb 0x97(%rsp), %al
andb $0x1, %al
movb %al, 0xf1(%rdi)
movb 0x96(%rsp), %al
andb $0x1, %al
movb %al, 0xf0(%rdi)
movb 0x95(%rsp), %al
andb $0x1, %al
movb %al, 0xf8(%rdi)
movq 0x98(%rsp), %rax
movq %rax, 0xe8(%rdi)
movq %rdi, %rax
addq $0x50, %rax
movq %rax, 0x30(%rsp)
addq $0x50, %rdi
callq 0x8630
movq 0x30(%rsp), %rdi
movq %rax, %rsi
movq 0x38(%rsp), %rax
movq 0xe8(%rax), %rax
shlq %rax
addq %rax, %rsi
callq 0x8680
movq 0x38(%rsp), %rdi
addq $0x50, %rdi
callq 0x8630
movq 0x38(%rsp), %rcx
xorl %edx, %edx
divq 0xe8(%rcx)
cmpq $0x0, %rdx
je 0x1677b
movq 0x38(%rsp), %rdi
movq 0xe8(%rdi), %rax
movq %rax, 0x28(%rsp)
addq $0x50, %rdi
callq 0x8630
movq 0x38(%rsp), %rcx
xorl %edx, %edx
divq 0xe8(%rcx)
movq 0x28(%rsp), %rax
subq %rdx, %rax
movq %rax, 0x88(%rsp)
movq $0x0, 0x80(%rsp)
movq 0x80(%rsp), %rax
cmpq 0x88(%rsp), %rax
jge 0x16779
movq 0x38(%rsp), %rdi
addq $0x50, %rdi
movl $0x24, %esi
callq 0x8210
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x1673e
jmp 0x1677b
movq $0x0, 0x78(%rsp)
movq 0x38(%rsp), %rcx
movq 0x78(%rsp), %rax
cmpq 0xe8(%rcx), %rax
jge 0x167ba
movq 0x38(%rsp), %rdi
addq $0x50, %rdi
movl $0x24, %esi
callq 0x8210
movq 0x78(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
jmp 0x16784
movq 0x38(%rsp), %rdi
addq $0x50, %rdi
movq %rdi, 0x8(%rsp)
callq 0x8630
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x38(%rax)
callq 0x81d0
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%rsp)
callq 0x8250
movq %rax, 0x18(%rsp)
leaq 0x57(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x8750
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
leaq 0x58(%rsp), %rdi
callq 0x8430
jmp 0x16821
movq 0x38(%rsp), %rsi
addq $0x50, %rsi
leaq 0x58(%rsp), %rdi
callq 0x8280
leaq 0x58(%rsp), %rdi
callq 0x8858
leaq 0x57(%rsp), %rdi
callq 0x83e0
movq 0x38(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rdi
callq 0x1ead0
movsd %xmm0, (%rsp)
movsd 0x66a19(%rip), %xmm0    # 0x7d288
callq 0x82e0
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x80b0
movq 0x38(%rsp), %rcx
cvttsd2si %xmm0, %rax
movq %rax, 0x40(%rcx)
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rcx
movq 0x38(%rsp), %rax
subq $0x1, %rcx
movq %rcx, 0x48(%rax)
addq $0xa8, %rsp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
leaq 0x57(%rsp), %rdi
callq 0x83e0
movq 0x48(%rsp), %rdi
callq 0x8730
nopw (%rax,%rax)