// File: /workspace/github_cpp_makefile_star2_O3/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 $0x18, %rsp
movl %edx, %r13d
leal (%rcx,%r13), %eax
decl %eax
cmpl %r8d, %eax
jle 0x11f23f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r8d, %r12d
movq %rsi, %rbx
movq %rdi, %r11
movl (%rdi), %r15d
movslq %eax, %rbp
testl %r15d, %r15d
jle 0x11f275
movq 0x10(%rbx), %rax
xorl %r14d, %r14d
movl (%rax,%r14,8), %r9d
cmpq %rbp, %r9
jge 0x11f27a
incq %r14
cmpq %r14, %r15
jne 0x11f25a
testl %r15d, %r15d
jg 0x11f2da
jmp 0x11f322
xorl %r14d, %r14d
jmp 0x11f2ca
movq %r12, (%rsp)
movq 0x8(%r11), %rcx
addq $0x8, %rcx
leaq 0x1(%r14), %r12
xorl %esi, %esi
xorl %edi, %edi
xorl %edx, %edx
testl $0xfffffff, (%rcx)      # imm = 0xFFFFFFF
je 0x11f2ae
movq (%rax,%rsi,8), %r8
movl %r8d, %r10d
cmpq %rbp, %r10
jg 0x11f2ae
incl %edi
btq $0x20, %r8
adcl $0x0, %edx
incq %rsi
addq $0x10, %rcx
cmpq %rsi, %r12
jne 0x11f290
testl %edi, %edi
jle 0x11f2c6
testl %edx, %edx
je 0x11f49b
movq (%rsp), %r12
testl %r15d, %r15d
setle %al
cmpl %r15d, %r14d
setne %cl
orb %al, %cl
jne 0x11f322
movq 0x8(%r11), %rax
addq $0x8, %rax
xorl %edx, %edx
xorl %esi, %esi
xorl %ecx, %ecx
testl $0xfffffff, (%rax)      # imm = 0xFFFFFFF
je 0x11f30a
movq 0x10(%rbx), %rdi
movq (%rdi,%rdx,8), %rdi
movl %edi, %r8d
cmpq %rbp, %r8
jg 0x11f30a
incl %esi
btq $0x20, %rdi
adcl $0x0, %ecx
incq %rdx
addq $0x10, %rax
cmpq %rdx, %r15
jne 0x11f2e8
testl %esi, %esi
jle 0x11f322
testl %ecx, %ecx
je 0x11f48b
movslq %r13d, %rax
leal 0x1(%r12), %ecx
movslq %ecx, %r13
subq %rax, %r13
leaq -0x1(%r15), %rcx
movl %r15d, %edx
testl %edx, %edx
jle 0x11f429
decl %edx
movq 0x10(%rbx), %rax
movl (%rax,%rcx,8), %r9d
decq %rcx
cmpq %r13, %r9
jg 0x11f337
leal 0x1(%rdx), %ebp
cmpl %ebp, %r15d
jl 0x11f230
movq 0x8(%r11), %rcx
movl %edx, %r14d
xorl %esi, %esi
movq %r14, %rdi
xorl %edx, %edx
movq %rdi, %r8
shlq $0x4, %r8
testl $0xfffffff, 0x8(%rcx,%r8) # imm = 0xFFFFFFF
je 0x11f393
movq (%rax,%rdi,8), %r8
movl %r8d, %r10d
cmpq %r13, %r10
jl 0x11f393
incl %esi
btq $0x20, %r8
adcl $0x0, %edx
incq %rdi
cmpl %edi, %r15d
jg 0x11f36b
testl %esi, %esi
jle 0x11f230
testl %edx, %edx
jne 0x11f230
movq 0x175c2e(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x11b43d(%rip), %rsi    # 0x23a7f9
xorl %edx, %edx
movl %r15d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
movq %r11, %r12
callq 0x22b0
cmpl %ebp, %r15d
jl 0x11f230
movq %r12, %rsi
leaq 0x11b40f(%rip), %rbp    # 0x23a7f0
movq 0x8(%rsi), %rax
movq %r14, %rcx
shlq $0x4, %rcx
testl $0xfffffff, 0x8(%rax,%rcx) # imm = 0xFFFFFFF
je 0x11f403
movq 0x10(%rbx), %rax
movl (%rax,%r14,8), %edx
cmpq %r13, %rdx
jge 0x11f410
incq %r14
cmpl %r14d, %r15d
jg 0x11f3e1
jmp 0x11f230
movq 0x175bc9(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x22b0
movq %r12, %rsi
jmp 0x11f403
testl %r15d, %r15d
jle 0x11f230
movq 0x8(%r11), %rax
leaq (,%r15,8), %rdx
xorl %esi, %esi
xorl %edi, %edi
xorl %ecx, %ecx
testl $0xfffffff, 0x8(%rax,%rsi,2) # imm = 0xFFFFFFF
je 0x11f468
movq 0x10(%rbx), %r8
movq (%r8,%rsi), %r8
movl %r8d, %r9d
cmpq %r13, %r9
jl 0x11f468
incl %edi
btq $0x20, %r8
adcl $0x0, %ecx
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x11f444
testl %edi, %edi
jle 0x11f230
testl %ecx, %ecx
jne 0x11f230
callq 0x14cb5
jmp 0x11f230
movq %r11, %r14
callq 0x14c99
movq %r14, %r11
jmp 0x11f322
movq %r13, 0x10(%rsp)
movq 0x175b39(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x11b311(%rip), %rsi    # 0x23a7c2
xorl %edx, %edx
movl %r15d, %ecx
movq (%rsp), %r8
xorl %eax, %eax
movq %r11, 0x8(%rsp)
callq 0x22b0
movq 0x8(%rsp), %r11
xorl %r13d, %r13d
movq 0x8(%r11), %rax
testl $0xfffffff, 0x8(%rax,%r13,2) # imm = 0xFFFFFFF
je 0x11f4ea
movq 0x10(%rbx), %rax
movl (%rax,%r13), %edx
cmpq %rbp, %rdx
jle 0x11f4f5
addq $0x8, %r13
decq %r12
jne 0x11f4ce
jmp 0x11f514
movq 0x175ae4(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x11b2ea(%rip), %rsi    # 0x23a7f0
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %r11
jmp 0x11f4ea
movq (%rsp), %r12
movq 0x10(%rsp), %r13
jmp 0x11f2ca