// File: /workspace/github_c_makefile_star2_O2/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, 0x100(%rsp)
movq %rcx, 0xe0(%rsp)
movl %edx, %r9d
movq %rdi, %rbx
movq %rsi, 0x48(%rsp)
testb $0x2, (%rsi)
movq %r8, 0x10(%rsp)
movq %r9, 0x50(%rsp)
jne 0xfae6
movq %rbx, %rdi
xorl %esi, %esi
callq 0x24ac
movq 0x50(%rsp), %r9
movq 0x10(%rsp), %r8
movq %rax, %r14
jmp 0xfae9
xorl %r14d, %r14d
movq 0x48(%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
leal 0x1(%r9,%r8), %eax
movslq %eax, %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r8, %r12
movq %r9, %r13
callq 0x24f0
movq %rax, 0x78(%rsp)
movq %r14, %rdi
movl %ebp, %esi
callq 0x1045d
movq %rax, %r15
movq %r14, 0x60(%rsp)
movq %r14, %rdi
movl %ebp, %esi
callq 0x1045d
movq %rax, 0x40(%rsp)
cmpq $0x0, 0xe0(%rsp)
je 0x1041f
movq %rbx, 0xc0(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0xbc(%rsp)
movl %r13d, %eax
negl %eax
movl %eax, 0xb4(%rsp)
pushq $0x1
popq %rax
subl %r12d, %eax
movq %rax, 0xf8(%rsp)
movq $0x0, 0xc8(%rsp)
movl $0x0, 0x3c(%rsp)
movq $0x0, 0x8(%rsp)
movq %r12, %r8
movq %r13, %rsi
movq %r15, 0x58(%rsp)
movq 0x18(%r15), %rax
movslq 0x4(%r15), %rcx
imulq $0x38, %rcx, %rcx
leaq (%rax,%rcx), %r15
movl (%rax,%rcx), %r12d
movslq %r12d, %r14
movq 0xf8(%rsp), %rdx
addq %r12, %rdx
movq %rdx, 0x70(%rsp)
leaq (,%r14,4), %rdx
movq 0x10(%rax,%rcx), %rbx
movq %rdx, 0x68(%rsp)
addq %rdx, %rbx
xorl %ebp, %ebp
leaq (%r14,%rbp), %rax
movslq 0x4(%r15), %r13
cmpq %r13, %rax
jg 0xfc7e
movl (%rbx,%rbp,4), %edx
cmpl $-0x1, %edx
jl 0xfc4f
leal (%r12,%rbp), %eax
addl %edx, %eax
cmpl %r8d, %eax
jge 0xfc4f
cmpl %esi, %edx
jge 0xfc4f
cmpl $-0x1, %eax
jl 0xfc4f
leaq (%r12,%rbp), %rcx
movq 0xe0(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0x1050d
cmpl 0xbc(%rsp), %eax
jne 0xfc42
movq 0x70(%rsp), %rcx
addl %ebp, %ecx
addl %eax, %ecx
je 0xfc54
movl %eax, (%rbx,%rbp,4)
movq 0x10(%rsp), %r8
movq 0x50(%rsp), %rsi
incq %rbp
jmp 0xfbe8
movq 0x40(%rsp), %rcx
movq 0x18(%rcx), %rax
movslq 0x4(%rcx), %rcx
imulq $0x38, %rcx, %rcx
movq 0x68(%rsp), %rdx
addq 0x10(%rax,%rcx), %rdx
movl (%rdx,%rbp,4), %eax
movl %eax, 0xb0(%rsp)
movq 0x10(%rsp), %r8
addl %r12d, %ebp
movq 0xc8(%rsp), %r14
movslq %r14d, %r12
cmpl %ebp, %r13d
movq 0x60(%rsp), %r15
jge 0x10284
movq 0x58(%rsp), %r13
movl 0x10(%r13), %eax
leal -0x1(%rax), %ebx
movl 0xb4(%rsp), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %ebx
movl 0x14(%r13), %eax
leal 0x1(%rax), %ecx
cmpl %r8d, %eax
cmovgel %r8d, %ecx
movl %ecx, 0x4(%rsp)
movl (%r13), %eax
incl %eax
cltd
movq 0x48(%rsp), %rcx
idivl 0x18(%rcx)
testl %edx, %edx
je 0xfce1
movq 0x40(%rsp), %r12
jmp 0xfe8c
cmpl 0x3c(%rsp), %r14d
movq 0x8(%rsp), %rsi
jne 0xfd0e
movl %r14d, %eax
sarl %eax
addl %r14d, %eax
addl $0x8, %eax
movl %eax, 0x3c(%rsp)
movslq %eax, %rdx
shlq $0x5, %rdx
movq %r15, %rdi
callq 0x2774
movq %rax, %rsi
shlq $0x5, %r12
leaq (%rsi,%r12), %rbp
andl $0x0, (%rsi,%r12)
movq 0x40(%rsp), %rcx
movl (%rcx), %eax
movq %rsi, 0x8(%rsp)
movl %eax, 0x8(%rsi,%r12)
movq %rcx, %r12
movl 0x8(%rcx), %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0x38, %rcx, %rcx
xorl %edx, %edx
cmpq %rax, %rcx
je 0xfd61
movq 0x18(%r12), %rsi
movl 0x4(%rsi,%rax), %edi
subl (%rsi,%rax), %edi
leal (%rdi,%rdi,4), %esi
addl %esi, %edx
addl $0x5, %edx
movl %edx, (%rbp)
addq $0x38, %rax
jmp 0xfd3f
movslq %edx, %rsi
shlq $0x2, %rsi
movq %r15, %rdi
callq 0x266c
movq %rax, 0x10(%rbp)
movslq 0x8(%r12), %rsi
movl %esi, 0x4(%rbp)
shlq $0x3, %rsi
movq %r15, %rdi
callq 0x266c
movq %rax, %rcx
movq %rax, 0x18(%rbp)
xorl %r8d, %r8d
xorl %esi, %esi
movslq 0x8(%r12), %r9
cmpq %r9, %r8
jge 0xfe78
leaq 0x1(%r8), %rdi
movl 0x4(%r12), %eax
addl %edi, %eax
cltd
idivl %r9d
movq 0x18(%r12), %r9
movslq %edx, %rax
imulq $0x38, %rax, %r10
leaq (%r9,%r10), %rax
movslq (%r9,%r10), %rdx
movq %rdx, %r11
shlq $0x20, %r11
movl 0x4(%r9,%r10), %r9d
movl %r9d, %r10d
subl %edx, %r10d
leal (%r10,%r10,4), %r10d
addl $0x5, %r10d
movslq %r10d, %r10
orq %r11, %r10
movq %r10, (%rcx,%r8,8)
movslq %esi, %r8
addq $0x4, %r8
movslq %r9d, %r9
cmpq %r9, %rdx
jg 0xfe70
movq 0x10(%rax), %r9
movl (%r9,%rdx,4), %r10d
movq 0x10(%rbp), %r11
movl %r10d, -0x10(%r11,%r8,4)
movl %esi, (%r9,%rdx,4)
movq 0x18(%rax), %r9
movl (%r9,%rdx,4), %r10d
movl %r10d, -0xc(%r11,%r8,4)
leal 0x1(%rsi), %r10d
movl %r10d, (%r9,%rdx,4)
movq 0x28(%rax), %r9
movl (%r9,%rdx,4), %r10d
movl %r10d, -0x8(%r11,%r8,4)
leal 0x2(%rsi), %r10d
movl %r10d, (%r9,%rdx,4)
movq 0x20(%rax), %r9
movl (%r9,%rdx,4), %r10d
movl %r10d, -0x4(%r11,%r8,4)
leal 0x3(%rsi), %r10d
movl %r10d, (%r9,%rdx,4)
movq 0x30(%rax), %r9
movl (%r9,%rdx,4), %r10d
movl %r10d, (%r11,%r8,4)
leal 0x4(%rsi), %r10d
movl %r10d, (%r9,%rdx,4)
incq %rdx
movl 0x4(%rax), %r9d
addl $0x5, %esi
addq $0x5, %r8
jmp 0xfdf0
movq %rdi, %r8
jmp 0xfd94
cmpl (%rbp), %esi
jne 0x10400
incl %r14d
movq %r14, 0xc8(%rsp)
movl %ebx, 0xb8(%rsp)
movslq %ebx, %r14
movq 0x78(%rsp), %rbx
subq %r14, %rbx
subq $0x8, %rsp
movq %r15, %rdi
movq 0x50(%rsp), %rsi
movq %r13, %rdx
movl %r14d, %ecx
movl 0xc(%rsp), %r15d
movl %r15d, %r8d
leaq 0xb0(%rsp), %r9
leaq 0xf0(%rsp), %r13
pushq %r13
leaq 0x100(%rsp), %rbp
pushq %rbp
leaq 0x98(%rsp), %rax
pushq %rax
leaq 0xa8(%rsp), %rax
pushq %rax
leaq 0xb8(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
leaq 0xd8(%rsp), %rax
pushq %rax
leaq 0x58(%rsp), %rax
pushq %rax
leaq 0x70(%rsp), %rax
pushq %rax
leaq 0x70(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
callq 0x12176
addq $0x60, %rsp
movq 0xa8(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x20(%rsp), %r8
movq 0x28(%rsp), %r9
subq $0x8, %rsp
movl %r14d, %edi
movl %r15d, %esi
pushq 0xf0(%rsp)
pushq 0x100(%rsp)
pushq 0x98(%rsp)
pushq 0xa8(%rsp)
pushq 0xb8(%rsp)
pushq 0xc8(%rsp)
pushq 0xd8(%rsp)
pushq %rbx
pushq 0x60(%rsp)
callq 0x122b7
addq $0x48, %rsp
movq 0x68(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %r12, %rdx
movl %r14d, %ecx
movl %r15d, %r8d
leaq 0xb0(%rsp), %r9
pushq %r13
pushq %rbp
leaq 0x98(%rsp), %rax
pushq %rax
leaq 0xa8(%rsp), %rax
pushq %rax
leaq 0xb8(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
leaq 0xd8(%rsp), %rax
pushq %rax
leaq 0x58(%rsp), %rax
pushq %rax
leaq 0x70(%rsp), %rax
pushq %rax
leaq 0x70(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
callq 0x12176
addq $0x60, %rsp
movq 0xa8(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq %r14, 0xd8(%rsp)
cmpl %r15d, %r14d
jg 0x101c5
movq 0x98(%rsp), %rbx
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rdx
movq 0x90(%rsp), %rsi
movq 0xf0(%rsp), %rdi
movq 0xe8(%rsp), %r8
movq 0xd8(%rsp), %r9
leaq (,%r9,4), %r11
movq 0xd0(%rsp), %rcx
leaq (%rcx,%r9,4), %rcx
movq %rcx, 0x70(%rsp)
movq 0xa0(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x108(%rsp)
movq 0x18(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x68(%rsp)
movq 0x28(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x120(%rsp)
movq 0x20(%rsp), %rcx
addq %r11, %rcx
movq %rcx, 0x118(%rsp)
movl 0x4(%rsp), %ecx
movl %ecx, %r10d
subl %r9d, %r10d
incl %r10d
leaq (%r8,%r9,4), %rcx
addq $0x4, %rcx
movq %rcx, 0x110(%rsp)
leaq (%rsi,%r9,4), %r14
addq $0x4, %r14
leaq (%rdx,%r9,4), %r15
addq $0x4, %r15
addq 0x30(%rsp), %r11
leaq (%rbx,%r9,4), %rbx
addq $0x4, %rbx
leaq (%rdi,%r9,4), %r13
addq $-0x4, %r13
leaq (%rax,%r9,4), %rbp
addq $-0x4, %rbp
xorl %eax, %eax
movq 0x78(%rsp), %rcx
movzbl (%rcx,%rax), %r12d
leaq (%rbx,%rax,4), %rdx
leaq (%rbx,%rax,4), %rsi
addq $-0x8, %rsi
leaq (,%rax,4), %rdi
addq %rbp, %rdi
testb $0x8, %r12b
cmoveq %rsi, %rdi
leaq (%r15,%rax,4), %r8
testb $0x10, %r12b
cmoveq %rdx, %r8
leaq (%r14,%rax,4), %rdx
leaq (%r14,%rax,4), %rsi
addq $-0x8, %rsi
leaq (,%rax,4), %r9
addq %r13, %r9
testb $0x20, %r12b
cmoveq %rsi, %r9
movq 0x110(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
testb $0x40, %r12b
cmoveq %rdx, %rcx
movl (%rdi), %esi
movl %esi, (%r11,%rax,4)
movl (%r8), %r8d
movq 0x118(%rsp), %rdx
movl %r8d, (%rdx,%rax,4)
movl (%r9), %edi
movq 0x120(%rsp), %rdx
movl %edi, (%rdx,%rax,4)
movl (%rcx), %edx
movq 0x68(%rsp), %rcx
movl %edx, (%rcx,%rax,4)
andb $0x7, %r12b
cmpb $0x1, %r12b
je 0x1019b
movq 0x108(%rsp), %rcx
movl (%rcx,%rax,4), %esi
cmpb $0x2, %r12b
cmovel %r8d, %esi
cmpb $0x3, %r12b
cmovel %edi, %esi
cmpb $0x4, %r12b
cmovel %edx, %esi
movq 0x70(%rsp), %rcx
movl %esi, (%rcx,%rax,4)
incq %rax
cmpl %eax, %r10d
jne 0x100f1
movq 0xd8(%rsp), %rcx
movq 0xd0(%rsp), %rdx
cmpl $-0x2, (%rdx,%rcx,4)
movq 0x58(%rsp), %r15
jg 0x1020c
movq 0x30(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x1020c
movq 0x20(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x1020c
movq 0x28(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x1020c
movq 0x18(%rsp), %rax
cmpl $-0x1, (%rax,%rcx,4)
jl 0x10217
movl 0xb8(%rsp), %eax
movl %eax, 0x10(%r15)
movslq 0x4(%rsp), %rax
cmpl $-0x2, (%rdx,%rax,4)
movq 0x10(%rsp), %r8
movq 0x50(%rsp), %rsi
jg 0x10258
movq 0x30(%rsp), %rcx
cmpl $-0x2, (%rcx,%rax,4)
jg 0x10258
movq 0x20(%rsp), %rcx
cmpl $-0x2, (%rcx,%rax,4)
jg 0x10258
movq 0x28(%rsp), %rcx
cmpl $-0x2, (%rcx,%rax,4)
jg 0x10258
movq 0x18(%rsp), %rcx
cmpl $-0x1, (%rcx,%rax,4)
jl 0x10260
movl 0x4(%rsp), %eax
movl %eax, 0x14(%r15)
cmpb $0x0, (%r15)
jne 0xfbaa
movq %r15, %rdi
movl %r8d, %edx
callq 0x10548
movq 0x50(%rsp), %rsi
movq 0x10(%rsp), %r8
jmp 0xfbaa
leaq (,%r12,8), %rbp
movq 0xc0(%rsp), %rdi
movq %rbp, %rsi
callq 0x266c
movq %rax, %r15
movl %r12d, %ecx
pushq $0x5
popq %rsi
movl 0xb0(%rsp), %r13d
testl %ecx, %ecx
jle 0x10335
decq %rcx
movq %rcx, %rax
shlq $0x5, %rax
movq 0x8(%rsp), %r8
movl 0x4(%r8,%rax), %edx
xorl %edi, %edi
testl %edx, %edx
movl $0x0, %r9d
cmovgl %edx, %r9d
addq %rax, %r8
decl %edx
shlq $0x3, %r9
xorl %ebx, %ebx
cmpq %rdi, %r9
je 0x103e1
movq 0x18(%r8), %r10
movl (%r10,%rdi), %r11d
addl %ebx, %r11d
movl %r13d, %eax
subl %ebx, %eax
jl 0x10302
cmpl %r11d, %r13d
jl 0x1030d
addq $0x8, %rdi
decl %edx
movl %r11d, %ebx
jmp 0x102e2
movl 0x8(%r8), %r9d
subl %edx, %r9d
movl %r9d, (%r15,%rcx,8)
cltd
idivl %esi
addl 0x4(%r10,%rdi), %eax
movl %eax, 0x4(%r15,%rcx,8)
movq 0x10(%r8), %rax
movslq %r13d, %rdx
movl (%rax,%rdx,4), %r13d
jmp 0x102ad
cmpl $-0x1, %r13d
jne 0x1043e
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x10350
callq 0x253c
jmp 0x103b1
xorl %ebx, %ebx
testq %r12, %r12
cmovleq %rbx, %r12
shlq $0x5, %r12
movq 0x8(%rsp), %r13
cmpq %rbx, %r12
je 0x10385
movq 0x10(%r13,%rbx), %rsi
xorl %edi, %edi
callq 0x2577
movq 0x18(%r13,%rbx), %rsi
xorl %edi, %edi
callq 0x2577
addq $0x20, %rbx
jmp 0x10362
xorl %edi, %edi
movq 0x8(%rsp), %rsi
callq 0x2577
movq 0x58(%rsp), %rdi
callq 0x1085d
movq 0x40(%rsp), %rdi
callq 0x1085d
xorl %edi, %edi
movq 0x78(%rsp), %rsi
callq 0x2577
movq 0xc0(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2816
movq 0x160(%rsp), %rcx
movl %r14d, (%rcx)
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13a84(%rip), %rdi     # 0x23e6c
leaq 0x13985(%rip), %rsi     # 0x23d74
leaq 0x13a84(%rip), %rcx     # 0x23e7a
movl $0x21e, %edx            # imm = 0x21E
callq 0x2160
leaq 0x139e3(%rip), %rdi     # 0x23dea
leaq 0x13966(%rip), %rsi     # 0x23d74
leaq 0x139e0(%rip), %rcx     # 0x23df5
movl $0x1d9, %edx            # imm = 0x1D9
callq 0x2160
leaq 0x1394a(%rip), %rdi     # 0x23d70
leaq 0x13947(%rip), %rsi     # 0x23d74
leaq 0x1394a(%rip), %rcx     # 0x23d7e
movl $0x237, %edx            # imm = 0x237
callq 0x2160
leaq 0x13a7a(%rip), %rdi     # 0x23ebf
leaq 0x13928(%rip), %rsi     # 0x23d74
leaq 0x13a27(%rip), %rcx     # 0x23e7a
movl $0x223, %edx            # imm = 0x223
callq 0x2160