// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_rmdup.c
// Function: bam_rmdup_core
void bam_rmdup_core(samfile_t *in, samfile_t *out)
{
	bam1_t *b;
	int last_tid = -1, last_pos = -1;
	tmp_stack_t stack;
	khint_t k;
	khash_t(lib) *aux;
	khash_t(name) *del_set;
	
	aux = kh_init(lib);
	del_set = kh_init(name);
	b = bam_init1();
	memset(&stack, 0, sizeof(tmp_stack_t));

	kh_resize(name, del_set, 4 * BUFFER_SIZE);
	while (samread(in, b) >= 0) {
		bam1_core_t *c = &b->core;
		if (c->tid != last_tid || last_pos != c->pos) {
			dump_best(&stack, out); // write the result
			clear_best(aux, BUFFER_SIZE);
			if (c->tid != last_tid) {
				clear_best(aux, 0);
				if (kh_size(del_set)) { // check
					fprintf(stderr, "[bam_rmdup_core] %llu unmatched pairs\n", (long long)kh_size(del_set));
					clear_del_set(del_set);
				}
				if ((int)c->tid == -1) { // append unmapped reads
					samwrite(out, b);
					while (samread(in, b) >= 0) samwrite(out, b);
					break;
				}
				last_tid = c->tid;
				fprintf(stderr, "[bam_rmdup_core] processing reference %s...\n", in->header->target_name[c->tid]);
			}
		}
		if (!(c->flag&BAM_FPAIRED) || (c->flag&(BAM_FUNMAP|BAM_FMUNMAP)) || (c->mtid >= 0 && c->tid != c->mtid)) {
			samwrite(out, b);
		} else if (c->isize > 0) { // paired, head
			uint64_t key = (uint64_t)c->pos<<32 | c->isize;
			const char *lib;
			lib_aux_t *q;
			int ret;
			lib = bam_get_library(in->header, b);
			q = lib? get_aux(aux, lib) : get_aux(aux, "\t");
			++q->n_checked;
			k = kh_put(pos, q->best_hash, key, &ret);
			if (ret == 0) { // found in best_hash
				bam1_t *p = kh_val(q->best_hash, k);
				++q->n_removed;
				if (sum_qual(p) < sum_qual(b)) { // the current alignment is better; this can be accelerated in principle
					kh_put(name, del_set, strdup(bam1_qname(p)), &ret); // p will be removed
					bam_copy1(p, b); // replaced as b
				} else kh_put(name, del_set, strdup(bam1_qname(b)), &ret); // b will be removed
				if (ret == 0)
					fprintf(stderr, "[bam_rmdup_core] inconsistent BAM file for pair '%s'. Continue anyway.\n", bam1_qname(b));
			} else { // not found in best_hash
				kh_val(q->best_hash, k) = bam_dup1(b);
				stack_insert(&stack, kh_val(q->best_hash, k));
			}
		} else { // paired, tail
			k = kh_get(name, del_set, bam1_qname(b));
			if (k != kh_end(del_set)) {
				free((char*)kh_key(del_set, k));
				kh_del(name, del_set, k);
			} else samwrite(out, b);
		}
		last_pos = c->pos;
	}

	for (k = kh_begin(aux); k != kh_end(aux); ++k) {
		if (kh_exist(aux, k)) {
			lib_aux_t *q = &kh_val(aux, k);			
			dump_best(&stack, out);
			fprintf(stderr, "[bam_rmdup_core] %lld / %lld = %.4lf in library '%s'\n", (long long)q->n_removed,
					(long long)q->n_checked, (double)q->n_removed/q->n_checked, kh_key(aux, k));
			kh_destroy(pos, q->best_hash);
			free((char*)kh_key(aux, k));
		}
	}
	kh_destroy(lib, aux);

	clear_del_set(del_set);
	kh_destroy(name, del_set);
	free(stack.a);
	bam_destroy1(b);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r12
movq %rdi, %rbp
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, %r15
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, %r14
movl $0x1, %edi
movl $0x38, %esi
callq 0x3610
movq %rax, %rbx
movq %r14, 0x20(%rsp)
movq %r14, %rdi
movl $0x100000, %esi         # imm = 0x100000
callq 0xba7d
leaq 0x10(%rbp), %rax
movq %rax, 0x50(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x48(%rsp)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq $0x0, 0x40(%rsp)
xorl %r13d, %r13d
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
movq %r15, 0x18(%rsp)
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x27d67
testl %eax, %eax
js 0xb889
movl 0x30(%rsp), %eax
cmpl %eax, (%rbx)
jne 0xb1a7
cmpl 0x4(%rbx), %r14d
je 0xb20c
movl 0x8(%rsp), %eax
testl %eax, %eax
je 0xb1e6
movl %eax, %r15d
xorl %ebp, %ebp
movq (%r13,%rbp,8), %rsi
movq %r12, %rdi
callq 0x27d9c
movq (%r13,%rbp,8), %rax
testq %rax, %rax
je 0xb1de
movq 0x30(%rax), %rdi
callq 0x3350
movq (%r13,%rbp,8), %rdi
callq 0x3350
incq %rbp
cmpq %rbp, %r15
jne 0xb1b4
movq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0x40000, %esi          # imm = 0x40000
callq 0xbc8e
movl $0x0, 0x8(%rsp)
movl 0x30(%rsp), %eax
cmpl %eax, (%rbx)
jne 0xb370
movq 0x8(%rbx), %rax
movabsq $0xd00000000, %rcx      # imm = 0xD00000000
andq %rcx, %rax
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
jne 0xb358
movl 0x14(%rbx), %eax
testl %eax, %eax
js 0xb23f
cmpl %eax, (%rbx)
jne 0xb358
movslq 0x1c(%rbx), %r14
testq %r14, %r14
jle 0xb3d9
movl 0x4(%rbx), %ebp
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq %rbx, %rsi
callq 0x25967
testq %rax, %rax
leaq 0x35e7f(%rip), %rcx     # 0x410e9
cmoveq %rcx, %rax
movq %r15, %rdi
movq %rax, %rsi
callq 0xbd94
incq (%rax)
movq %rax, 0x28(%rsp)
movq 0x10(%rax), %r15
movl 0x8(%r15), %eax
cmpl 0xc(%r15), %eax
jb 0xb2ae
movl (%r15), %eax
movl 0x4(%r15), %ecx
addl %ecx, %ecx
cmpl %eax, %ecx
movl $0x0, %esi
sbbl %esi, %esi
orl $0x1, %esi
addl %eax, %esi
movq %r15, %rdi
callq 0xc627
shlq $0x20, %rbp
movq %rbp, %r8
orq %r14, %r8
movl (%r15), %r10d
shrq $0x21, %rbp
movl %r14d, %edi
shll $0xb, %edi
xorl %r14d, %edi
xorl %ebp, %edi
movl %edi, %eax
xorl %edx, %edx
divl %r10d
movl %edx, %esi
movq 0x10(%r15), %r9
movl %edx, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %eax
leal (%rsi,%rsi), %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0xb44a
leal -0x1(%r10), %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %esi, %edi
movl %r10d, %eax
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r9,%rcx,4), %r11d
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %r11d, %ebp
shrl %cl, %ebp
testb $0x2, %bpl
jne 0xb424
testb $0x1, %bpl
jne 0xb332
movq 0x18(%r15), %r14
movl %edi, %ebp
cmpq %r8, (%r14,%rbp,8)
je 0xb424
btl %ecx, %r11d
cmovbl %edi, %eax
addl %edx, %edi
cmpl %r10d, %edi
movl %r10d, %ecx
movl $0x0, %r11d
cmovbl %r11d, %ecx
subl %ecx, %edi
movl %eax, %ecx
cmpl %esi, %edi
jne 0xb2fe
jmp 0xb427
movq %r12, %rdi
movq %rbx, %rsi
callq 0x27d9c
movq 0x10(%rsp), %rbp
movl 0x4(%rbx), %r14d
movb $0x1, %al
jmp 0xb3cc
movq %r15, %rdi
xorl %esi, %esi
callq 0xbc8e
movq 0x20(%rsp), %rax
movl 0x4(%rax), %edx
testq %rdx, %rdx
jne 0xb72d
movl (%rbx), %ebp
cmpl $-0x1, %ebp
jne 0xb754
movq %r12, %rdi
movq %rbx, %rsi
callq 0x27d9c
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x27d67
testl %eax, %eax
js 0xb3c2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x27d9c
jmp 0xb3a6
movl $0x0, 0x8(%rsp)
xorl %eax, %eax
testb %al, %al
jne 0xb186
jmp 0xb889
movq 0x20(%rsp), %rax
movl (%rax), %edi
testl %edi, %edi
je 0xb6ec
movq 0x30(%rbx), %rsi
movsbl (%rsi), %ecx
testl %ecx, %ecx
je 0xb769
movb 0x1(%rsi), %al
testb %al, %al
je 0xb76b
leaq 0x2(%rsi), %rdx
movl %ecx, %r8d
shll $0x5, %r8d
subl %ecx, %r8d
movsbl %al, %ecx
addl %r8d, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0xb406
jmp 0xb76b
movl %r10d, %ecx
movl %ecx, %esi
cmpl %r10d, %ecx
jne 0xb44a
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r9,%rcx,4), %edx
leal (%rdi,%rdi), %ecx
shrl %cl, %edx
cmpl %r10d, %eax
cmovel %edi, %eax
testb $0x2, %dl
cmovel %edi, %eax
movl %eax, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %edx
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %edx, %edi
shrl %cl, %edi
movl %esi, %r14d
testb $0x2, %dil
movq 0x10(%rsp), %rbp
jne 0xb47b
testb $0x1, %dil
jne 0xb4a4
movl $0x0, 0xc(%rsp)
jmp 0xb4c7
movl $0x3, %esi
shll %cl, %esi
movq 0x18(%r15), %rcx
movq %r8, (%rcx,%r14,8)
notl %esi
andl %esi, %edx
movl %edx, (%r9,%rax,4)
incl 0x4(%r15)
incl 0x8(%r15)
movl $0x1, 0xc(%rsp)
jmp 0xb4c7
movq 0x18(%r15), %rsi
movl $0x3, %edi
shll %cl, %edi
movq %r8, (%rsi,%r14,8)
notl %edi
andl %edi, %edx
movl %edx, (%r9,%rax,4)
incl 0x4(%r15)
movl $0x2, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0xb5a2
movl $0x1, %edi
movl $0x38, %esi
callq 0x3610
movq %rax, %r15
movupd (%rbx), %xmm0
movupd 0x10(%rbx), %xmm1
movupd 0x20(%rbx), %xmm2
movupd %xmm2, 0x20(%rax)
movupd %xmm0, (%rax)
movupd %xmm1, 0x10(%rax)
movq 0x30(%rbx), %rax
movq %rax, 0x30(%r15)
movslq 0x24(%r15), %rbp
movl %ebp, 0x28(%r15)
movl $0x1, %esi
movq %rbp, %rdi
callq 0x3610
movq %rax, 0x30(%r15)
movq 0x30(%rbx), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x37d0
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rax
movq 0x20(%rax), %rax
movq %r15, (%rax,%r14,8)
movq 0x10(%rcx), %rax
movq 0x20(%rax), %rax
movq (%rax,%r14,8), %r14
movl 0x8(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl %ecx, %eax
jne 0xb584
leal (%rcx,%rcx), %ebp
testl %ecx, %ecx
movl $0x10000, %eax          # imm = 0x10000
cmovel %eax, %ebp
movslq %ebp, %rsi
shlq $0x3, %rsi
movq %r13, %rdi
callq 0x3720
movq %rax, %r13
movl 0x8(%rsp), %eax
movl %ebp, %ecx
movq %rcx, 0x40(%rsp)
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbp
movl %eax, %ecx
cltq
incl %ecx
movl %ecx, 0x8(%rsp)
movq %r14, (%r13,%rax,8)
jmp 0xb368
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rax
movq 0x20(%rax), %rax
movq (%rax,%r14,8), %r15
incq 0x8(%rcx)
movq 0x30(%r15), %rdi
movslq 0x10(%r15), %rax
xorl %ecx, %ecx
movl $0x0, %edx
testq %rax, %rax
jle 0xb600
movq 0x8(%r15), %rdx
movq %rdx, %rsi
shrq $0x30, %rsi
leaq (%rdi,%rsi,4), %rsi
shrl $0x18, %edx
addq %rsi, %rdx
leal 0x1(%rax), %esi
sarl %esi
movslq %esi, %rsi
addq %rdx, %rsi
xorl %r8d, %r8d
xorl %edx, %edx
movzbl (%rsi,%r8), %r9d
addl %r9d, %edx
incq %r8
cmpq %r8, %rax
jne 0xb5f0
movq 0x30(%rbx), %rax
movslq 0x10(%rbx), %rsi
testq %rsi, %rsi
jle 0xb644
movq 0x8(%rbx), %rcx
movq %rcx, %r8
shrq $0x30, %r8
leaq (%rax,%r8,4), %r8
shrl $0x18, %ecx
addq %r8, %rcx
leal 0x1(%rsi), %r8d
sarl %r8d
movslq %r8d, %r8
addq %rcx, %r8
xorl %r9d, %r9d
xorl %ecx, %ecx
movzbl (%r8,%r9), %r10d
addl %r10d, %ecx
incq %r9
cmpq %r9, %rsi
jne 0xb634
cmpl %ecx, %edx
jge 0xb6f4
callq 0x3570
movq 0x20(%rsp), %rdi
movq %rax, %rsi
leaq 0xc(%rsp), %rdx
callq 0xc09d
movq 0x30(%r15), %r14
movl 0x28(%r15), %ebp
movl 0x24(%rbx), %eax
cmpl %eax, %ebp
jge 0xb6a6
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ebp
sarl $0x10, %ebp
orl %eax, %ebp
incl %ebp
movslq %ebp, %rsi
movq %r14, %rdi
callq 0x3720
movq %rax, %r14
movq 0x30(%rbx), %rsi
movslq 0x24(%rbx), %rdx
movq %r14, %rdi
callq 0x37d0
movupd (%rbx), %xmm0
movupd 0x10(%rbx), %xmm1
movupd 0x20(%rbx), %xmm2
movupd %xmm2, 0x20(%r15)
movq 0x30(%rbx), %rax
movq %rax, 0x30(%r15)
movupd %xmm0, (%r15)
movupd %xmm1, 0x10(%r15)
movl %ebp, 0x28(%r15)
movq %r14, 0x30(%r15)
movq 0x10(%rsp), %rbp
jmp 0xb70e
xorl %r15d, %r15d
jmp 0xb827
movq %rax, %rdi
callq 0x3570
movq 0x20(%rsp), %rdi
movq %rax, %rsi
leaq 0xc(%rsp), %rdx
callq 0xc09d
cmpl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %r15
jne 0xb368
movq 0x48(%rsp), %rdi
callq 0x3df0
jmp 0xb368
movq 0x438b4(%rip), %rax     # 0x4efe8
movq (%rax), %rdi
leaq 0x34812(%rip), %rsi     # 0x3ff50
xorl %eax, %eax
callq 0x3750
movq 0x20(%rsp), %rdi
callq 0xbd21
jmp 0xb38b
movq 0x50(%rsp), %rdi
movl %ebp, %esi
callq 0x3dc7
movl %ebp, 0x30(%rsp)
jmp 0xb20c
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %edx, %r9d
leal -0x1(%rdi), %r8d
movl %ecx, %eax
xorl %edx, %edx
divl %r8d
incl %edx
movq 0x20(%rsp), %rax
movq 0x10(%rax), %r8
movl %r9d, %r15d
movq %rbx, 0x60(%rsp)
movq %rdi, 0x28(%rsp)
movl %r9d, 0x3c(%rsp)
movl %edx, 0x38(%rsp)
movq %rsi, 0x58(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %ebp
leal (%r15,%r15), %r14d
andl $0x1e, %r14d
movl %ebp, %eax
movl %r14d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0xb81a
testb $0x1, %al
jne 0xb7fd
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rbx
callq 0x35a0
movq %rbx, %r8
movl 0x38(%rsp), %edx
movl 0x3c(%rsp), %r9d
movq 0x58(%rsp), %rsi
movq 0x28(%rsp), %rdi
movq 0x60(%rsp), %rbx
testl %eax, %eax
je 0xb81a
addl %edx, %r15d
cmpl %edi, %r15d
movl %edi, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %r15d
cmpl %r9d, %r15d
jne 0xb7a5
movl %edi, %r15d
jmp 0xb827
movl %r14d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %edi, %r15d
movq 0x10(%rsp), %rbp
cmpl %edi, %r15d
jne 0xb83e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x27d9c
jmp 0xb87f
movq 0x20(%rsp), %r14
movq 0x18(%r14), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x3350
movq 0x10(%r14), %rax
movl %r15d, %edx
shrl $0x4, %edx
movl (%rax,%rdx,4), %esi
addl %r15d, %r15d
andl $0x1e, %r15d
movl %esi, %edi
movl %r15d, %ecx
shrl %cl, %edi
testb $0x3, %dil
jne 0xb87f
btsl %r15d, %esi
movl %esi, (%rax,%rdx,4)
decl 0x4(%r14)
movq 0x18(%rsp), %r15
jmp 0xb368
movl (%r15), %edx
testq %rdx, %rdx
je 0xb9e5
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rsi
xorl %r15d, %r15d
movq %rdx, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %eax
leal (%r15,%r15), %ecx
shrl %cl, %eax
testb $0x3, %al
je 0xb8cb
incq %r15
cmpq %rdx, %r15
jne 0xb8ab
jmp 0xb9e5
leaq (%r15,%r15,2), %rcx
shlq $0x3, %rcx
movq 0x18(%rsp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x30(%rsp)
movl 0x8(%rsp), %eax
testl %eax, %eax
je 0xb920
movl %eax, %r14d
xorl %ebp, %ebp
movq (%r13,%rbp,8), %rsi
movq %r12, %rdi
callq 0x27d9c
movq (%r13,%rbp,8), %rax
testq %rax, %rax
je 0xb918
movq 0x30(%rax), %rdi
callq 0x3350
movq (%r13,%rbp,8), %rdi
callq 0x3350
incq %rbp
cmpq %rbp, %r14
jne 0xb8ee
movq 0x436c1(%rip), %rax     # 0x4efe8
movq (%rax), %rdi
movq 0x30(%rsp), %r14
movq (%r14), %rcx
movq 0x8(%r14), %rdx
movq %rdx, %xmm1
movq 0x345ed(%rip), %xmm2    # 0x3ff30
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x345f1(%rip), %xmm3    # 0x3ff40
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rcx, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rbp
movq (%rbp,%r15,8), %r8
leaq 0x3465b(%rip), %rsi     # 0x3ffec
movb $0x1, %al
callq 0x3750
movq 0x10(%r14), %r14
testq %r14, %r14
je 0xb9c4
movq 0x18(%r14), %rdi
callq 0x3350
movq 0x10(%r14), %rdi
callq 0x3350
movq 0x20(%r14), %rdi
callq 0x3350
movq %r14, %rdi
callq 0x3350
movq (%rbp,%r15,8), %rdi
callq 0x3350
movl $0x0, 0x8(%rsp)
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %rsi
jmp 0xb8be
movq 0x18(%rsp), %r14
movq 0x18(%r14), %rdi
callq 0x3350
movq 0x10(%r14), %rdi
callq 0x3350
movq 0x20(%r14), %rdi
callq 0x3350
movq %r14, %rdi
callq 0x3350
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0xbd21
testq %r14, %r14
je 0xba42
movq 0x18(%r14), %rdi
callq 0x3350
movq 0x10(%r14), %rdi
callq 0x3350
movq 0x20(%r14), %rdi
callq 0x3350
movq %r14, %rdi
callq 0x3350
movq %r13, %rdi
callq 0x3350
testq %rbx, %rbx
je 0xba6e
movq 0x30(%rbx), %rdi
callq 0x3350
movq %rbx, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3350
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq