// File: BenLangmead[P]bowtie/./ebwt.h
// Function: Ebwt::restore(SString<char>&) const
void Ebwt::restore(BTRefString& s) const {
	assert(isInMemory());
	s.resize(this->_eh._len);
	TIndexOffU jumps = 0;
	TIndexOffU i = this->_eh._len; // should point to final SA elt (starting with '$')
	SideLocus l(i, this->_eh, this->_ebwt);
	while(i != _zOff) {
		assert_lt(jumps, this->_eh._len);
		//if(_verbose) cout << "restore: i: " << i << endl;
		// Not a marked row; go back a char in the original string
		TIndexOffU newi = mapLF(l);
		assert_neq(newi, i);
		s[this->_eh._len - jumps - 1] = rowL(l);
		i = newi;
		l.initFromRow(i, this->_eh, this->_ebwt);
		jumps++;
	}
	assert_eq(jumps, this->_eh._len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x48(%rbp)
callq 0x18060
testb $0x1, %al
jne 0x8e83
jmp 0x8e85
jmp 0x8ea4
leaq 0x36224(%rip), %rdi     # 0x3f0b0
leaq 0x3622a(%rip), %rsi     # 0x3f0bd
movl $0xacc, %edx            # imm = 0xACC
leaq 0x364c9(%rip), %rcx     # 0x3f368
callq 0x51e0
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x108(%rax), %rsi
callq 0x189a0
movq -0x48(%rbp), %rax
movq $0x0, -0x18(%rbp)
movq 0x108(%rax), %rcx
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rsi
movq %rax, %rdx
addq $0x108, %rdx            # imm = 0x108
movq 0xc8(%rax), %rcx
leaq -0x38(%rbp), %rdi
callq 0x18a60
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
cmpq 0x68(%rcx), %rax
je 0x9189
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
cmpq 0x108(%rcx), %rax
jb 0x8fd0
movq 0x410a5(%rip), %rdi     # 0x49fc0
leaq 0x36325(%rip), %rsi     # 0x3f247
callq 0x5360
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x36320(%rip), %rsi     # 0x3f25d
callq 0x5360
movq %rax, %rdi
movq -0x48(%rbp), %rax
movq 0x108(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x38659(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x41012(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x41046(%rip), %rdi     # 0x49fc0
leaq 0x3613c(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x377fa(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0xad2, %esi            # imm = 0xAD2
callq 0x5750
movq %rax, %rdi
movq 0x40fd4(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x376b2(%rip), %rdi     # 0x4066a
leaq 0x360fe(%rip), %rsi     # 0x3f0bd
movl $0xad2, %edx            # imm = 0xAD2
leaq 0x3639d(%rip), %rcx     # 0x3f368
callq 0x51e0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x18aa0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x9118
movq 0x40fc8(%rip), %rdi     # 0x49fc0
leaq 0x362eb(%rip), %rsi     # 0x3f2ea
callq 0x5360
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x36115(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0xf7b7(%rip), %rsi      # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0xf7cc(%rip), %rsi      # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x360e1(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x360c1(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0xf763(%rip), %rsi      # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0xf778(%rip), %rsi      # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x38511(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x40eca(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x40efe(%rip), %rdi     # 0x49fc0
leaq 0x35ff4(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x376b2(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0xad6, %esi            # imm = 0xAD6
callq 0x5750
movq %rax, %rdi
movq 0x40e8c(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x3756a(%rip), %rdi     # 0x4066a
leaq 0x35fb6(%rip), %rsi     # 0x3f0bd
movl $0xad6, %edx            # imm = 0xAD6
leaq 0x36255(%rip), %rcx     # 0x3f368
callq 0x51e0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x18f40
movl %eax, %ecx
movq -0x48(%rbp), %rax
movb %cl, -0x49(%rbp)
movq -0x10(%rbp), %rdi
movq 0x108(%rax), %rsi
subq -0x18(%rbp), %rsi
subq $0x1, %rsi
callq 0x18f90
movb -0x49(%rbp), %dl
movq %rax, %rcx
movq -0x48(%rbp), %rax
movb %dl, (%rcx)
movq -0x40(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rsi
movq %rax, %rdx
addq $0x108, %rdx            # imm = 0x108
movq 0xc8(%rax), %rcx
leaq -0x38(%rbp), %rdi
callq 0x19090
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x8eed
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
cmpq 0x108(%rcx), %rax
je 0x92d3
movq 0x40e1b(%rip), %rdi     # 0x49fc0
leaq 0x35f6d(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x35f68(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0xf60a(%rip), %rsi      # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0xf61f(%rip), %rsi      # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x35f34(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x48(%rbp), %rax
movq 0x108(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x35f0d(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0xf5af(%rip), %rsi      # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x48(%rbp), %rax
movq 0x108(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0xf5bd(%rip), %rsi      # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x38356(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x40d0f(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x40d43(%rip), %rdi     # 0x49fc0
leaq 0x35e39(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x374f7(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0xadc, %esi            # imm = 0xADC
callq 0x5750
movq %rax, %rdi
movq 0x40cd1(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x373af(%rip), %rdi     # 0x4066a
leaq 0x35dfb(%rip), %rsi     # 0x3f0bd
movl $0xadc, %edx            # imm = 0xADC
leaq 0x3609a(%rip), %rcx     # 0x3f368
callq 0x51e0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)