// File: /workspace/github_c_makefile_star2_O1/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 $0x138, %rsp            # imm = 0x138
movq %r8, 0xe0(%rsp)
movq %rcx, 0x88(%rsp)
movl %edx, %ebp
movq %rsi, 0x60(%rsp)
testb $0x2, (%rsi)
movq %rbp, 0x28(%rsp)
movq %rdi, 0xd0(%rsp)
movq %r9, 0x78(%rsp)
jne 0x12413
xorl %esi, %esi
callq 0x300c
movq 0x28(%rsp), %rbp
movq %rax, %r15
jmp 0x12416
xorl %r15d, %r15d
movq 0x60(%rsp), %rdx
movl 0xc(%rdx), %eax
addl 0x8(%rdx), %eax
movl 0x4(%rdx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0x14(%rdx), %ebx
addl 0x10(%rdx), %ebx
cmpl %ebx, %eax
cmovgl %eax, %ebx
movq 0xe0(%rsp), %r14
leal 0x1(%rbp,%r14), %eax
movslq %eax, %rsi
movl $0x1, %edx
movq %r15, %rdi
callq 0x3054
movq %rax, 0x98(%rsp)
movq %r15, %rdi
movl %ebx, %esi
callq 0x12e3d
movq %rax, %r12
movq %r15, %rdi
movl %ebx, %esi
callq 0x12e3d
movq 0x88(%rsp), %r11
testq %r11, %r11
je 0x12dff
movq %rax, %r13
movq 0x78(%rsp), %rbx
incq %rbx
movq %rbp, %rsi
leal -0x1(%rbp), %eax
movl %eax, 0xcc(%rsp)
leal -0x1(%r14), %eax
movl %eax, 0xc8(%rsp)
movl %ebp, %eax
negl %eax
movl %eax, 0xc4(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0xd8(%rsp)
movq $0x0, 0x18(%rsp)
movq %r15, %rbp
movq %r15, 0x20(%rsp)
movq %r12, 0x80(%rsp)
movq %r13, 0x68(%rsp)
movq %rbx, 0x78(%rsp)
movq 0x18(%r12), %rcx
movslq 0x4(%r12), %rax
imulq $0x38, %rax, %rdx
leaq (%rcx,%rdx), %rax
movl (%rcx,%rdx), %r15d
cmpl 0x4(%rcx,%rdx), %r15d
jg 0x125b8
movq 0x10(%rcx,%rdx), %rcx
movslq %r15d, %rdx
movl (%rcx,%rdx,4), %edi
cmpl $-0x1, %edi
jge 0x1251d
xorl %r9d, %r9d
jmp 0x1259a
leal (%rdi,%rdx), %r8d
xorl %r9d, %r9d
cmpl %r14d, %r8d
jge 0x1259a
cmpl %esi, %edi
jge 0x1259a
cmpl $-0x1, %r8d
jl 0x1259a
leaq (%rbx,%rdx), %r8
movslq %edi, %rsi
movq 0x1(%r11,%rsi), %r9
movq (%r8,%rsi), %r10
addl $0x8, %esi
cmpq %r10, %r9
je 0x1254d
movl %edi, %esi
movl %esi, %edi
je 0x12537
xorq %r9, %r10
bsfq %r10, %rdi
shrl $0x3, %edi
addl %esi, %edi
cmpl 0xcc(%rsp), %edi
jne 0x1258f
leal (%rdi,%rdx), %esi
cmpl 0xc8(%rsp), %esi
jne 0x1258f
movq 0x18(%r13), %rsi
movslq 0x4(%r13), %rdi
imulq $0x38, %rdi, %rdi
movq 0x10(%rsi,%rdi), %rsi
movl (%rsi,%rdx,4), %esi
movl %esi, 0x58(%rsp)
movb $0x1, %r9b
jmp 0x12595
movl %edi, (%rcx,%rdx,4)
xorl %r9d, %r9d
movq 0x28(%rsp), %rsi
testb %r9b, %r9b
jne 0x125b5
leaq 0x1(%rdx), %r15
movslq 0x4(%rax), %rdi
cmpq %rdi, %rdx
movq %r15, %rdx
jl 0x12510
jmp 0x125b8
movq %rdx, %r15
movl 0x4(%rax), %eax
cmpl %eax, %r15d
jle 0x12c0a
movl %eax, 0x54(%rsp)
movl 0x10(%r12), %eax
leal -0x1(%rax), %esi
movl 0xc4(%rsp), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %esi
movl 0x14(%r12), %eax
leal 0x1(%rax), %ecx
cmpl %r14d, %eax
cmovgel %r14d, %ecx
movl %ecx, 0xc(%rsp)
movl (%r12), %eax
incl %eax
cltd
movq 0x60(%rsp), %rcx
idivl 0x18(%rcx)
testl %edx, %edx
movq %r15, 0x108(%rsp)
movl %esi, 0x5c(%rsp)
jne 0x127fc
movq 0xd8(%rsp), %rcx
cmpl %ecx, 0x10(%rsp)
jne 0x12647
movl %ecx, %eax
sarl %eax
addl %eax, %ecx
addl $0x8, %ecx
movq %rcx, 0xd8(%rsp)
movslq %ecx, %rdx
shlq $0x5, %rdx
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
callq 0x32c4
jmp 0x1264c
movq 0x18(%rsp), %rax
movslq 0x10(%rsp), %rsi
shlq $0x5, %rsi
leaq (%rax,%rsi), %r12
movl $0x0, (%rax,%rsi)
movl (%r13), %ecx
movq %rax, 0x18(%rsp)
movl %ecx, 0x8(%rax,%rsi)
movslq 0x8(%r13), %rcx
testq %rcx, %rcx
jle 0x1269e
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 0x12682
movl %esi, (%r12)
movslq (%r12), %rsi
shlq $0x2, %rsi
movq %rbp, %rdi
callq 0x31c1
movq %rax, 0x10(%r12)
movslq 0x8(%r13), %rsi
movl %esi, 0x4(%r12)
shlq $0x3, %rsi
movq %rbp, %rdi
callq 0x31c1
movq %rax, 0x18(%r12)
movl 0x8(%r13), %r9d
testl %r9d, %r9d
jle 0x127d3
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, %r9
shlq $0x20, %r9
movl 0x4(%rsi,%rax), %r11d
movl %r11d, %ebx
subl %edx, %ebx
leal (%rbx,%rbx,4), %ebx
addl $0x5, %ebx
movslq %ebx, %rbx
orq %r9, %rbx
movq %rbx, (%rcx,%r10,8)
cmpl %edx, %r11d
jl 0x127bf
addq %rsi, %rax
movq 0x10(%rax), %r9
movq 0x18(%rax), %r10
movq 0x10(%r12), %r15
movq 0x28(%rax), %r11
movq 0x20(%rax), %rbx
movq 0x30(%rax), %r14
movslq %edi, %r13
decq %rdx
leaq (%r15,%r13,4), %r13
addq $0x10, %r13
movl 0x4(%r9,%rdx,4), %r15d
movl %r15d, -0x10(%r13)
movl %edi, 0x4(%r9,%rdx,4)
movl 0x4(%r10,%rdx,4), %r15d
movl %r15d, -0xc(%r13)
leal 0x1(%rdi), %r15d
movl %r15d, 0x4(%r10,%rdx,4)
movl 0x4(%r11,%rdx,4), %r15d
movl %r15d, -0x8(%r13)
leal 0x2(%rdi), %r15d
movl %r15d, 0x4(%r11,%rdx,4)
movl 0x4(%rbx,%rdx,4), %r15d
movl %r15d, -0x4(%r13)
leal 0x3(%rdi), %r15d
movl %r15d, 0x4(%rbx,%rdx,4)
movl 0x4(%r14,%rdx,4), %r15d
movl %r15d, (%r13)
leal 0x4(%rdi), %r15d
movl %r15d, 0x4(%r14,%rdx,4)
movslq 0x4(%rax), %r15
incq %rdx
addl $0x5, %edi
addq $0x14, %r13
cmpq %r15, %rdx
jl 0x12756
movq 0x68(%rsp), %r13
movslq 0x8(%r13), %r9
cmpq %r9, %r8
jl 0x126e6
jmp 0x127d5
xorl %edi, %edi
cmpl (%r12), %edi
jne 0x12de0
movq 0x10(%rsp), %rax
incl %eax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rbp
movq 0x80(%rsp), %r12
movl 0x5c(%rsp), %esi
movslq %esi, %r14
movq 0x98(%rsp), %rax
subq %r14, %rax
movq %rax, 0x90(%rsp)
subq $0x8, %rsp
movq %rbp, %rdi
movq 0x68(%rsp), %rsi
movq %r12, %rdx
movl %r14d, %ecx
movl 0x14(%rsp), %ebx
movl %ebx, %r8d
leaq 0x78(%rsp), %r9
leaq 0xf8(%rsp), %r12
pushq %r12
leaq 0x110(%rsp), %rbp
pushq %rbp
leaq 0x110(%rsp), %r15
pushq %r15
leaq 0xc0(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0xe0(%rsp), %rax
pushq %rax
leaq 0xf0(%rsp), %rax
pushq %rax
leaq 0x70(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
leaq 0xa0(%rsp), %rax
pushq %rax
callq 0x14c53
addq $0x60, %rsp
movq 0x70(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
subq $0x8, %rsp
movl %r14d, %edi
movl %ebx, %esi
pushq 0xf8(%rsp)
pushq 0x110(%rsp)
pushq 0x110(%rsp)
pushq 0xc0(%rsp)
pushq 0xd0(%rsp)
pushq 0xe0(%rsp)
pushq 0xf0(%rsp)
pushq 0xd0(%rsp)
pushq 0x78(%rsp)
callq 0x14da9
addq $0x48, %rsp
movq 0x28(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq %r13, %rdx
movl %r14d, %ecx
movl %ebx, %r8d
leaq 0x78(%rsp), %r9
pushq %r12
pushq %rbp
pushq %r15
leaq 0xc0(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0xe0(%rsp), %rax
pushq %rax
leaq 0xf0(%rsp), %rax
pushq %rax
leaq 0x70(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
leaq 0xa0(%rsp), %rax
pushq %rax
callq 0x14c53
addq $0x60, %rsp
movq %r14, 0xe8(%rsp)
cmpl %ebx, %r14d
jg 0x12b2b
movq 0xb0(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq 0xf8(%rsp), %rsi
movq 0xa8(%rsp), %rdi
movq 0x100(%rsp), %rbx
movq 0xf0(%rsp), %r8
movq 0xe8(%rsp), %r15
leaq (,%r15,4), %r10
movq 0x70(%rsp), %rax
addq %r10, %rax
movq %rax, 0x90(%rsp)
movq 0xb8(%rsp), %rax
addq %r10, %rax
movq %rax, 0x110(%rsp)
movq 0x30(%rsp), %rax
addq %r10, %rax
movq %rax, 0x130(%rsp)
movq 0x40(%rsp), %rax
addq %r10, %rax
movq %rax, 0x128(%rsp)
movq 0x38(%rsp), %rax
addq %r10, %rax
movq %rax, 0x120(%rsp)
movl 0xc(%rsp), %eax
movl %eax, %r9d
subl %r15d, %r9d
incl %r9d
leaq (%r8,%r15,4), %rax
addq $0x4, %rax
movq %rax, 0x118(%rsp)
leaq (%rdi,%r15,4), %r11
addq $0x4, %r11
leaq (%rsi,%r15,4), %r14
addq $0x4, %r14
addq 0x48(%rsp), %r10
leaq (%rdx,%r15,4), %r13
addq $0x4, %r13
leaq (%rbx,%r15,4), %r12
addq $-0x4, %r12
leaq (%rcx,%r15,4), %rdx
addq $-0x4, %rdx
xorl %ebx, %ebx
movq 0x98(%rsp), %rax
movzbl (%rax,%rbx), %ecx
leaq (,%rbx,4), %rsi
addq %r13, %rsi
leaq -0x8(,%rbx,4), %rdi
addq %r13, %rdi
leaq (%rdx,%rbx,4), %r8
testb $0x8, %cl
cmoveq %rdi, %r8
leaq (%r14,%rbx,4), %rdi
testb $0x10, %cl
cmoveq %rsi, %rdi
leaq (%r11,%rbx,4), %rsi
leaq (%r11,%rbx,4), %r15
addq $-0x8, %r15
leaq (%r12,%rbx,4), %rax
testb $0x20, %cl
cmoveq %r15, %rax
movq 0x118(%rsp), %r15
leaq (%r15,%rbx,4), %rbp
testb $0x40, %cl
cmoveq %rsi, %rbp
movl (%r8), %esi
movl %esi, (%r10,%rbx,4)
movl (%rdi), %r8d
movq 0x120(%rsp), %rdi
movl %r8d, (%rdi,%rbx,4)
movl (%rax), %r15d
movq 0x128(%rsp), %rax
movl %r15d, (%rax,%rbx,4)
movl (%rbp), %edi
movq 0x130(%rsp), %rax
movl %edi, (%rax,%rbx,4)
andb $0x7, %cl
cmpb $0x1, %cl
je 0x12b00
movq 0x110(%rsp), %rax
movl (%rax,%rbx,4), %esi
cmpb $0x2, %cl
cmovel %r8d, %esi
cmpb $0x3, %cl
cmovel %r15d, %esi
cmpb $0x4, %cl
cmovel %edi, %esi
movq 0x90(%rsp), %rax
movl %esi, (%rax,%rbx,4)
incq %rbx
cmpl %ebx, %r9d
jne 0x12a58
movq 0x70(%rsp), %rax
movq 0xe8(%rsp), %rdx
cmpl $-0x2, (%rax,%rdx,4)
movq 0x80(%rsp), %r12
movq 0x78(%rsp), %rbx
movq 0x88(%rsp), %r11
jg 0x12b7f
movq 0x48(%rsp), %rcx
cmpl $-0x2, (%rcx,%rdx,4)
jg 0x12b7f
movq 0x38(%rsp), %rcx
cmpl $-0x2, (%rcx,%rdx,4)
jg 0x12b7f
movq 0x40(%rsp), %rcx
cmpl $-0x2, (%rcx,%rdx,4)
jg 0x12b7f
movq 0x30(%rsp), %rcx
cmpl $-0x1, (%rcx,%rdx,4)
jl 0x12b88
movl 0x5c(%rsp), %ecx
movl %ecx, 0x10(%r12)
movslq 0xc(%rsp), %rcx
cmpl $-0x2, (%rax,%rcx,4)
movq 0xe0(%rsp), %r14
movq 0x28(%rsp), %rsi
movq 0x108(%rsp), %r15
jg 0x12bd4
movq 0x48(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x12bd4
movq 0x38(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x12bd4
movq 0x40(%rsp), %rax
cmpl $-0x2, (%rax,%rcx,4)
jg 0x12bd4
movq 0x30(%rsp), %rax
cmpl $-0x1, (%rax,%rcx,4)
jl 0x12bdd
movl 0xc(%rsp), %eax
movl %eax, 0x14(%r12)
cmpb $0x0, (%r12)
jne 0x12bfc
movq %r12, %rdi
movl %r14d, %edx
callq 0x12f05
movq 0x28(%rsp), %rsi
movq 0x88(%rsp), %r11
movq 0x20(%rsp), %rbp
movq 0x68(%rsp), %r13
movl 0x54(%rsp), %eax
cmpl %eax, %r15d
jg 0x124e7
movq 0x10(%rsp), %r14
movslq %r14d, %rbp
leaq (,%rbp,8), %rbx
movq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x31c1
movq %rax, %r12
testl %ebp, %ebp
jle 0x12d0d
movl %r14d, %eax
movl 0x58(%rsp), %r13d
leaq -0x1(%rax), %rcx
movq %rcx, %rdx
shlq $0x5, %rdx
movq 0x18(%rsp), %rsi
movslq 0x4(%rsi,%rdx), %rdi
testq %rdi, %rdi
jle 0x12dc1
addq 0x18(%rsp), %rdx
movq %rdi, %r8
negq %r8
xorl %r9d, %r9d
movb $0x1, %r11b
movl $0x1, %esi
movl %r13d, %r14d
subl %r9d, %r14d
jl 0x12c93
movq 0x18(%rdx), %r10
movl -0x8(%r10,%rsi,8), %r15d
addl %r9d, %r15d
cmpl %r15d, %r13d
jl 0x12cb8
movq 0x18(%rdx), %r10
addl -0x8(%r10,%rsi,8), %r9d
cmpq %rdi, %rsi
setb %r11b
leaq (%r8,%rsi), %r10
incq %r10
incq %rsi
cmpq $0x1, %r10
jne 0x12c7a
jmp 0x12dc1
testb $0x1, %r11b
je 0x12dc1
movl 0x8(%rdx), %r8d
subl %edi, %r8d
leal (%rsi,%r8), %edi
movl %edi, (%r12,%rcx,8)
movslq %r14d, %rdi
imulq $0x66666667, %rdi, %rdi # imm = 0x66666667
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x21, %rdi
addl %r8d, %edi
addl -0x4(%r10,%rsi,8), %edi
movl %edi, 0x4(%r12,%rcx,8)
movq 0x10(%rdx), %rdx
movslq %r13d, %rsi
movl (%rdx,%rsi,4), %r13d
cmpq $0x1, %rax
movq %rcx, %rax
jg 0x12c46
jmp 0x12d12
movl 0x58(%rsp), %r13d
cmpl $-0x1, %r13d
jne 0x12e1e
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x12d2d
callq 0x30b8
jmp 0x12d8d
cmpl $0x0, 0x10(%rsp)
jle 0x12d5b
movq 0x18(%rsp), %rax
leaq 0x18(%rax), %r14
movq -0x8(%r14), %rsi
xorl %edi, %edi
callq 0x30f6
movq (%r14), %rsi
xorl %edi, %edi
callq 0x30f6
addq $0x20, %r14
decq %rbp
jne 0x12d3d
xorl %edi, %edi
movq 0x18(%rsp), %rsi
callq 0x30f6
movq 0x80(%rsp), %rdi
callq 0x132e5
movq 0x68(%rsp), %rdi
callq 0x132e5
xorl %edi, %edi
movq 0x98(%rsp), %rsi
callq 0x30f6
movq 0xd0(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3366
movq 0x170(%rsp), %rcx
movq 0x10(%rsp), %rdx
movl %edx, (%rcx)
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16044(%rip), %rdi     # 0x28e0c
leaq 0x15f45(%rip), %rsi     # 0x28d14
leaq 0x16044(%rip), %rcx     # 0x28e1a
movl $0x21e, %edx            # imm = 0x21E
callq 0x2160
leaq 0x15fa3(%rip), %rdi     # 0x28d8a
leaq 0x15f26(%rip), %rsi     # 0x28d14
leaq 0x15fa0(%rip), %rcx     # 0x28d95
movl $0x1d9, %edx            # imm = 0x1D9
callq 0x2160
leaq 0x15f0a(%rip), %rdi     # 0x28d10
leaq 0x15f07(%rip), %rsi     # 0x28d14
leaq 0x15f0a(%rip), %rcx     # 0x28d1e
movl $0x237, %edx            # imm = 0x237
callq 0x2160
leaq 0x1603a(%rip), %rdi     # 0x28e5f
leaq 0x15ee8(%rip), %rsi     # 0x28d14
leaq 0x15fe7(%rip), %rcx     # 0x28e1a
movl $0x223, %edx            # imm = 0x223
callq 0x2160