// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwamem_extra.c
// Function: mem_reg2ovlp
void mem_reg2ovlp(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, bseq1_t *s, mem_alnreg_v *a)
{
	int i;
	kstring_t str = {0,0,0};
	for (i = 0; i < a->n; ++i) {
		const mem_alnreg_t *p = &a->a[i];
		int is_rev, rid, qb = p->qb, qe = p->qe;
		int64_t pos, rb = p->rb, re = p->re;
		pos = bns_depos(bns, rb < bns->l_pac? rb : re - 1, &is_rev);
		rid = bns_pos2rid(bns, pos);
		assert(rid == p->rid);
		pos -= bns->anns[rid].offset;
		kputs(s->name, &str); kputc('\t', &str);
		kputw(s->l_seq, &str); kputc('\t', &str);
		if (is_rev) qb ^= qe, qe ^= qb, qb ^= qe; // swap
		kputw(qb, &str); kputc('\t', &str); kputw(qe, &str); kputc('\t', &str);
		kputs(bns->anns[rid].name, &str); kputc('\t', &str);
		kputw(bns->anns[rid].len, &str); kputc('\t', &str);
		kputw(pos, &str); kputc('\t', &str); kputw(pos + (re - rb), &str); kputc('\t', &str);
		ksprintf(&str, "%.3f", (double)p->truesc / opt->a / (qe - qb > re - rb? qe - qb : re - rb));
		kputc('\n', &str);
	}
	s->sam = str.s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3130
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x30fc9
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x30d7b
movq -0x70(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x30d8a
movq -0x78(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rsi
leaq -0x54(%rbp), %rdx
callq 0x30fe0
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x179d0
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x30dc0
jmp 0x30ddf
leaq 0xa65a(%rip), %rdi      # 0x3b421
leaq 0xa62b(%rip), %rsi      # 0x3b3f9
movl $0x64, %edx
leaq 0xa655(%rip), %rcx      # 0x3b42f
callq 0x3190
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x58(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x68(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x31040
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movq -0x20(%rbp), %rax
movl (%rax), %edi
leaq -0x48(%rbp), %rsi
callq 0x311d0
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
cmpl $0x0, -0x54(%rbp)
je 0x30e5d
movl -0x60(%rbp), %eax
xorl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
xorl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
xorl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %edi
leaq -0x48(%rbp), %rsi
callq 0x311d0
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movl -0x60(%rbp), %edi
leaq -0x48(%rbp), %rsi
callq 0x311d0
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x58(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x31040
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x58(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edi
leaq -0x48(%rbp), %rsi
callq 0x311d0
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movq -0x68(%rbp), %rax
movl %eax, %edi
leaq -0x48(%rbp), %rsi
callq 0x311d0
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
subq -0x70(%rbp), %rcx
addq %rcx, %rax
movl %eax, %edi
leaq -0x48(%rbp), %rsi
callq 0x311d0
movl $0x9, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movq -0x50(%rbp), %rax
cvtsi2sdl 0x20(%rax), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x60(%rbp), %eax
subl -0x5c(%rbp), %eax
cltq
movq -0x78(%rbp), %rcx
subq -0x70(%rbp), %rcx
cmpq %rcx, %rax
jle 0x30f74
movl -0x60(%rbp), %eax
subl -0x5c(%rbp), %eax
cltq
movq %rax, -0x98(%rbp)
jmp 0x30f83
movq -0x78(%rbp), %rax
subq -0x70(%rbp), %rax
movq %rax, -0x98(%rbp)
movsd -0x90(%rbp), %xmm0
movq -0x98(%rbp), %rax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq -0x48(%rbp), %rdi
leaq 0x9d72(%rip), %rsi      # 0x3ad18
movb $0x1, %al
callq 0x139b0
movl $0xa, %edi
leaq -0x48(%rbp), %rsi
callq 0x31080
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x30d06
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
addq $0xa0, %rsp
popq %rbp
retq
nop