// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, 0x4(%rsp)
movslq %r9d, %rbx
movl (%rsi,%rbx,8), %eax
movq %rax, 0x8(%rsp)
movslq %r8d, %r12
movq $-0x1, %r14
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
movq $-0x1, %r13
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movq %rbx, %rax
xorl %edx, %edx
divq %r12
movq %rdx, %rbp
movq (%rsi,%rbx,8), %rbx
shrq $0x20, %rbx
cmpq %r9, %rbx
je 0x1194b5
movq %rax, %rcx
movq %rbx, %rax
xorl %edx, %edx
divq %r12
cltq
decq %rcx
cmpq %rcx, %rax
jne 0x119574
shlq $0x4, %rbp
movq 0x8(%rdi,%rbp), %rcx
movq %rcx, %rdx
shrq $0x1c, %rdx
andl $0x7ffffff, %edx        # imm = 0x7FFFFFF
cmpq %rdx, %r14
movq %rdx, %rax
cmovlq %r14, %rax
shrq $0x38, %rcx
negq %rcx
addq %rdx, %rcx
incq %rcx
cmpq %rcx, %r13
cmovgq %r13, %rcx
subq %rcx, %rax
jl 0x1194f8
cmpq $-0x1, %rax
jne 0x11957f
leaq (%rdi,%rbp), %rax
addq $0x8, %rax
cmpq $-0x1, %r13
je 0x119525
movq (%rax), %rcx
movq %rcx, %rdx
shrq $0x1c, %rdx
andl $0x7ffffff, %edx        # imm = 0x7FFFFFF
shrq $0x38, %rcx
subq %rcx, %rdx
incq %rdx
cmpq %rdx, %r13
jle 0x119540
movq (%rax), %rcx
movq %rcx, %r13
shrq $0x1c, %r13
andl $0x7ffffff, %r13d       # imm = 0x7FFFFFF
shrq $0x38, %rcx
subq %rcx, %r13
incq %r13
cmpq $-0x1, %r14
je 0x119558
movq (%rax), %rcx
shrq $0x1c, %rcx
andl $0x7ffffff, %ecx        # imm = 0x7FFFFFF
cmpq %rcx, %r14
jge 0x119566
movq (%rax), %r14
shrq $0x1c, %r14
andl $0x7ffffff, %r14d       # imm = 0x7FFFFFF
incq %r15
movq (%rax), %rax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
addq %rax, %r8
cmpl $-0x1, %ebx
jne 0x119484
jmp 0x1195a3
movq %r8, 0x20(%rsp)
callq 0x154e1
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %r8
jmp 0x1194f8
movl 0x4(%rsp), %ecx
movslq %ecx, %rax
cmpq %rax, %r15
jne 0x1195c8
movq 0x8(%rsp), %rcx
cmpq %rcx, %r8
jne 0x1195eb
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x170a11(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x114fa1(%rip), %rsi    # 0x22e57a
movq %r15, %rdx
xorl %eax, %eax
movq %r8, %rbx
callq 0x22b0
movq %rbx, %r8
jmp 0x1195af
movq 0x1709ee(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x114f98(%rip), %rsi    # 0x22e594
movq %r8, %rdx
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0