// File: /workspace/github_cpp_makefile_star2_O3/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)
movq %rsi, %r10
movq %rdi, %r11
movslq %r9d, %r13
movl (%rsi,%r13,8), %eax
movq %rax, 0x8(%rsp)
movslq %r8d, %rbp
movq $-0x1, %r12
xorl %r14d, %r14d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movq $-0x1, %r15
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movq %r13, %rax
xorl %edx, %edx
divq %rbp
movq %rdx, %rcx
movq (%r10,%r13,8), %r13
shrq $0x20, %r13
cmpq %r8, %r13
je 0x11f0bf
movq %rax, %rsi
movq %r13, %rax
xorl %edx, %edx
divq %rbp
cltq
decq %rsi
cmpq %rsi, %rax
jne 0x11f153
shlq $0x4, %rcx
movq 0x8(%r11,%rcx), %rax
movq %rax, %rsi
shrq $0x1c, %rsi
andl $0x7ffffff, %esi        # imm = 0x7FFFFFF
cmpq %rsi, %r12
movq %rsi, %rdx
cmovlq %r12, %rdx
movq %rax, %rdi
shrq $0x38, %rdi
negq %rdi
addq %rdi, %rsi
incq %rsi
cmpq %rsi, %r15
cmovgq %r15, %rsi
subq %rsi, %rdx
jl 0x11f101
cmpq $-0x1, %rdx
jne 0x11f15f
incq %rbx
movq %rax, %rcx
shrq $0x1c, %rcx
andl $0x7ffffff, %ecx        # imm = 0x7FFFFFF
movq %rax, %rdx
shrq $0x38, %rdx
negq %rdx
addq %rcx, %rdx
incq %rdx
cmpq %rdx, %r15
movq %rdx, %rsi
cmovlq %r15, %rsi
cmpq $-0x1, %r15
cmoveq %rdx, %rsi
cmpq %rcx, %r12
movq %rcx, %rdx
cmovgq %r12, %rdx
cmpq $-0x1, %r12
cmoveq %rcx, %rdx
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
addq %rax, %r14
movq %rsi, %r15
movq %rdx, %r12
cmpl $-0x1, %r13d
jne 0x11f08e
jmp 0x11f1a9
leaq (%r11,%rcx), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x175e6d(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
movl $0xb, %esi
movl $0x1, %edx
leaq 0x11b5f7(%rip), %rdi    # 0x23a77e
callq 0x2410
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %rax
movq (%rax), %rax
jmp 0x11f101
movl 0x4(%rsp), %ecx
movslq %ecx, %rax
cmpq %rax, %rbx
jne 0x11f1ce
movq 0x8(%rsp), %rcx
cmpq %rcx, %r14
jne 0x11f1eb
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x175e0b(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x11b5ab(%rip), %rsi    # 0x23a78a
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22b0
jmp 0x11f1b5
movq 0x175dee(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x11b5a8(%rip), %rsi    # 0x23a7a4
movq %r14, %rdx
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0