// File: /workspace/github_cpp_makefile_star2_O1/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
jg 0x119862
movl %r8d, %r12d
movq %rsi, %rbx
movq %rdi, %r11
movl (%rdi), %r14d
movslq %eax, %rbp
testl %r14d, %r14d
jle 0x119665
movq 0x10(%rbx), %rax
xorl %r15d, %r15d
movl (%rax,%r15,8), %r9d
cmpq %rbp, %r9
jge 0x11966a
incq %r15
cmpq %r15, %r14
jne 0x11964f
movl %r14d, %r15d
jmp 0x1196ba
xorl %r15d, %r15d
jmp 0x1196ba
movq %r12, (%rsp)
movq 0x8(%r11), %rcx
addq $0x8, %rcx
leaq 0x1(%r15), %r12
xorl %esi, %esi
xorl %edi, %edi
xorl %edx, %edx
testl $0xfffffff, (%rcx)      # imm = 0xFFFFFFF
je 0x11969e
movq (%rax,%rsi,8), %r8
movl %r8d, %r10d
cmpq %rbp, %r10
jg 0x11969e
incl %edi
btq $0x20, %r8
adcl $0x0, %edx
incq %rsi
addq $0x10, %rcx
cmpq %rsi, %r12
jne 0x119680
testl %edi, %edi
jle 0x1196b6
testl %edx, %edx
je 0x119888
movq (%rsp), %r12
cmpl %r14d, %r15d
setne %al
testl %r14d, %r14d
setle %cl
orb %al, %cl
jne 0x119715
movq 0x8(%r11), %rax
leaq (,%r14,8), %rdx
xorl %esi, %esi
xorl %edi, %edi
xorl %ecx, %ecx
testl $0xfffffff, 0x8(%rax,%rsi,2) # imm = 0xFFFFFFF
je 0x119700
movq 0x10(%rbx), %r8
movq (%r8,%rsi), %r8
movl %r8d, %r9d
cmpq %rbp, %r9
jg 0x119700
incl %edi
btq $0x20, %r8
adcl $0x0, %ecx
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x1196dc
testl %edi, %edi
jle 0x119715
testl %ecx, %ecx
je 0x119871
movslq %r13d, %rax
leal 0x1(%r12), %ecx
movslq %ecx, %r13
subq %rax, %r13
leaq -0x1(%r14), %rcx
movl %r14d, %edx
testl %edx, %edx
jle 0x11980a
decl %edx
movq 0x10(%rbx), %rax
movl (%rax,%rcx,8), %r9d
decq %rcx
cmpq %r13, %r9
jg 0x11972a
leal 0x1(%rdx), %ebp
cmpl %ebp, %r14d
jl 0x11980c
movq 0x8(%r11), %rcx
movl %edx, %r15d
xorl %esi, %esi
movq %r15, %rdi
xorl %edx, %edx
movq %rdi, %r8
shlq $0x4, %r8
testl $0xfffffff, 0x8(%rcx,%r8) # imm = 0xFFFFFFF
je 0x119786
movq (%rax,%rdi,8), %r8
movl %r8d, %r10d
cmpq %r13, %r10
jl 0x119786
incl %esi
btq $0x20, %r8
adcl $0x0, %edx
incq %rdi
cmpl %edi, %r14d
jg 0x11975e
testl %esi, %esi
jle 0x11980c
testl %edx, %edx
jne 0x11980c
movq 0x170843(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x114e42(%rip), %rsi    # 0x22e5e9
xorl %edx, %edx
movl %r14d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
movq %r11, %r12
callq 0x22b0
movq %r12, %r11
cmpl %ebp, %r14d
jl 0x11980c
movq 0x8(%r11), %rax
movq %r15, %rcx
shlq $0x4, %rcx
testl $0xfffffff, 0x8(%rax,%rcx) # imm = 0xFFFFFFF
je 0x1197e3
movq 0x10(%rbx), %rax
movl (%rax,%r15,8), %edx
cmpq %r13, %rdx
jge 0x1197ed
incq %r15
cmpl %r15d, %r14d
jg 0x1197c1
jmp 0x11980c
movq 0x1707ec(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x114de2(%rip), %rsi    # 0x22e5e0
xorl %eax, %eax
callq 0x22b0
movq %r12, %r11
jmp 0x1197e3
movl %edx, %ebp
testl %ebp, %ebp
setg %al
testl %r14d, %r14d
setle %cl
orb %al, %cl
jne 0x119862
movq 0x8(%r11), %rax
leaq (,%r14,8), %rdx
xorl %esi, %esi
xorl %edi, %edi
xorl %ecx, %ecx
testl $0xfffffff, 0x8(%rax,%rsi,2) # imm = 0xFFFFFFF
je 0x119851
movq 0x10(%rbx), %r8
movq (%r8,%rsi), %r8
movl %r8d, %r9d
cmpq %r13, %r9
jl 0x119851
incl %edi
btq $0x20, %r8
adcl $0x0, %ecx
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x11982d
testl %edi, %edi
jle 0x119862
testl %ecx, %ecx
je 0x119881
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r11, %r15
callq 0x154fd
movq %r15, %r11
jmp 0x119715
callq 0x15519
jmp 0x119862
movq %r13, 0x10(%rsp)
movq 0x17074c(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x114d14(%rip), %rsi    # 0x22e5b2
xorl %edx, %edx
movl %r14d, %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 0x1198d7
movq 0x10(%rbx), %rax
movl (%rax,%r13), %edx
cmpq %rbp, %rdx
jle 0x1198e2
addq $0x8, %r13
decq %r12
jne 0x1198bb
jmp 0x119901
movq 0x1706f7(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x114ced(%rip), %rsi    # 0x22e5e0
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %r11
jmp 0x1198d7
movq (%rsp), %r12
movq 0x10(%rsp), %r13
jmp 0x1196ba