// File: /workspace/github_c_makefile_star2_O3/lh3[P]minimap2/index.c
// Function: mm_idx_bed_read_merge
static mm_idx_intv_t *mm_idx_bed_read_merge(const mm_idx_t *mi, const char *fn, int read_junc, int min_sc)
{
	long n = 0, n0 = 0;
	int32_t i;
	mm_idx_intv_t *I;
	I = mm_idx_bed_read_core(mi, fn, read_junc, min_sc);
	if (I == 0) return 0;
	for (i = 0; i < mi->n_seq; ++i) {
		int32_t j, j0, k;
		mm_idx_intv_t *intv = &I[i];
		n0 += intv->n;
		radix_sort_bed(intv->a, intv->a + intv->n); // sort by st
		for (j = 1, j0 = 0; j <= intv->n; ++j) { // sort by st and then by end
			if (j == intv->n || intv->a[j].st != intv->a[j0].st) {
				radix_sort_end(intv->a + j0, intv->a + j);
				j0 = j;
			}
		}
		for (j = 1, j0 = 0, k = 0; j <= intv->n; ++j) { // merge intervals with the same (st, en)
			if (j == intv->n || intv->a[j].st != intv->a[j0].st || intv->a[j].en != intv->a[j0].en) {
				intv->a[k] = intv->a[j0];
				intv->a[k++].cnt = j - j0;
				j0 = j;
			}
		}
		intv->a = REALLOC(mm_idx_intv1_t, intv->a, k);
		intv->n = intv->m = k;
		n += k;
	}
	if (mm_verbose >= 3)
		fprintf(stderr, "[%s] read %ld introns, %ld of which are non-redundant\n", __func__, n0, n);
	return I;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, 0x3c(%rsp)
movl %edx, 0x54(%rsp)
movq %rdi, 0x48(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rsi, %rsi
je 0x8fea
cmpb $0x2d, (%rsi)
jne 0x8fd6
cmpb $0x0, 0x1(%rsi)
je 0x8fea
leaq 0x23c9e(%rip), %rax     # 0x2cc7b
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2350
jmp 0x9007
movq 0x2cfe7(%rip), %rax     # 0x35fd8
movq (%rax), %rdi
callq 0x22b0
leaq 0x23c7b(%rip), %rsi     # 0x2cc7b
movl %eax, %edi
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x9580
movq 0x48(%rsp), %rax
movl 0x10(%rax), %edi
movl $0x10, %esi
callq 0x2230
movq %rax, 0x40(%rsp)
movq %rbx, 0x80(%rsp)
movq %rbx, %rdi
callq 0x12908
leaq 0x60(%rsp), %rdx
movq %rax, 0x58(%rsp)
movq %rax, %rdi
movl $0x2, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x12961
testl %eax, %eax
js 0x93e1
movq 0x70(%rsp), %r12
leaq 0x1(%r12), %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq %rax, 0x8(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq $0x0, 0x18(%rsp)
movzbl -0x1(%r15), %ebx
cmpl $0x9, %ebx
je 0x90a5
testl %ebx, %ebx
jne 0x91b0
movb $0x0, -0x1(%r15)
cmpl $0xb, %r14d
ja 0x91a6
movl %r14d, %eax
leaq 0x24042(%rip), %rcx     # 0x2d100
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x70b7
movl %eax, %r13d
testl %eax, %eax
jns 0x91a6
jmp 0x93cd
callq 0x2460
movq (%rax), %rax
movsbq (%r12), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x91b8
movq %r12, %rdi
callq 0x2360
movq %rax, 0x18(%rsp)
jmp 0x91a6
movq %r12, %rdi
callq 0x2360
movq %rax, 0x10(%rsp)
testl %eax, %eax
jns 0x91a6
jmp 0x93cd
movq %r12, 0x30(%rsp)
movq %r12, 0x20(%rsp)
jmp 0x91a6
movq %r12, %rdi
callq 0x2360
movq %rax, %rbp
testl %eax, %eax
jns 0x91a6
jmp 0x91b8
movb (%r12), %cl
addb $-0x30, %cl
movl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpb $0x9, %cl
ja 0x9163
movq %r12, %rdi
callq 0x2360
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq 0x8(%rsp), %rcx
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl %eax, %ecx
movq %rcx, 0x8(%rsp)
jmp 0x91a6
movb (%r12), %al
xorl %ecx, %ecx
cmpb $0x2d, %al
setne %cl
shll $0x1e, %ecx
addl $0xc0000000, %ecx       # imm = 0xC0000000
cmpb $0x2b, %al
movl $0x40000000, %eax       # imm = 0x40000000
cmovel %eax, %ecx
movq 0x8(%rsp), %rax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
orl %ecx, %eax
movq %rax, 0x8(%rsp)
testb %bl, %bl
je 0x91b8
incl %r14d
movq %r15, %r12
incq %r15
jmp 0x9093
cmpl $0xb, %r14d
setge %al
testl %r13d, %r13d
js 0x93cd
cmpl $0x0, 0x10(%rsp)
js 0x93cd
cmpl %ebp, 0x10(%rsp)
jge 0x93cd
cmpl $0x0, 0x3c(%rsp)
jle 0x91fd
movq 0x8(%rsp), %rcx
leal (,%rcx,4), %ecx
sarl $0x2, %ecx
cmpl 0x3c(%rsp), %ecx
jl 0x93cd
cmpl $0x0, 0x54(%rsp)
sete %cl
movl %r13d, %r13d
shlq $0x4, %r13
addq 0x40(%rsp), %r13
xorb $0x1, %al
orb %cl, %al
jne 0x9361
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
movq %rax, %r12
movq 0x28(%rsp), %rbx
incq %rbx
movq %rbx, 0x28(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
movq 0x30(%rsp), %r14
incq %r14
movq %r14, 0x30(%rsp)
cmpl $0x2, 0x18(%rsp)
jl 0x93cd
movq %rax, %r15
addl 0x10(%rsp), %r12d
addl %r12d, %r15d
movq %r13, %rax
movl (%r13), %r13d
movq %rax, 0x20(%rsp)
movl 0x4(%rax), %ebp
movq 0x18(%rsp), %rax
decl %eax
movq %rax, 0x18(%rsp)
cmpl %ebp, %r13d
jne 0x92c4
movl %ebp, %r12d
sarl %r12d
addl %ebp, %r12d
testl %ebp, %ebp
movl $0x10, %eax
cmovel %eax, %r12d
movq 0x20(%rsp), %rbp
movq 0x8(%rbp), %rdi
movslq %r12d, %rsi
shlq $0x4, %rsi
callq 0x2320
movq %rax, 0x8(%rbp)
movl %r12d, %ebp
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
movq %rax, %r12
movq 0x28(%rsp), %rbx
incq %rbx
movq %rbx, 0x28(%rsp)
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
movq 0x30(%rsp), %r14
incq %r14
movq %r14, 0x30(%rsp)
addl 0x10(%rsp), %r12d
cmpl %r15d, %r12d
jle 0x933c
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movslq %r13d, %rdx
incl %r13d
shlq $0x4, %rdx
movl %r15d, (%rcx,%rdx)
movl %r12d, 0x4(%rcx,%rdx)
movl $0xffffffff, 0x8(%rcx,%rdx) # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rsi
movl %esi, 0xc(%rcx,%rdx)
addl %eax, %r12d
movl %r12d, %r15d
movq 0x18(%rsp), %rax
decl %eax
movq %rax, 0x18(%rsp)
jne 0x928f
movq 0x20(%rsp), %rax
movl %r13d, (%rax)
movl %ebp, 0x4(%rax)
jmp 0x93cd
movslq (%r13), %rbx
cmpl 0x4(%r13), %ebx
jne 0x93a1
movl %ebx, %eax
sarl %eax
addl %ebx, %eax
testl %ebx, %ebx
movl $0x10, %ecx
cmovel %ecx, %eax
movl %eax, 0x4(%r13)
movq 0x8(%r13), %rdi
movslq %eax, %rsi
shlq $0x4, %rsi
callq 0x2320
movq %rax, 0x8(%r13)
jmp 0x93a5
movq %r12, 0x28(%rsp)
movb $0x1, %al
jmp 0x91bf
movq 0x8(%r13), %rax
leal 0x1(%rbx), %ecx
movl %ecx, (%r13)
shlq $0x4, %rbx
movq 0x10(%rsp), %rcx
movl %ecx, (%rax,%rbx)
movl %ebp, 0x4(%rax,%rbx)
movl $0xffffffff, 0x8(%rax,%rbx) # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rcx
movl %ecx, 0xc(%rax,%rbx)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
leaq 0x60(%rsp), %rdx
jmp 0x904c
movq 0x70(%rsp), %rdi
callq 0x2040
movq 0x58(%rsp), %rdi
callq 0x12945
movq 0x80(%rsp), %rdi
callq 0x2030
movq 0x40(%rsp), %r12
testq %r12, %r12
je 0x9580
movq 0x48(%rsp), %rax
cmpl $0x0, 0x10(%rax)
je 0x9585
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r13d, %r13d
movq %r8, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movq %rcx, %rax
shlq $0x4, %rax
leaq (%r12,%rax), %rbp
movslq (%r12,%rax), %rbx
movq 0x8(%r12,%rax), %r15
movq %rbx, %rsi
shlq $0x4, %rsi
addq %r15, %rsi
movq %r15, %rdi
callq 0x8cc6
testq %rbx, %rbx
movq %rbx, 0x10(%rsp)
jle 0x9531
movq %r13, 0x20(%rsp)
movl %ebx, %ebx
leaq 0x1(%rbx), %r14
leaq 0x10(%r15), %r12
xorl %eax, %eax
movl $0x1, %r13d
movslq %eax, %rdi
cmpq %r13, %rbx
je 0x9495
movl (%r12), %ecx
movq %rdi, %rdx
shlq $0x4, %rdx
cmpl (%r15,%rdx), %ecx
je 0x94a7
shlq $0x4, %rdi
addq %r15, %rdi
movq %r12, %rsi
callq 0x8f3d
movl %r13d, %eax
incq %r13
addq $0x10, %r12
cmpq %r13, %r14
jne 0x947c
testl %ebx, %ebx
movq 0x20(%rsp), %r13
jle 0x9535
xorl %eax, %eax
movl $0x1, %ecx
movl $0x14, %edx
xorl %esi, %esi
movq 0x40(%rsp), %r12
cmpq %rcx, %rbx
jne 0x94d9
movslq %esi, %rdi
jmp 0x94fb
movl -0x4(%r15,%rdx), %r9d
movslq %esi, %rdi
movq %rdi, %r8
shlq $0x4, %r8
cmpl (%r15,%r8), %r9d
jne 0x94fb
addq %r15, %r8
movl (%r15,%rdx), %r9d
cmpl 0x4(%r8), %r9d
je 0x9523
cltq
movq %rax, %r8
shlq $0x4, %r8
shlq $0x4, %rdi
movups (%r15,%rdi), %xmm0
movups %xmm0, (%r15,%r8)
movl %ecx, %edi
subl %esi, %edi
movq 0x8(%rbp), %r15
incl %eax
movl %edi, 0x8(%r15,%r8)
movl %ecx, %esi
incq %rcx
addq $0x10, %rdx
cmpq %rcx, %r14
jne 0x94cf
jmp 0x953c
xorl %eax, %eax
jmp 0x953c
xorl %eax, %eax
movq 0x40(%rsp), %r12
addq 0x10(%rsp), %r13
movslq %eax, %rbx
movq %rbx, %rsi
shlq $0x4, %rsi
movq %r15, %rdi
callq 0x2320
movq %rax, 0x8(%rbp)
movl %ebx, 0x4(%rbp)
movl %ebx, (%rbp)
movq 0x8(%rsp), %r8
addq %rbx, %r8
movq 0x18(%rsp), %rcx
incq %rcx
movq 0x48(%rsp), %rax
movl 0x10(%rax), %eax
cmpq %rax, %rcx
jb 0x9427
jmp 0x958b
xorl %r12d, %r12d
jmp 0x9597
xorl %r13d, %r13d
xorl %r8d, %r8d
leaq 0x2d16e(%rip), %rax     # 0x36700
cmpl $0x3, (%rax)
jge 0x95ac
movq %r12, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ca45(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0x240e8(%rip), %rsi     # 0x2d6a5
leaq 0x24118(%rip), %rdx     # 0x2d6dc
movq %r13, %rcx
xorl %eax, %eax
callq 0x2260
jmp 0x9597