// File: chhylp123[P]hifiasm/sketch.cpp
// Function: debug_refine(ha_mz1_t*, unsigned long*, int, int, int, int)
void debug_refine(ha_mz1_t *ma, uint64_t *mmt, int32_t sn, int32_t n, int32_t m, int32_t end)
{
	uint64_t ks = end;
	int64_t t = 0, i, k, sp = -1, ep = -1, ovlp, tot = mmt[end]&0xffffffff, nt = 0;;
	while (ks != 0xffffffff)
	{
		i = ks/m; k = ks%m;
		ks = mmt[ks]>>32;
		if(ks == 0xffffffff || (int32_t)(ks/m) == (i-1))
		{
			t++;
			ovlp = ((MIN(ep, (int64_t)ma[k].pos) >= MAX(sp, (int64_t)(ma[k].pos+1-ma[k].span)))? 
						MIN(ep, (int64_t)ma[k].pos) - MAX(sp, (int64_t)(ma[k].pos+1-ma[k].span)) + 1:0);
			if(ovlp != 0) fprintf(stderr, "ERROR-OVLP\n");
			if(sp == -1 || sp > (ma[k].pos+1-ma[k].span)) sp = ma[k].pos+1-ma[k].span;
			if(ep == -1 || ep < ma[k].pos) ep = ma[k].pos;
			nt += (ma[k].rid);
		}
	}
	if(t != sn) fprintf(stderr, "ERROR-TN, t: %ld, sn: %d\n", t, sn);
	if(nt != tot) fprintf(stderr, "ERROR-TOT, nt: %ld, tot: %ld\n", nt, tot);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movslq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $-0x1, -0x48(%rbp)
movq $-0x1, -0x50(%rbp)
movq -0x10(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq (%rcx,%rdx,8), %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x28(%rbp)
je 0x193078
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x28(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x28(%rbp)
je 0x192d23
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
cltq
movq -0x38(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x193073
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x1c, %rcx
andq $0x7ffffff, %rcx        # imm = 0x7FFFFFF
cmpq %rcx, %rax
jg 0x192d60
movq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x192d81
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x1c, %rcx
andq $0x7ffffff, %rcx        # imm = 0x7FFFFFF
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0x40(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movq 0x8(%rdx), %rdx
shrq $0x38, %rdx
subl %edx, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x192dd9
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x192e18
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
addl $0x1, %eax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x38, %rcx
subl %ecx, %eax
cltq
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
cmpq %rcx, %rax
jl 0x192f42
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x1c, %rcx
andq $0x7ffffff, %rcx        # imm = 0x7FFFFFF
cmpq %rcx, %rax
jg 0x192e5d
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x192e81
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x48(%rbp), %rax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x1c, %rcx
andq $0x7ffffff, %rcx        # imm = 0x7FFFFFF
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0x40(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movq 0x8(%rdx), %rdx
shrq $0x38, %rdx
subl %edx, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x192ee2
movq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x192f24
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
addl $0x1, %eax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x38, %rcx
subl %ecx, %eax
cltq
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
movq -0x98(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x192f4d
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
jmp 0x192f4d
movq -0xa0(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x192f77
movq 0x23107a(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x1f83e0(%rip), %rsi    # 0x38b350
movb $0x0, %al
callq 0x22a0
cmpq $-0x1, -0x48(%rbp)
je 0x192fc4
movq -0x48(%rbp), %rax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x1c, %rcx
andq $0x7ffffff, %rcx        # imm = 0x7FFFFFF
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0x40(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movq 0x8(%rdx), %rdx
shrq $0x38, %rdx
subl %edx, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jle 0x193003
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
addl $0x1, %eax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x38, %rcx
subl %ecx, %eax
cltq
movq %rax, -0x48(%rbp)
cmpq $-0x1, -0x50(%rbp)
je 0x193031
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
shrq $0x1c, %rcx
andq $0x7ffffff, %rcx        # imm = 0x7FFFFFF
cmpq %rcx, %rax
jge 0x193052
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xfffffff, %rax        # imm = 0xFFFFFFF
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x192cb3
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
je 0x1930a4
movq 0x230f54(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
movl -0x14(%rbp), %ecx
leaq 0x1f82bf(%rip), %rsi    # 0x38b35c
movb $0x0, %al
callq 0x22a0
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x1930ce
movq 0x230f2b(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
leaq 0x1f82af(%rip), %rsi    # 0x38b376
movb $0x0, %al
callq 0x22a0
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)