// File: /workspace/github_c_makefile_star2_O3/lh3[P]minigraph/miniwfa.c
// Function: mwf_wfa_seg
wf_chkpt_t *mwf_wfa_seg(void *km, const mwf_opt_t *opt, int32_t tl, const char *pts, int32_t ql, const char *pqs, int32_t *n_seg_)
{
	int32_t max_pen, last, n_seg;
	wf_stripe_t *wf, *sf;
	wf_sss_t sss = {0,0,0};
	uint8_t *xbuf;
	wf_chkpt_t *seg;
	void *km_st;

	km_st = !(opt->flag&MWF_F_NO_KALLOC)? km_init2(km, 0) : 0;
	max_pen = opt->x;
	max_pen = max_pen > opt->o1 + opt->e1? max_pen : opt->o1 + opt->e1;
	max_pen = max_pen > opt->o2 + opt->e2? max_pen : opt->o2 + opt->e2;
	xbuf = Kcalloc(km_st, uint8_t, tl + ql + 1);
	wf = wf_stripe_init(km_st, max_pen);
	sf = wf_stripe_init(km_st, max_pen);
	assert(pts);

	while (1) {
		wf_slice_t *p = &wf->a[wf->top];
		int32_t d, lo, hi, *H = p->H;
		for (d = p->lo; d <= p->hi; ++d) {
			int32_t k;
			if (H[d] < -1 || d + H[d] < -1 || H[d] >= tl || d + H[d] >= ql) continue;
			k = wf_extend1_padded(pts, pqs, H[d], d);
			if (k == tl - 1 && d + k == ql - 1) {
				last = sf->a[sf->top].H[d];
				break;
			}
			H[d] = k;
		}
		if (d <= p->hi) break;
		lo = wf->lo > -tl? wf->lo - 1 : -tl;
		hi = wf->hi <  ql? wf->hi + 1 :  ql;
		if ((wf->s + 1) % opt->step == 0)
			wf_snapshot(km_st, &sss, sf);
		wf_next_seg(km_st, opt, xbuf, wf, sf, lo, hi);
		if ((wf->s&0xff) == 0) wf_stripe_shrink(wf, tl, ql);
	}
	seg = wf_traceback_seg(km, &sss, last, &n_seg);
	if (km_st == 0) {
		wf_snapshot_free(km_st, &sss);
		wf_stripe_destroy(km_st, wf);
		wf_stripe_destroy(km_st, sf);
		kfree(km_st, xbuf);
	} else km_destroy(km_st);

	seg = (wf_chkpt_t*)krelocate(km, seg, n_seg * sizeof(*seg));
	*n_seg_ = n_seg;
	return seg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %r9, 0xb8(%rsp)
movq %r8, 0xc0(%rsp)
movq %rcx, %r15
movq %rdx, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
testb $0x2, (%rsi)
movq %rdi, 0xb0(%rsp)
jne 0x12712
xorl %esi, %esi
callq 0x2f3c
movq %rax, %rbx
jmp 0x12714
xorl %ebx, %ebx
movq 0x68(%rsp), %rdx
movl 0xc(%rdx), %eax
addl 0x8(%rdx), %eax
movl 0x4(%rdx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0x14(%rdx), %ebp
addl 0x10(%rdx), %ebp
cmpl %ebp, %eax
cmovgl %eax, %ebp
movq 0xc0(%rsp), %r12
movq 0x70(%rsp), %r14
leal 0x1(%r14,%r12), %eax
movslq %eax, %rsi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2f84
movq %rax, 0x78(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x13111
movq %rax, 0x58(%rsp)
movq %rbx, 0x60(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x13111
movq %rax, 0x10(%rsp)
testq %r15, %r15
je 0x130d3
movl %r14d, %eax
negl %eax
movl %eax, 0xac(%rsp)
movl $0xfffffff9, %eax       # imm = 0xFFFFFFF9
movl $0xfffffff9, %ecx       # imm = 0xFFFFFFF9
subl %r12d, %ecx
movl %ecx, 0xa8(%rsp)
subl %r14d, %eax
movq %rax, 0xf0(%rsp)
incq 0xb8(%rsp)
incq %r15
movq %r15, 0xf8(%rsp)
movq $0x0, (%rsp)
movl $0x0, 0x44(%rsp)
movq $0x0, 0x50(%rsp)
movq %r12, %rbp
movq 0x60(%rsp), %r12
movq 0x58(%rsp), %r13
movq 0x18(%r13), %rsi
movslq 0x4(%r13), %rax
imulq $0x38, %rax, %rdi
movl (%rsi,%rdi), %ecx
movl 0x4(%rsi,%rdi), %eax
cmpl %eax, %ecx
jg 0x128c8
leaq (%rsi,%rdi), %rdx
movq 0x10(%rsi,%rdi), %rsi
movslq %ecx, %r9
addl 0xa8(%rsp), %ecx
movq 0xb8(%rsp), %rdi
addq %r9, %rdi
movl %ecx, %r8d
movq %r9, %rcx
movslq (%rsi,%r9,4), %r9
cmpq $-0x1, %r9
jl 0x128af
leal (%r9,%rcx), %r10d
cmpl %ebp, %r10d
jge 0x128af
cmpl %r14d, %r9d
jge 0x128af
cmpl $-0x1, %r10d
jl 0x128af
leaq (%rdi,%r9), %r11
movq 0xf8(%rsp), %r10
leaq (%r10,%r9), %rbx
xorl %r10d, %r10d
movq (%rbx,%r10), %r14
movq (%r11,%r10), %r15
addq $0x8, %r10
cmpq %r15, %r14
je 0x12859
xorq %r14, %r15
bsfq %r15, %r11
shrl $0x3, %r11d
movq 0xf0(%rsp), %rbx
addl %r9d, %ebx
addl %r10d, %ebx
addl %r11d, %ebx
leal (%r9,%r8), %r14d
addq %r11, %r14
addl %r10d, %r14d
orl %ebx, %r14d
je 0x12f06
addl $-0x8, %r9d
addq %r10, %r9
addq %r11, %r9
movl %r9d, (%rsi,%rcx,4)
movl 0x4(%rdx), %eax
movq 0x70(%rsp), %r14
leaq 0x1(%rcx), %r9
movslq %eax, %r10
incl %r8d
incq %rdi
cmpq %r10, %rcx
jl 0x12825
movl %r9d, %ecx
movl 0x48(%rsp), %ebx
cmpl %eax, %ecx
jle 0x12f24
movl 0x10(%r13), %eax
leal -0x1(%rax), %edi
movl 0xac(%rsp), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %edi
movl 0x14(%r13), %eax
leal 0x1(%rax), %ecx
cmpl %ebp, %eax
cmovgel %ebp, %ecx
movl %ecx, 0xc(%rsp)
movl (%r13), %eax
incl %eax
cltd
movq 0x68(%rsp), %rcx
idivl 0x18(%rcx)
testl %edx, %edx
movl %ebx, 0x48(%rsp)
movl %edi, 0x4c(%rsp)
jne 0x12b05
movq (%rsp), %rax
cmpl 0x44(%rsp), %eax
jne 0x12955
movq (%rsp), %rax
sarl %eax
movq (%rsp), %rcx
addl %ecx, %eax
addl $0x8, %eax
movl %eax, 0x44(%rsp)
movslq %eax, %rdx
shlq $0x5, %rdx
movq %r12, %rdi
movq 0x50(%rsp), %rsi
callq 0x31ed
movq %rax, %rdx
movq (%rsp), %rax
movq 0x10(%rsp), %r13
jmp 0x1295f
movq 0x10(%rsp), %r13
movq 0x50(%rsp), %rdx
cltq
shlq $0x5, %rax
leaq (%rdx,%rax), %r15
movl $0x0, (%rdx,%rax)
movl (%r13), %ecx
movq %rdx, 0x50(%rsp)
movl %ecx, 0x8(%rdx,%rax)
movslq 0x8(%r13), %rcx
testq %rcx, %rcx
jle 0x129b6
movq 0x18(%r13), %rax
imulq $0x38, %rcx, %rcx
xorl %edx, %edx
xorl %esi, %esi
movl 0x4(%rax,%rdx), %edi
subl (%rax,%rdx), %edi
leal (%rdi,%rdi,4), %edi
addl %edi, %esi
addl $0x5, %esi
addq $0x38, %rdx
cmpq %rdx, %rcx
jne 0x12992
movl %esi, (%r15)
movslq %esi, %rsi
shlq $0x2, %rsi
jmp 0x129b8
xorl %esi, %esi
movq %r12, %rdi
callq 0x30e5
movq %rax, 0x10(%r15)
movslq 0x8(%r13), %rsi
movl %esi, 0x4(%r15)
shlq $0x3, %rsi
movq %r12, %rdi
callq 0x30e5
movq %rax, 0x18(%r15)
movl 0x8(%r13), %r9d
testl %r9d, %r9d
jle 0x12ae2
movq %rax, %rcx
movq 0x18(%r13), %rsi
xorl %r8d, %r8d
xorl %edi, %edi
movq %r8, %r10
incq %r8
movl 0x4(%r13), %eax
addl %r8d, %eax
cltd
idivl %r9d
movslq %edx, %rax
imulq $0x38, %rax, %rax
movslq (%rsi,%rax), %rdx
movq %rdx, %r11
shlq $0x20, %r11
movl 0x4(%rsi,%rax), %ebx
movl %ebx, %r14d
subl %edx, %r14d
leal (%r14,%r14,4), %ebp
addl $0x5, %ebp
movslq %ebp, %r14
orq %r11, %r14
movq %r14, (%rcx,%r10,8)
cmpl %edx, %ebx
jl 0x12ad4
addq %rsi, %rax
movq 0x10(%rax), %r9
movq 0x18(%rax), %r10
movq 0x10(%r15), %r12
movq 0x28(%rax), %r11
movq 0x20(%rax), %rbx
movq 0x30(%rax), %r14
movslq %edi, %r13
decq %rdx
leaq (%r12,%r13,4), %r12
addq $0x10, %r12
movl 0x4(%r9,%rdx,4), %ebp
movl %ebp, -0x10(%r12)
movl %edi, 0x4(%r9,%rdx,4)
movl 0x4(%r10,%rdx,4), %ebp
movl %ebp, -0xc(%r12)
leal 0x1(%rdi), %ebp
movl %ebp, 0x4(%r10,%rdx,4)
movl 0x4(%r11,%rdx,4), %ebp
movl %ebp, -0x8(%r12)
leal 0x2(%rdi), %ebp
movl %ebp, 0x4(%r11,%rdx,4)
movl 0x4(%rbx,%rdx,4), %ebp
movl %ebp, -0x4(%r12)
leal 0x3(%rdi), %ebp
movl %ebp, 0x4(%rbx,%rdx,4)
movl 0x4(%r14,%rdx,4), %ebp
movl %ebp, (%r12)
leal 0x4(%rdi), %ebp
movl %ebp, 0x4(%r14,%rdx,4)
movslq 0x4(%rax), %r13
incq %rdx
addl $0x5, %edi
addq $0x14, %r12
cmpq %r13, %rdx
jl 0x12a64
movq 0x10(%rsp), %r13
movl 0x8(%r13), %r9d
movslq %r9d, %rax
cmpq %rax, %r8
jl 0x129f5
jmp 0x12ae4
xorl %edi, %edi
cmpl (%r15), %edi
jne 0x130b4
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
movq 0x60(%rsp), %r12
movq 0x58(%rsp), %r13
movl 0x4c(%rsp), %edi
movslq %edi, %r14
movq 0x78(%rsp), %rax
subq %r14, %rax
movq %rax, 0x18(%rsp)
subq $0x8, %rsp
movq %r12, %rdi
movq 0x70(%rsp), %rsi
movq %r13, %rdx
movl %r14d, %ecx
movl 0x14(%rsp), %ebx
movl %ebx, %r8d
leaq 0xa8(%rsp), %r9
leaq 0x88(%rsp), %r15
pushq %r15
leaq 0xf0(%rsp), %r13
pushq %r13
leaq 0xf0(%rsp), %rbp
pushq %rbp
movq %r12, %r15
leaq 0x108(%rsp), %r12
pushq %r12
leaq 0xb0(%rsp), %rax
pushq %rax
leaq 0xc0(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0x60(%rsp), %rax
pushq %rax
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0x90(%rsp), %rax
pushq %rax
callq 0x14ed9
addq $0x60, %rsp
movq 0xa0(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq 0x28(%rsp), %r8
movq 0x30(%rsp), %r9
subq $0x8, %rsp
movl %r14d, %edi
movl %ebx, %esi
pushq 0x88(%rsp)
pushq 0xf0(%rsp)
pushq 0xf0(%rsp)
pushq 0x108(%rsp)
pushq 0xb0(%rsp)
pushq 0xc0(%rsp)
pushq 0xd0(%rsp)
pushq 0x58(%rsp)
pushq 0x68(%rsp)
callq 0x1502f
addq $0x48, %rsp
movq %r15, %rdi
movq 0x70(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %r14d, %ecx
movl %ebx, %r8d
leaq 0xa8(%rsp), %r9
leaq 0x88(%rsp), %rax
pushq %rax
pushq %r13
pushq %rbp
pushq %r12
leaq 0xb0(%rsp), %rax
pushq %rax
leaq 0xc0(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0x60(%rsp), %rax
pushq %rax
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0x90(%rsp), %rax
pushq %rax
callq 0x14ed9
addq $0x60, %rsp
movq 0xa0(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq %r14, 0xd0(%rsp)
cmpl %ebx, %r14d
jg 0x12e49
movq 0x90(%rsp), %r14
movq 0xe8(%rsp), %rax
movq 0xd8(%rsp), %rdx
movq 0x88(%rsp), %rsi
movq 0xe0(%rsp), %rdi
movq 0x80(%rsp), %r8
movq 0xd0(%rsp), %r9
leaq (,%r9,4), %r11
movq 0xc8(%rsp), %rcx
leaq (%rcx,%r9,4), %rcx
movq %rcx, 0x18(%rsp)
movq 0x98(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x100(%rsp)
movq 0x20(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x120(%rsp)
movq 0x30(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x118(%rsp)
movq 0x28(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x110(%rsp)
movl 0xc(%rsp), %ecx
movl %ecx, %r10d
subl %r9d, %r10d
incl %r10d
leaq (%r8,%r9,4), %rcx
addq $0x4, %rcx
movq %rcx, 0x108(%rsp)
leaq (%rsi,%r9,4), %rbx
addq $0x4, %rbx
leaq (%rdx,%r9,4), %r13
addq $0x4, %r13
addq 0x38(%rsp), %r11
leaq (%r14,%r9,4), %rbp
addq $0x4, %rbp
leaq (%rdi,%r9,4), %r14
addq $-0x4, %r14
leaq (%rax,%r9,4), %rax
addq $-0x4, %rax
xorl %r12d, %r12d
movq 0x78(%rsp), %rcx
movzbl (%rcx,%r12), %r15d
leaq (,%r12,4), %rdx
addq %rbp, %rdx
leaq -0x8(,%r12,4), %rsi
addq %rbp, %rsi
leaq (%rax,%r12,4), %rdi
testb $0x8, %r15b
cmoveq %rsi, %rdi
leaq (,%r12,4), %r8
addq %r13, %r8
testb $0x10, %r15b
cmoveq %rdx, %r8
leaq (%rbx,%r12,4), %rdx
leaq (%rbx,%r12,4), %rsi
addq $-0x8, %rsi
leaq (%r14,%r12,4), %r9
testb $0x20, %r15b
cmoveq %rsi, %r9
movq 0x108(%rsp), %rcx
leaq (%rcx,%r12,4), %rcx
testb $0x40, %r15b
cmoveq %rdx, %rcx
movl (%rdi), %esi
movl %esi, (%r11,%r12,4)
movl (%r8), %r8d
movq 0x110(%rsp), %rdx
movl %r8d, (%rdx,%r12,4)
movl (%r9), %edi
movq 0x118(%rsp), %rdx
movl %edi, (%rdx,%r12,4)
movl (%rcx), %edx
movq 0x120(%rsp), %rcx
movl %edx, (%rcx,%r12,4)
andb $0x7, %r15b
cmpb $0x1, %r15b
je 0x12e1e
movq 0x100(%rsp), %rcx
movl (%rcx,%r12,4), %esi
cmpb $0x2, %r15b
cmovel %r8d, %esi
cmpb $0x3, %r15b
cmovel %edi, %esi
cmpb $0x4, %r15b
cmovel %edx, %esi
movq 0x18(%rsp), %rcx
movl %esi, (%rcx,%r12,4)
incq %r12
cmpl %r12d, %r10d
jne 0x12d6b
movq 0xd0(%rsp), %rcx
movq 0xc8(%rsp), %rdx
cmpl $-0x2, (%rdx,%rcx,4)
movq 0x58(%rsp), %r13
jg 0x12e90
movq 0x38(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x12e90
movq 0x28(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x12e90
movq 0x30(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x12e90
movq 0x20(%rsp), %rax
cmpl $-0x1, (%rax,%rcx,4)
jl 0x12e98
movl 0x4c(%rsp), %eax
movl %eax, 0x10(%r13)
movslq 0xc(%rsp), %rax
cmpl $-0x2, (%rdx,%rax,4)
movq 0xc0(%rsp), %rbp
movq 0x70(%rsp), %r14
jg 0x12edc
movq 0x38(%rsp), %rcx
cmpl $-0x2, (%rcx,%rax,4)
jg 0x12edc
movq 0x28(%rsp), %rcx
cmpl $-0x2, (%rcx,%rax,4)
jg 0x12edc
movq 0x30(%rsp), %rcx
cmpl $-0x2, (%rcx,%rax,4)
jg 0x12edc
movq 0x20(%rsp), %rcx
cmpl $-0x1, (%rcx,%rax,4)
jl 0x12ee4
movl 0xc(%rsp), %eax
movl %eax, 0x14(%r13)
cmpb $0x0, (%r13)
movq 0x60(%rsp), %r12
jne 0x127e9
movq %r13, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x131d2
jmp 0x127e9
movq 0x10(%rsp), %rsi
movq 0x18(%rsi), %rdx
movslq 0x4(%rsi), %rsi
imulq $0x38, %rsi, %rsi
movq 0x10(%rdx,%rsi), %rdx
movl (%rdx,%rcx,4), %ebx
jmp 0x128cc
movq (%rsp), %r14
movslq %r14d, %rbp
leaq (,%rbp,8), %rsi
movq 0xb0(%rsp), %rdi
movq %rsi, 0x18(%rsp)
callq 0x30e5
movq %rax, %r15
testl %ebp, %ebp
movq 0x50(%rsp), %r13
jle 0x12ff4
movl %r14d, %eax
leaq -0x1(%rax), %rcx
movq %rcx, %rdx
shlq $0x5, %rdx
movslq 0x4(%r13,%rdx), %r8
testq %r8, %r8
jle 0x13095
addq %r13, %rdx
movq 0x18(%rdx), %rsi
leal -0x1(%r8), %r9d
shlq $0x3, %r8
xorl %edi, %edi
xorl %r10d, %r10d
movl %r10d, %r14d
movl (%rsi,%rdi), %r10d
addl %r14d, %r10d
movl %ebx, %r11d
subl %r14d, %r11d
jl 0x12f9f
movl %ebx, %r12d
cmpl %r10d, %ebx
jl 0x12fb0
addq $0x8, %rdi
decl %r9d
cmpq %rdi, %r8
jne 0x12f85
jmp 0x13095
movl 0x8(%rdx), %r8d
subl %r9d, %r8d
movl %r8d, (%r15,%rcx,8)
movslq %r11d, %r8
imulq $0x66666667, %r8, %r8   # imm = 0x66666667
movq %r8, %r9
shrq $0x3f, %r9
sarq $0x21, %r8
addl %r9d, %r8d
addl 0x4(%rsi,%rdi), %r8d
movl %r8d, 0x4(%r15,%rcx,8)
movq 0x10(%rdx), %rdx
movslq %r12d, %rsi
movl (%rdx,%rsi,4), %ebx
cmpq $0x1, %rax
movq %rcx, %rax
jg 0x12f58
cmpl $-0x1, %ebx
jne 0x130f2
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1300e
callq 0x2fe1
jmp 0x13060
cmpl $0x0, (%rsp)
jle 0x13036
leaq 0x18(%r13), %r14
movq -0x8(%r14), %rsi
xorl %edi, %edi
callq 0x301f
movq (%r14), %rsi
xorl %edi, %edi
callq 0x301f
addq $0x20, %r14
decq %rbp
jne 0x13018
xorl %edi, %edi
movq %r13, %rsi
callq 0x301f
movq 0x58(%rsp), %rdi
callq 0x134cf
movq 0x10(%rsp), %rdi
callq 0x134cf
xorl %edi, %edi
movq 0x78(%rsp), %rsi
callq 0x301f
movq 0xb0(%rsp), %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
callq 0x328f
movq 0x160(%rsp), %rcx
movq (%rsp), %rdx
movl %edx, (%rcx)
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15dc0(%rip), %rdi     # 0x28e5c
leaq 0x15cc1(%rip), %rsi     # 0x28d64
leaq 0x15dc0(%rip), %rcx     # 0x28e6a
movl $0x21e, %edx            # imm = 0x21E
callq 0x2160
leaq 0x15d1f(%rip), %rdi     # 0x28dda
leaq 0x15ca2(%rip), %rsi     # 0x28d64
leaq 0x15d1c(%rip), %rcx     # 0x28de5
movl $0x1d9, %edx            # imm = 0x1D9
callq 0x2160
leaq 0x15c86(%rip), %rdi     # 0x28d60
leaq 0x15c83(%rip), %rsi     # 0x28d64
leaq 0x15c86(%rip), %rcx     # 0x28d6e
movl $0x237, %edx            # imm = 0x237
callq 0x2160
leaq 0x15db6(%rip), %rdi     # 0x28eaf
leaq 0x15c64(%rip), %rsi     # 0x28d64
leaq 0x15d63(%rip), %rcx     # 0x28e6a
movl $0x223, %edx            # imm = 0x223
callq 0x2160