// File: chhylp123[P]hifiasm/inter.cpp
// Function: get_emask_ovlp(idx_emask_t*, unsigned int, unsigned int, unsigned int*, unsigned int*)
emask_t* get_emask_ovlp(idx_emask_t *idx, uint32_t qn, uint32_t tn, uint32_t *occ, uint32_t *st)
{
	emask_t *a = NULL; (*occ) = 0; if(st) (*st) = (uint32_t)-1;
	if(qn >= idx->n) return a;
	uint32_t k;
	for (k = 0; k < idx->a[qn].n && idx->a[qn].a[k].tn < tn; k++);
	if(k < idx->a[qn].n && idx->a[qn].a[k].tn == tn) {
		a = idx->a[qn].a + k; if(st) (*st) = k;
		for ((*occ) = k; k < idx->a[qn].n && idx->a[qn].a[k].tn == tn; k++);
		(*occ) = k - (*occ);
		return a;
	}
	return a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x2cda39
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jb 0x2cda52
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2cdbbc
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movl -0x14(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, -0x35(%rbp)
jae 0x2cdaa3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x18(%rbp), %eax
setb %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x2cdaac
jmp 0x2cdab9
jmp 0x2cdaae
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2cda59
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movl -0x14(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jae 0x2cdbb4
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x18(%rbp), %eax
jne 0x2cdbb4
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2cdb32
movl -0x34(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movl -0x14(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, -0x36(%rbp)
jae 0x2cdb85
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x18(%rbp), %eax
sete %al
movb %al, -0x36(%rbp)
movb -0x36(%rbp), %al
testb $0x1, %al
jne 0x2cdb8e
jmp 0x2cdb9b
jmp 0x2cdb90
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2cdb3b
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
subl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2cdbbc
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)