// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwt.c
// Function: bwt_extend
void bwt_extend(const bwt_t *bwt, const bwtintv_t *ik, bwtintv_t ok[VALUE_DOMAIN], int is_back)
{
	bwtint_t tk[VALUE_DOMAIN], tl[VALUE_DOMAIN];
	int i, copyIdx;

	// Accumulate occurrences
	bwt_2occ4(bwt, ik->x[!is_back] - 1, ik->x[!is_back] - 1 + ik->x[2], tk, tl);
	for (i = 0; i != VALUE_DOMAIN; ++i) {
		ok[i].x[!is_back] = bwt->L2[i] + 1 + tk[i];
		ok[i].x[2] = tl[i] - tk[i];
	}

	// Copy values returned from occurrence accumulators
	ok[VALUE_DOMAIN - 1].x[is_back] = ik->x[is_back] + (ik->x[!is_back] <= bwt->primary && ik->x[!is_back] + ik->x[2] - 1 >= bwt->primary);

	for (copyIdx = VALUE_DOMAIN - 2 ; copyIdx >= 0 ; copyIdx--) {
		ok[copyIdx].x[is_back] = ok[copyIdx + 1].x[is_back] + ok[copyIdx + 1].x[2];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
cmpl $0x0, -0x1c(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
subq $0x1, %rsi
movq -0x10(%rbp), %rax
cmpl $0x0, -0x1c(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
subq $0x1, %rdx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rdx
leaq -0x120(%rbp), %rcx
leaq -0x220(%rbp), %r8
callq 0x146a0
movl $0x0, -0x224(%rbp)
cmpl $0x20, -0x224(%rbp)
je 0x14a52
movq -0x8(%rbp), %rax
movslq -0x224(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdx
addq $0x1, %rdx
movslq -0x224(%rbp), %rax
addq -0x120(%rbp,%rax,8), %rdx
movq -0x18(%rbp), %rax
movslq -0x224(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, -0x1c(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movslq -0x224(%rbp), %rax
movq -0x220(%rbp,%rax,8), %rcx
movslq -0x224(%rbp), %rax
subq -0x120(%rbp,%rax,8), %rcx
movq -0x18(%rbp), %rax
movslq -0x224(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movl -0x224(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x224(%rbp)
jmp 0x149b1
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x238(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, -0x1c(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x229(%rbp)
ja 0x14ac8
movq -0x10(%rbp), %rax
cmpl $0x0, -0x1c(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq -0x10(%rbp), %rcx
addq 0x10(%rcx), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
setae %al
movb %al, -0x229(%rbp)
movq -0x238(%rbp), %rdx
movb -0x229(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, 0x3e0(%rax,%rcx,8)
movl $0x1e, -0x228(%rbp)
cmpl $0x0, -0x228(%rbp)
jl 0x14b67
movq -0x18(%rbp), %rax
movl -0x228(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x18(%rbp), %rax
movl -0x228(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
addq 0x10(%rax), %rdx
movq -0x18(%rbp), %rax
movslq -0x228(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x228(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0x14af9
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq