// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, 0x20(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x28(%rsp)
xorpd %xmm0, %xmm0
leaq 0x60(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x20
popq %r13
xorl %eax, %eax
movq %r8, 0x30(%rsp)
cmpq %rax, (%r8)
jbe 0x1d8e9
movq %rax, 0x58(%rsp)
movq 0x18(%r8), %rbp
movl -0x10(%rbp,%r13), %eax
movl %eax, 0x1c(%rsp)
movl -0xc(%rbp,%r13), %eax
movl %eax, 0xc(%rsp)
movq -0x20(%rbp,%r13), %rax
movq -0x18(%rbp,%r13), %r15
movq 0x10(%rsp), %rdi
movq (%rdi), %r14
leaq -0x1(%r15), %r12
cmpq %r14, %rax
movq %rax, 0x40(%rsp)
cmovlq %rax, %r12
cmpq %r12, %r14
movq %r12, %rax
notq %rax
leaq (%rax,%r14,2), %rbx
cmovgq %r12, %rbx
movq %rbx, %rsi
callq 0xf933
movq %rbp, 0x48(%rsp)
cmpl -0x8(%rbp,%r13), %eax
movq %r13, 0x50(%rsp)
jne 0x1d906
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rcx
cltq
imulq $0x28, %rax, %rax
movq %rax, 0x38(%rsp)
subl (%rcx,%rax), %ebx
movq 0x20(%rsp), %rbp
movq 0x8(%rbp), %rdi
leaq 0x60(%rsp), %r13
movq %r13, %rsi
callq 0x1d923
pushq $0x9
popq %rdi
movq %r13, %rsi
callq 0x1d946
movl (%rbp), %edi
movq %r13, %rsi
callq 0x1d9da
pushq $0x9
popq %rbp
movl %ebp, %edi
movq %r13, %rsi
callq 0x1d946
cmpq %r12, %r14
movl 0x1c(%rsp), %eax
movl %eax, %r14d
movl 0xc(%rsp), %edi
cmovgl %edi, %r14d
cmovgl %eax, %edi
movl %edi, 0xc(%rsp)
movq %r13, %rsi
callq 0x1d9da
movl %ebp, %edi
movq %r13, %rsi
callq 0x1d946
movl %r14d, %edi
movq %r13, %rsi
callq 0x1d9da
movl %ebp, %edi
movq %r13, %rsi
callq 0x1d946
movq 0x10(%rsp), %r12
movq 0x10(%r12), %rax
movq 0x38(%rsp), %rbp
movq 0x18(%rax,%rbp), %rdi
movq %r13, %rsi
callq 0x1d923
pushq $0x9
popq %rdi
movq %r13, %rsi
callq 0x1d946
movq 0x10(%r12), %rax
movl 0x8(%rax,%rbp), %edi
movq %r13, %rsi
callq 0x1d9da
pushq $0x9
popq %rbp
movl %ebp, %edi
movq %r13, %rsi
callq 0x1d946
movl %ebx, %edi
movq %r13, %rsi
callq 0x1d9da
movl %ebp, %edi
movq %r13, %rsi
callq 0x1d946
subq 0x40(%rsp), %r15
leal (%r15,%rbx), %edi
movq %r13, %rsi
callq 0x1d9da
movl %ebp, %edi
movq %r13, %rsi
callq 0x1d946
movq 0x50(%rsp), %rbx
movq 0x48(%rsp), %rax
cvtsi2sdl (%rax,%rbx), %xmm0
movq 0x28(%rsp), %rax
cvtsi2sdl (%rax), %xmm1
subl 0xc(%rsp), %r14d
movslq %r14d, %rax
cmpq %rax, %r15
cmovleq %rax, %r15
divsd %xmm1, %xmm0
cvtsi2sd %r15, %xmm1
divsd %xmm1, %xmm0
movq %r13, %rdi
leaq 0x65f2(%rip), %rsi      # 0x23eb0
movb $0x1, %al
callq 0xd490
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x1d946
movq 0x58(%rsp), %rax
incq %rax
addq $0x60, %rbx
movq 0x30(%rsp), %r8
movq %rbx, %r13
jmp 0x1d708
movq 0x70(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rax, 0x28(%rcx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6ce3(%rip), %rdi      # 0x245f0
leaq 0x6cb4(%rip), %rsi      # 0x245c8
leaq 0x6ce3(%rip), %rcx      # 0x245fe
pushq $0x64
popq %rdx
callq 0x31a0