// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/map.c
// Function: merge_hits
static void merge_hits(step_t *s)
{
	int f, i, k0, k, max_seg = 0, *n_reg_part, *rep_len_part, *frag_gap_part, *qlens;
	void *km;
	FILE **fp = s->p->fp_parts;
	const mm_mapopt_t *opt = s->p->opt;

	km = km_init();
	for (f = 0; f < s->n_frag; ++f)
		max_seg = max_seg > s->n_seg[f]? max_seg : s->n_seg[f];
	qlens = CALLOC(int, max_seg + s->p->n_parts * 3);
	n_reg_part = qlens + max_seg;
	rep_len_part = n_reg_part + s->p->n_parts;
	frag_gap_part = rep_len_part + s->p->n_parts;
	for (f = 0, k = k0 = 0; f < s->n_frag; ++f) {
		k0 = k;
		for (i = 0; i < s->n_seg[f]; ++i, ++k) {
			int j, l, t, rep_len = 0;
			qlens[i] = s->seq[k].l_seq;
			for (j = 0, s->n_reg[k] = 0; j < s->p->n_parts; ++j) {
				mm_err_fread(&n_reg_part[j],    sizeof(int), 1, fp[j]);
				mm_err_fread(&rep_len_part[j],  sizeof(int), 1, fp[j]);
				mm_err_fread(&frag_gap_part[j], sizeof(int), 1, fp[j]);
				s->n_reg[k] += n_reg_part[j];
				if (rep_len < rep_len_part[j])
					rep_len = rep_len_part[j];
			}
			s->reg[k] = CALLOC(mm_reg1_t, s->n_reg[k]);
			for (j = 0, l = 0; j < s->p->n_parts; ++j) {
				for (t = 0; t < n_reg_part[j]; ++t, ++l) {
					mm_reg1_t *r = &s->reg[k][l];
					uint32_t capacity;
					mm_err_fread(r, sizeof(mm_reg1_t), 1, fp[j]);
					r->rid += s->p->rid_shift[j];
					if (opt->flag & MM_F_CIGAR) {
						mm_err_fread(&capacity, 4, 1, fp[j]);
						r->p = (mm_extra_t*)calloc(capacity, 4);
						r->p->capacity = capacity;
						mm_err_fread(r->p, r->p->capacity, 4, fp[j]);
					}
				}
			}
			if (!(opt->flag&MM_F_SR) && s->seq[k].l_seq >= opt->rank_min_len)
				mm_update_dp_max(s->seq[k].l_seq, s->n_reg[k], s->reg[k], opt->rank_frac, opt->a, opt->b);
			for (j = 0; j < s->n_reg[k]; ++j) {
				mm_reg1_t *r = &s->reg[k][j];
				if (r->p) r->p->dp_max2 = 0; // reset ->dp_max2 as mm_set_parent() doesn't clear it; necessary with mm_update_dp_max()
				r->subsc = 0; // this may not be necessary
				r->n_sub = 0; // n_sub will be an underestimate as we don't see all the chains now, but it can't be accurate anyway
			}
			mm_hit_sort(km, &s->n_reg[k], s->reg[k], opt->alt_drop);
			mm_set_parent(km, opt->mask_level, opt->mask_len, s->n_reg[k], s->reg[k], opt->a * 2 + opt->b, opt->flag&MM_F_HARD_MLEVEL, opt->alt_drop);
			if (!(opt->flag & MM_F_ALL_CHAINS)) {
				mm_select_sub(km, opt->pri_ratio, s->p->mi->k*2, opt->best_n, 0, opt->max_gap * 0.8, &s->n_reg[k], s->reg[k]);
				mm_set_sam_pri(s->n_reg[k], s->reg[k]);
			}
			mm_set_mapq2(km, s->n_reg[k], s->reg[k], opt->min_chain_score, opt->a, rep_len, !!(opt->flag & (MM_F_SR|MM_F_SR_RNA)), !!(opt->flag & MM_F_SPLICE));
		}
		if (s->n_seg[f] == 2 && opt->pe_ori >= 0 && (opt->flag&MM_F_CIGAR))
			mm_pair(km, frag_gap_part[0], opt->pe_bonus, opt->a * 2 + opt->b, opt->a, qlens, &s->n_reg[k0], &s->reg[k0]);
	}
	free(qlens);
	km_destroy(km);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x60(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x1a820
movq %rax, -0x48(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x133a8
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0xc(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x1337f
movl -0x1c(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x13394
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13354
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
imull $0x3, 0x48(%rcx), %ecx
addl %ecx, %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x2220
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq 0x48(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq 0x48(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x13a62
movl -0x18(%rbp), %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0xc(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x139ba
movl $0x0, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
movq -0x40(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x48(%rcx), %eax
jge 0x13577
movq -0x28(%rbp), %rdi
movslq -0x5c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x55c0
movq -0x30(%rbp), %rdi
movslq -0x5c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x55c0
movq -0x38(%rbp), %rdi
movslq -0x5c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x55c0
movq -0x28(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x68(%rbp), %eax
movq -0x30(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x13567
movq -0x30(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
jmp 0x13569
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1349b
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movslq (%rax,%rcx,4), %rdi
movl $0x50, %esi
callq 0x2220
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x48(%rcx), %eax
jge 0x136e4
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq -0x28(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x136d4
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x60(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x50, %esi
movl $0x1, %edx
callq 0x55c0
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x70(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rax
andq $0x4, %rax
cmpq $0x0, %rax
je 0x136bb
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
leaq -0x74(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x55c0
movl -0x74(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2220
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x74(%rbp), %ecx
movq -0x70(%rbp), %rax
movq 0x48(%rax), %rax
movl %ecx, (%rax)
movq -0x70(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x70(%rbp), %rax
movq 0x48(%rax), %rax
movl (%rax), %eax
movl %eax, %esi
movq -0x50(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x4, %edx
callq 0x55c0
jmp 0x136bd
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x135cc
jmp 0x136d6
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x135b2
movq -0x58(%rbp), %rax
movq (%rax), %rax
andq $0x1000, %rax           # imm = 0x1000
cmpq $0x0, %rax
jne 0x1376c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x58(%rbp), %rcx
cmpl 0xb0(%rcx), %eax
jl 0x1376c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x58(%rbp), %rax
movss 0xb4(%rax), %xmm0
movq -0x58(%rbp), %rax
movl 0x64(%rax), %ecx
movq -0x58(%rbp), %rax
movl 0x68(%rax), %r8d
callq 0x22860
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x18(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x137e1
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x137c0
movq -0x80(%rbp), %rax
movq 0x48(%rax), %rax
movl $0x0, 0xc(%rax)
movq -0x80(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x80(%rbp), %rax
movl $0x0, 0x34(%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x13773
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movslq -0x18(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x58(%rbp), %rax
movss 0x60(%rax), %xmm0
callq 0x2aae0
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rax
movss 0x50(%rax), %xmm0
movq -0x58(%rbp), %rax
movl 0x54(%rax), %esi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x58(%rbp), %rax
movl 0x64(%rax), %r8d
shll %r8d
movq -0x58(%rbp), %rax
addl 0x68(%rax), %r8d
movq -0x58(%rbp), %rax
movq (%rax), %rax
andq $0x20000000, %rax       # imm = 0x20000000
movl %eax, %r9d
movq -0x58(%rbp), %rax
movss 0x60(%rax), %xmm1
callq 0x2a3b0
movq -0x58(%rbp), %rax
movq (%rax), %rax
andq $0x800000, %rax         # imm = 0x800000
cmpq $0x0, %rax
jne 0x13921
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rax
movss 0x58(%rax), %xmm0
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %esi
shll %esi
movq -0x58(%rbp), %rax
movl 0x5c(%rax), %edx
movq -0x58(%rbp), %rax
cvtsi2sdl 0x1c(%rax), %xmm1
movsd 0x43aa2(%rip), %xmm2    # 0x57368
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %r8d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %r9
movslq -0x18(%rbp), %rax
shlq $0x2, %rax
addq %rax, %r9
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
xorl %ecx, %ecx
movq %rax, (%rsp)
callq 0x2b020
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2ada0
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x58(%rbp), %rax
movl 0x34(%rax), %ecx
movq -0x58(%rbp), %rax
movl 0x64(%rax), %r8d
movl -0x68(%rbp), %r9d
movq -0x58(%rbp), %r10
movabsq $0x8000001000, %rax     # imm = 0x8000001000
andq (%r10), %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %r10d
movq -0x58(%rbp), %rax
movq (%rax), %rax
andq $0x80, %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x2be70
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x13442
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $0x2, (%rax,%rcx,4)
jne 0x13a52
movq -0x58(%rbp), %rax
cmpl $0x0, 0xb8(%rax)
jl 0x13a52
movq -0x58(%rbp), %rax
movq (%rax), %rax
andq $0x4, %rax
cmpq $0x0, %rax
je 0x13a52
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rax
movl (%rax), %esi
movq -0x58(%rbp), %rax
movl 0xbc(%rax), %edx
movq -0x58(%rbp), %rax
movl 0x64(%rax), %ecx
shll %ecx
movq -0x58(%rbp), %rax
addl 0x68(%rax), %ecx
movq -0x58(%rbp), %rax
movl 0x64(%rax), %r8d
movq -0x40(%rbp), %r9
movq -0x8(%rbp), %rax
movq 0x18(%rax), %r10
movslq -0x14(%rbp), %rax
shlq $0x2, %rax
addq %rax, %r10
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x14(%rbp), %r11
shlq $0x3, %r11
addq %r11, %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x18a60
jmp 0x13a54
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13425
movq -0x40(%rbp), %rdi
callq 0x2040
movq -0x48(%rbp), %rdi
callq 0x1a840
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)