// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movl %edx, %r10d
movq %rsi, %r12
movq %rdi, 0x18(%rsp)
movslq %r9d, %rbx
movl (%rsi,%rbx,8), %r9d
movslq %r8d, %rbp
pushq $-0x1
popq %r14
xorl %edi, %edi
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq 0x177ac2(%rip), %r8     # 0x252fe0
movq %r14, %r15
xorl %r11d, %r11d
cmpq %r13, %rbx
je 0xdb669
movq %rbx, %rcx
movq (%r12,%rbx,8), %rbx
shrq $0x20, %rbx
cmpq %r13, %rbx
je 0xdb55a
movq %rcx, %rax
xorl %edx, %edx
divq %rbp
movq %rax, %rsi
movq %rbx, %rax
xorl %edx, %edx
divq %rbp
cltq
decq %rsi
cmpq %rsi, %rax
jne 0xdb524
movq %rdi, 0x8(%rsp)
movq %rcx, %rax
xorl %edx, %edx
divq %rbp
shlq $0x4, %rdx
movq 0x18(%rsp), %rax
movq 0x8(%rax,%rdx), %rax
movq %rax, %rsi
shrq $0x1c, %rsi
andl $0x7ffffff, %esi        # imm = 0x7FFFFFF
cmpq %rsi, %r15
movq %rsi, %rcx
cmovlq %r15, %rcx
movq %rax, %rdi
shrq $0x38, %rdi
negq %rdi
addq %rdi, %rsi
incq %rsi
cmpq %rsi, %r14
cmovgq %r14, %rsi
subq %rsi, %rcx
jl 0xdb60d
cmpq $-0x1, %rcx
movq 0x8(%rsp), %rdi
je 0xdb612
movq 0x18(%rsp), %rax
addq %rdx, %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq (%r8), %rcx
leaq 0x1110a2(%rip), %rdi    # 0x1ec670
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
movq %r9, 0x30(%rsp)
movl %r10d, 0x14(%rsp)
movq %r11, 0x28(%rsp)
callq 0x2410
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %r11
movq 0x1779e7(%rip), %r8     # 0x252fe0
movl 0x14(%rsp), %r10d
movq 0x30(%rsp), %r9
movq 0x20(%rsp), %rax
movq (%rax), %rax
jmp 0xdb612
movq 0x8(%rsp), %rdi
incq %rdi
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, %r14
movq %rdx, %rsi
cmovlq %r14, %rsi
cmpq $-0x1, %r14
cmoveq %rdx, %rsi
cmpq %rcx, %r15
movq %rcx, %rdx
cmovgq %r15, %rdx
cmpq $-0x1, %r15
cmoveq %rcx, %rdx
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
addq %rax, %r11
movq %rsi, %r14
movq %rdx, %r15
jmp 0xdb524
movslq %r10d, %rax
cmpq %rax, %rdi
jne 0xdb685
cmpq %r9, %r11
jne 0xdb6b0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rdx
movq (%r8), %rdi
leaq 0x110fea(%rip), %rsi    # 0x1ec67c
movl %r10d, %ecx
xorl %eax, %eax
movq %r9, %rbx
movq %r8, %r14
movq %r11, %r15
callq 0x22b0
movq %r15, %r11
movq %r14, %r8
movq %rbx, %r9
jmp 0xdb671
movq (%r8), %rdi
leaq 0x110fdc(%rip), %rsi    # 0x1ec696
movq %r11, %rdx
movq %r9, %rcx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0