// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x19310f
jmp 0x193744
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x193344
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x193334
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x193204
cmpl $0x0, -0x24(%rbp)
jl 0x19319b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xfffffff, %rax        # imm = 0xFFFFFFF
cmpl $0x0, %eax
jg 0x19319d
jmp 0x1931f6
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jg 0x1931f4
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x24(%rbp), %rdx
movabsq $0x100000000, %rax      # imm = 0x100000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x1931f2
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1931f4
jmp 0x1931f6
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x193167
cmpl $0x0, -0x30(%rbp)
jle 0x193332
cmpl $0x0, -0x2c(%rbp)
jne 0x193332
movq 0x230dc1(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
movl -0x28(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rsi
movq (%rax,%rsi,8), %rax
movl %eax, %eax
movl %eax, %r9d
leaq 0x1f814c(%rip), %rsi    # 0x38b394
movb $0x0, %al
callq 0x22a0
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x193330
cmpl $0x0, -0x24(%rbp)
jl 0x193298
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xfffffff, %rax        # imm = 0xFFFFFFF
cmpl $0x0, %eax
jg 0x19329d
jmp 0x193322
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jg 0x193320
movq 0x230d19(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movl %eax, %edx
leaq 0x1f80dd(%rip), %rsi    # 0x38b3c2
movb $0x0, %al
callq 0x22a0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x24(%rbp), %rdx
movabsq $0x100000000, %rax      # imm = 0x100000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x19331e
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x193320
jmp 0x193322
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x193264
jmp 0x193332
jmp 0x193344
jmp 0x193336
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x19311f
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x193428
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x193402
cmpl $0x0, -0x24(%rbp)
jl 0x193399
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xfffffff, %rax        # imm = 0xFFFFFFF
cmpl $0x0, %eax
jg 0x19339b
jmp 0x1933f4
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movl -0x14(%rbp), %ecx
addl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jg 0x1933f2
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x24(%rbp), %rdx
movabsq $0x100000000, %rax      # imm = 0x100000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x1933f0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1933f2
jmp 0x1933f4
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x193365
cmpl $0x0, -0x30(%rbp)
jle 0x193426
cmpl $0x0, -0x2c(%rbp)
jne 0x193426
movq 0x230bcb(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x1f3e43(%rip), %rsi    # 0x387262
movb $0x0, %al
callq 0x22a0
jmp 0x193428
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x19365e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jg 0x19364e
movl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x19351b
cmpl $0x0, -0x24(%rbp)
jl 0x1934ae
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xfffffff, %rax        # imm = 0xFFFFFFF
cmpl $0x0, %eax
jg 0x1934b0
jmp 0x19350d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x19350b
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x24(%rbp), %rdx
movabsq $0x100000000, %rax      # imm = 0x100000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x193509
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x19350b
jmp 0x19350d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x19347a
cmpl $0x0, -0x30(%rbp)
jle 0x19364c
cmpl $0x0, -0x2c(%rbp)
jne 0x19364c
movq 0x230aaa(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
movl -0x28(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rsi
movq (%rax,%rsi,8), %rax
movl %eax, %eax
movl %eax, %r9d
leaq 0x1f7e6c(%rip), %rsi    # 0x38b3cb
movb $0x0, %al
callq 0x22a0
movl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x19364a
cmpl $0x0, -0x24(%rbp)
jl 0x1935ae
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xfffffff, %rax        # imm = 0xFFFFFFF
cmpl $0x0, %eax
jg 0x1935b3
jmp 0x19363c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x19363a
movq 0x2309ff(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movl %eax, %edx
leaq 0x1f7dc3(%rip), %rsi    # 0x38b3c2
movb $0x0, %al
callq 0x22a0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x24(%rbp), %rdx
movabsq $0x100000000, %rax      # imm = 0x100000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x193638
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x19363a
jmp 0x19363c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x19357a
jmp 0x19364c
jmp 0x19365e
jmp 0x193650
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x193431
cmpl $0x0, -0x20(%rbp)
jge 0x193744
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x19371e
cmpl $0x0, -0x24(%rbp)
jl 0x1936b1
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xfffffff, %rax        # imm = 0xFFFFFFF
cmpl $0x0, %eax
jg 0x1936b3
jmp 0x193710
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x19370e
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x24(%rbp), %rdx
movabsq $0x100000000, %rax      # imm = 0x100000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x19370c
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x19370e
jmp 0x193710
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x19367d
cmpl $0x0, -0x30(%rbp)
jle 0x193742
cmpl $0x0, -0x2c(%rbp)
jne 0x193742
movq 0x2308af(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x1f3cee(%rip), %rsi    # 0x387429
movb $0x0, %al
callq 0x22a0
jmp 0x193744
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)