// File: readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::computeChild()
void sparseSA::computeChild() {
    for(long i = 0; i < N/K; i++){
        CHILD[i] = -1;
    }
    //Compute up and down values
    long lastIndex  = -1;
    stack<long,vector<long> > stapelUD;
    stapelUD.push(0);
    for(long i = 1; i < N/K; i++){
        while(LCP[i] < LCP[stapelUD.top()]){
            lastIndex = stapelUD.top();
            stapelUD.pop();
            if(LCP[i] <= LCP[stapelUD.top()] && LCP[stapelUD.top()] != LCP[lastIndex]){
                CHILD[stapelUD.top()] = lastIndex;
            }
        }
        //now LCP[i] >= LCP[top] holds
        if(lastIndex != -1){
            CHILD[i-1] = lastIndex;
            lastIndex = -1;
        }
        stapelUD.push(i);
    }
    while(0 < LCP[stapelUD.top()]){//last row (fix for last character of sequence not being unique
        lastIndex = stapelUD.top();
        stapelUD.pop();
        if(0 <= LCP[stapelUD.top()] && LCP[stapelUD.top()] != LCP[lastIndex]){
            CHILD[stapelUD.top()] = lastIndex;
        }
    }
    //Compute Next L-index values
    stack<long,vector<long> > stapelNL;
    stapelNL.push(0);
    for(long i = 1; i < N/K; i++){
        while(LCP[i] < LCP[stapelNL.top()])
            stapelNL.pop();
        lastIndex = stapelNL.top();
        if(LCP[i] == LCP[lastIndex]){
            stapelNL.pop();
            CHILD[lastIndex] = i;
        }
        stapelNL.push(i);
    }
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x1b0(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x138(%rsp)
movq $0x0, 0x1a8(%rsp)
movq 0x138(%rsp), %rcx
movq 0x1a8(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rcx
movq 0x130(%rsp), %rax
cmpq %rcx, %rax
jge 0x17328
movq 0x138(%rsp), %rdi
addq $0xd0, %rdi
movq 0x1a8(%rsp), %rsi
callq 0x1eb90
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x1a8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1a8(%rsp)
jmp 0x172bb
movq $-0x1, 0x1a0(%rsp)
leaq 0x188(%rsp), %rdi
movq %rdi, 0x128(%rsp)
callq 0x1ecc0
movq 0x128(%rsp), %rdi
movq $0x0, 0x180(%rsp)
leaq 0x180(%rsp), %rsi
callq 0x1ecf0
jmp 0x1736c
movq $0x1, 0x168(%rsp)
movq 0x138(%rsp), %rcx
movq 0x168(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rcx
movq 0x120(%rsp), %rax
cmpq %rcx, %rax
jge 0x17680
jmp 0x173b3
movq 0x138(%rsp), %rdi
addq $0xa0, %rdi
movq 0x168(%rsp), %rsi
callq 0x1ed20
movl %eax, 0x11c(%rsp)
jmp 0x173d8
movq 0x138(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0x108(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0x110(%rsp)
jmp 0x17405
movq 0x108(%rsp), %rdi
movq 0x110(%rsp), %rax
movq (%rax), %rsi
callq 0x1ed20
movl %eax, 0x104(%rsp)
jmp 0x17426
movl 0x11c(%rsp), %eax
movl 0x104(%rsp), %ecx
cmpl %ecx, %eax
jge 0x175ff
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0xf8(%rsp)
jmp 0x17453
movq 0xf8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1a0(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1edf0
jmp 0x17475
movq 0x138(%rsp), %rdi
addq $0xa0, %rdi
movq 0x168(%rsp), %rsi
callq 0x1ed20
movl %eax, 0xf4(%rsp)
jmp 0x1749a
movq 0x138(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0xe0(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0xe8(%rsp)
jmp 0x174c7
movq 0xe0(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq (%rax), %rsi
callq 0x1ed20
movl %eax, 0xdc(%rsp)
jmp 0x174e8
movl 0xf4(%rsp), %eax
movl 0xdc(%rsp), %ecx
cmpl %ecx, %eax
jg 0x175fa
movq 0x138(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0xc8(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0xd0(%rsp)
jmp 0x1752b
movq 0xc8(%rsp), %rdi
movq 0xd0(%rsp), %rax
movq (%rax), %rsi
callq 0x1ed20
movl %eax, 0xc4(%rsp)
jmp 0x1754c
movq 0x138(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1a0(%rsp), %rsi
callq 0x1ed20
movl %eax, 0xc0(%rsp)
jmp 0x17571
movl 0xc4(%rsp), %eax
movl 0xc0(%rsp), %ecx
cmpl %ecx, %eax
je 0x175fa
movq 0x138(%rsp), %rax
movl 0x1a0(%rsp), %ecx
movl %ecx, 0xac(%rsp)
addq $0xd0, %rax
movq %rax, 0xb0(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0xb8(%rsp)
jmp 0x175be
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rax
movq (%rax), %rsi
callq 0x1eb90
movl 0xac(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x175fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x17a45
jmp 0x173b3
cmpq $-0x1, 0x1a0(%rsp)
je 0x1764e
movq 0x138(%rsp), %rdi
movq 0x1a0(%rsp), %rax
movl %eax, 0xa8(%rsp)
addq $0xd0, %rdi
movq 0x168(%rsp), %rsi
subq $0x1, %rsi
callq 0x1eb90
movl 0xa8(%rsp), %ecx
movl %ecx, (%rax)
movq $-0x1, 0x1a0(%rsp)
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x1ee00
jmp 0x17665
jmp 0x17667
movq 0x168(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x168(%rsp)
jmp 0x17378
jmp 0x17682
movq 0x138(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0x98(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0xa0(%rsp)
jmp 0x176af
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq (%rax), %rsi
callq 0x1ed20
movl %eax, 0x94(%rsp)
jmp 0x176d0
movl 0x94(%rsp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jge 0x17829
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0x88(%rsp)
jmp 0x176f8
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1a0(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1edf0
jmp 0x1771a
movq 0x138(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0x78(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0x80(%rsp)
jmp 0x17744
movq 0x78(%rsp), %rdi
movq 0x80(%rsp), %rax
movq (%rax), %rsi
callq 0x1ed20
movl %eax, 0x74(%rsp)
jmp 0x1775f
movl 0x74(%rsp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jg 0x17824
movq 0x138(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0x60(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0x68(%rsp)
jmp 0x17794
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rax
movq (%rax), %rsi
callq 0x1ed20
movl %eax, 0x5c(%rsp)
jmp 0x177ac
movq 0x138(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1a0(%rsp), %rsi
callq 0x1ed20
movl %eax, 0x58(%rsp)
jmp 0x177ce
movl 0x5c(%rsp), %eax
movl 0x58(%rsp), %ecx
cmpl %ecx, %eax
je 0x17824
movq 0x138(%rsp), %rax
movl 0x1a0(%rsp), %ecx
movl %ecx, 0x44(%rsp)
addq $0xd0, %rax
movq %rax, 0x48(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1ede0
movq %rax, 0x50(%rsp)
jmp 0x1780c
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rax
movq (%rax), %rsi
callq 0x1eb90
movl 0x44(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x17682
leaq 0x150(%rsp), %rdi
callq 0x1ecc0
jmp 0x17838
movq $0x0, 0x148(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x1ecf0
jmp 0x1785b
movq $0x1, 0x140(%rsp)
movq 0x138(%rsp), %rcx
movq 0x140(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jge 0x17a23
jmp 0x1789c
movq 0x138(%rsp), %rdi
addq $0xa0, %rdi
movq 0x140(%rsp), %rsi
callq 0x1ed20
movl %eax, 0x34(%rsp)
jmp 0x178be
movq 0x138(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0x20(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x1ede0
movq %rax, 0x28(%rsp)
jmp 0x178e5
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
movq (%rax), %rsi
callq 0x1ed20
movl %eax, 0x1c(%rsp)
jmp 0x178fd
movl 0x34(%rsp), %eax
movl 0x1c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x17940
leaq 0x150(%rsp), %rdi
callq 0x1edf0
jmp 0x17918
jmp 0x1789c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x1ee30
jmp 0x17a45
leaq 0x150(%rsp), %rdi
callq 0x1ede0
movq %rax, 0x10(%rsp)
jmp 0x17954
movq 0x138(%rsp), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1a0(%rsp)
addq $0xa0, %rdi
movq 0x140(%rsp), %rsi
callq 0x1ed20
movl %eax, 0xc(%rsp)
jmp 0x17986
movq 0x138(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1a0(%rsp), %rsi
callq 0x1ed20
movl %eax, 0x8(%rsp)
jmp 0x179a8
movl 0xc(%rsp), %eax
movl 0x8(%rsp), %ecx
cmpl %ecx, %eax
jne 0x179f1
leaq 0x150(%rsp), %rdi
callq 0x1edf0
jmp 0x179c3
movq 0x138(%rsp), %rdi
movq 0x140(%rsp), %rax
movl %eax, 0x4(%rsp)
addq $0xd0, %rdi
movq 0x1a0(%rsp), %rsi
callq 0x1eb90
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
leaq 0x150(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x1ee00
jmp 0x17a08
jmp 0x17a0a
movq 0x140(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x140(%rsp)
jmp 0x17867
leaq 0x150(%rsp), %rdi
callq 0x1ee30
leaq 0x188(%rsp), %rdi
callq 0x1ee30
addq $0x1b8, %rsp            # imm = 0x1B8
retq
leaq 0x188(%rsp), %rdi
callq 0x1ee30
movq 0x178(%rsp), %rdi
callq 0x8730
nop