// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/sketch.cpp
// Function: dbg_boundary(ha_mz1_v*, st_mt_t*, int, int, int)
void dbg_boundary(ha_mz1_v *p, st_mt_t *mt, int32_t w, int32_t k, int32_t tot_l)
{
	if(tot_l < w + k -1) return;
	int32_t i, m, n = p->n, s, a;
	for (i = 0; i < n; i++){
		if(GL(*mt, i) >= w+k-1){
			for (m = s = a = 0; m <= i; m++){
				if(!A_M(*p, m)) continue;
				if(GL(*mt, m) <= w+k-1){
					a++;
					if(mt->a[m]&0x100000000) s++;
				}
			}
			if(a > 0 && s == 0){
				fprintf(stderr, "\nERROR1, s: %d, n: %d, tot_l: %d, end_l: %ld\n", s, n, tot_l, GL(*mt, i));
				for (m = s = a = 0; m <= i; m++){
					if(!A_M(*p, m)) continue;
					if(GL(*mt, m) <= w+k-1){
						fprintf(stderr, "lp: %ld\n", GL(*mt, m));
						a++;
						if(mt->a[m]&0x100000000) s++;
					}
				}
				
			} 
			
			break;
		}
	}
	if(i == n){
		for (m = s = a = 0; m < n; m++){
			if(!A_M(*p, m)) continue;
			if(GL(*mt, m) <= w+k-1){
				a++;
				if(mt->a[m]&0x100000000) s++;
			}
		}
		if(a > 0 && s == 0) fprintf(stderr, "ERROR2\n");
	}

	for (i = n-1; i >= 0; i--)
	{
		if (GL(*mt, i) + w <= tot_l + 1) {
			for (m = i, s = a = 0; m < n; m++){
				if(!A_M(*p, m)) continue;
				if(GL(*mt, m) + w >= tot_l + 1){
					a++;
					if(mt->a[m]&0x100000000) s++;
				} 				
			}
			if(a > 0 && s == 0) {
				fprintf(stderr, "\nERROR3, s: %d, n: %d, tot_l: %d, end_l: %ld\n", s, n, tot_l, GL(*mt, i));
				for (m = i, s = a = 0; m < n; m++){
					if(!A_M(*p, m)) continue;
					if(GL(*mt, m) + w >= tot_l + 1){
						fprintf(stderr, "lp: %ld\n", GL(*mt, m));
						a++;
						if(mt->a[m]&0x100000000) s++;
					} 				
				}
			}
			
			break;
		}
	}
	
	if(i < 0){
		for (m = s = a = 0; m < n; m++){
			if(!A_M(*p, m)) continue;
			if(GL(*mt, m) + w >= tot_l + 1){
				a++;
				if(mt->a[m]&0x100000000) s++;
			} 				
		}
		if(a > 0 && s == 0) fprintf(stderr, "ERROR4\n");
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r13d
leal (%rcx,%r13), %eax
decl %eax
cmpl %r8d, %eax
jle 0xdb700
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movq %rdi, %r14
movq %r8, 0x10(%rsp)
movl (%rdi), %r11d
movslq %eax, %r12
xorl %ebp, %ebp
testl %r11d, %r11d
movl $0x0, %r15d
cmovgl %r11d, %r15d
cmpq %rbp, %r15
je 0xdb737
movq 0x10(%rbx), %rax
movl (%rax,%rbp,8), %r9d
cmpq %r12, %r9
jge 0xdb73c
incq %rbp
jmp 0xdb720
movl %r15d, %ebp
jmp 0xdb790
movq %r13, 0x8(%rsp)
movq 0x8(%r14), %rcx
addq $0x8, %rcx
leaq 0x1(%rbp), %r13
xorl %esi, %esi
xorl %edx, %edx
xorl %edi, %edi
cmpq %rsi, %r13
je 0xdb77f
testl $0xfffffff, (%rcx)      # imm = 0xFFFFFFF
je 0xdb776
movq (%rax,%rsi,8), %r8
movl %r8d, %r10d
cmpq %r12, %r10
jg 0xdb776
incl %edi
btq $0x20, %r8
adcl $0x0, %edx
incq %rsi
addq $0x10, %rcx
jmp 0xdb753
testl %edi, %edi
jle 0xdb78b
testl %edx, %edx
je 0xdb972
movq 0x8(%rsp), %r13
cmpl %r11d, %ebp
jne 0xdb7e2
leaq (,%r15,8), %rcx
xorl %edx, %edx
xorl %eax, %eax
xorl %esi, %esi
cmpq %rdx, %rcx
je 0xdb7d6
movq 0x8(%r14), %rdi
testl $0xfffffff, 0x8(%rdi,%rdx,2) # imm = 0xFFFFFFF
je 0xdb7d0
movq 0x10(%rbx), %rdi
movq (%rdi,%rdx), %rdi
movl %edi, %r8d
cmpq %r12, %r8
jg 0xdb7d0
incl %esi
btq $0x20, %rdi
adcl $0x0, %eax
addq $0x8, %rdx
jmp 0xdb7a3
testl %esi, %esi
jle 0xdb7e2
testl %eax, %eax
je 0xdb94b
movslq %r13d, %rax
movq 0x10(%rsp), %r8
leal 0x1(%r8), %ecx
movslq %ecx, %r13
subq %rax, %r13
leaq -0x1(%r11), %rcx
movl %r11d, %edx
testl %edx, %edx
jle 0xdb855
decl %edx
movq 0x10(%rbx), %rax
movl (%rax,%rcx,8), %r9d
decq %rcx
cmpq %r13, %r9
jg 0xdb7fb
movl %edx, %r15d
xorl %ecx, %ecx
movq %r15, %rdx
xorl %esi, %esi
cmpl %edx, %r11d
jle 0xdb8d0
movq 0x8(%r14), %rdi
movq %rdx, %r10
shlq $0x4, %r10
testl $0xfffffff, 0x8(%rdi,%r10) # imm = 0xFFFFFFF
je 0xdb850
movq (%rax,%rdx,8), %rdi
movl %edi, %r10d
cmpq %r13, %r10
jl 0xdb850
incl %esi
btq $0x20, %rdi
adcl $0x0, %ecx
incq %rdx
jmp 0xdb81b
leaq (,%r15,8), %rcx
xorl %edx, %edx
xorl %eax, %eax
xorl %esi, %esi
cmpq %rdx, %rcx
je 0xdb896
movq 0x8(%r14), %rdi
testl $0xfffffff, 0x8(%rdi,%rdx,2) # imm = 0xFFFFFFF
je 0xdb890
movq 0x10(%rbx), %rdi
movq (%rdi,%rdx), %rdi
movl %edi, %r8d
cmpq %r13, %r8
jl 0xdb890
incl %esi
btq $0x20, %rdi
adcl $0x0, %eax
addq $0x8, %rdx
jmp 0xdb863
testl %esi, %esi
jle 0xdb6f1
testl %eax, %eax
jne 0xdb6f1
movq 0x177733(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x10d044(%rip), %rdi    # 0x1e88fb
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2410
testl %esi, %esi
jle 0xdb6f1
testl %ecx, %ecx
jne 0xdb6f1
movq 0x1776f9(%rip), %rbp    # 0x252fe0
movq (%rbp), %rdi
leaq 0x110df9(%rip), %rsi    # 0x1ec6eb
xorl %edx, %edx
movl %r11d, %ecx
xorl %eax, %eax
movq %r11, %r12
callq 0x22b0
movq %r12, %rsi
cmpl %r15d, %esi
jle 0xdb6f1
movq 0x8(%r14), %rax
movq %r15, %rcx
shlq $0x4, %rcx
testl $0xfffffff, 0x8(%rax,%rcx) # imm = 0xFFFFFFF
je 0xdb92f
movq 0x10(%rbx), %rax
movl (%rax,%r15,8), %edx
cmpq %r13, %rdx
jge 0xdb934
incq %r15
jmp 0xdb904
movq (%rbp), %rdi
leaq 0x110da3(%rip), %rsi    # 0x1ec6e2
xorl %eax, %eax
callq 0x22b0
movq %r12, %rsi
jmp 0xdb92f
movq 0x17768e(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x10cdd8(%rip), %rdi    # 0x1e8734
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
movq %r11, %r12
callq 0x2410
movq %r12, %r11
jmp 0xdb7e2
movq 0x177667(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x110d31(%rip), %rsi    # 0x1ec6b4
xorl %edx, %edx
movq %r11, 0x18(%rsp)
movl %r11d, %ecx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
xorl %ecx, %ecx
subq $0x1, %r13
jb 0xdb9e5
movq 0x8(%r14), %rax
testl $0xfffffff, 0x8(%rax,%rcx,2) # imm = 0xFFFFFFF
je 0xdb9bb
movq 0x10(%rbx), %rax
movl (%rax,%rcx), %edx
cmpq %r12, %rdx
jle 0xdb9c1
addq $0x8, %rcx
jmp 0xdb99b
movq 0x177618(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x110d10(%rip), %rsi    # 0x1ec6e2
xorl %eax, %eax
movq %rcx, 0x20(%rsp)
callq 0x22b0
movq 0x20(%rsp), %rcx
jmp 0xdb9bb
movq 0x18(%rsp), %r11
jmp 0xdb78b