// File: /workspace/github_c_makefile_star2_O2/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, 0x5c(%rsp)
movq %rdi, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
testq %rsi, %rsi
je 0x7edc
cmpb $0x2d, (%rsi)
jne 0x7ec8
cmpb $0x0, 0x1(%rsi)
je 0x7edc
leaq 0x1fdac(%rip), %rax     # 0x27c7b
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2350
jmp 0x7ef9
movq 0x2a0f5(%rip), %rax     # 0x31fd8
movq (%rax), %rdi
callq 0x22b0
leaq 0x1fd89(%rip), %rsi     # 0x27c7b
movl %eax, %edi
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x842c
movq 0x50(%rsp), %rax
movl 0x10(%rax), %edi
pushq $0x10
popq %rsi
callq 0x2230
movq %rax, 0x40(%rsp)
movq %rbx, 0x68(%rsp)
movq %rbx, %rdi
callq 0x10df8
movq %rax, 0x60(%rsp)
leaq 0x201cd(%rip), %r14     # 0x28100
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rsi
xorl %edx, %edx
callq 0x7927
testl %eax, %eax
js 0x828e
movq 0x80(%rsp), %rbx
leaq 0x1(%rbx), %r15
xorl %r12d, %r12d
movl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq %rax, 0x8(%rsp)
pushq $-0x1
popq %rbp
movl %ebp, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x48(%rsp)
movzbl -0x1(%r15), %r13d
cmpl $0x9, %r13d
je 0x7f91
testl %r13d, %r13d
jne 0x8087
movb $0x0, -0x1(%r15)
cmpl $0xb, %r12d
ja 0x807c
movl %r12d, %eax
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x6048
movl %eax, %ebp
testl %eax, %eax
jns 0x807c
jmp 0x808f
callq 0x2460
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x808f
movq %rbx, %rdi
callq 0x2360
movq %rax, 0x48(%rsp)
jmp 0x807c
movq %rbx, %rdi
callq 0x2360
movq %rax, 0x10(%rsp)
jmp 0x8019
movq %rbx, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
jmp 0x807c
movq %rbx, %rdi
callq 0x2360
movq %rax, 0x18(%rsp)
testl %eax, %eax
jns 0x807c
jmp 0x808f
movb (%rbx), %cl
addb $-0x30, %cl
movl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpb $0x9, %cl
ja 0x803b
movq %rbx, %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 0x807c
movb (%rbx), %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 %r13b, %r13b
je 0x808f
incl %r12d
movq %r15, %rbx
incq %r15
jmp 0x7f7d
cmpl $0xb, %r12d
setge %al
testl %ebp, %ebp
movq 0x30(%rsp), %r14
js 0x7f2c
cmpl $0x0, 0x10(%rsp)
js 0x7f2c
movq 0x18(%rsp), %rcx
cmpl %ecx, 0x10(%rsp)
jge 0x7f2c
cmpl $0x0, 0x3c(%rsp)
jle 0x80dd
movq 0x8(%rsp), %rcx
leal (,%rcx,4), %ecx
sarl $0x2, %ecx
cmpl 0x3c(%rsp), %ecx
jl 0x7f2c
cmpl $0x0, 0x5c(%rsp)
sete %cl
movl %ebp, %r13d
shlq $0x4, %r13
addq 0x40(%rsp), %r13
xorb $0x1, %al
orb %cl, %al
jne 0x821d
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
pushq $0xa
popq %rbp
movl %ebp, %edx
callq 0x2290
movq %rax, %r15
movq 0x20(%rsp), %rbx
incq %rbx
movq %rbx, 0x20(%rsp)
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
movl %ebp, %edx
callq 0x2290
movq 0x28(%rsp), %rbp
incq %rbp
movq %rbp, 0x28(%rsp)
addl 0x10(%rsp), %r15d
addl %eax, %r15d
pushq $0x1
popq %r14
cmpl 0x48(%rsp), %r14d
jge 0x7f2c
movl %r14d, 0x30(%rsp)
movq %r15, 0x18(%rsp)
movslq (%r13), %r12
cmpl 0x4(%r13), %r12d
jne 0x818d
movl %r12d, %eax
sarl %eax
addl %r12d, %eax
testl %r12d, %r12d
pushq $0x10
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x4(%r13)
movq 0x8(%r13), %rdi
movslq %eax, %rsi
shlq $0x4, %rsi
callq 0x2320
movq %rax, 0x8(%r13)
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
movq %r13, %r14
pushq $0xa
popq %r13
movl %r13d, %edx
callq 0x2290
movq %rax, %r15
movq 0x20(%rsp), %rbx
incq %rbx
movq %rbx, 0x20(%rsp)
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
movl %r13d, %edx
movq %r14, %r13
callq 0x2290
movq 0x28(%rsp), %rbp
incq %rbp
movq %rbp, 0x28(%rsp)
addl 0x10(%rsp), %r15d
movq 0x18(%rsp), %rsi
cmpl %esi, %r15d
jle 0x820d
movq 0x8(%r13), %rcx
leal 0x1(%r12), %edx
movl %edx, (%r13)
shlq $0x4, %r12
movl %esi, (%rcx,%r12)
movl %r15d, 0x4(%rcx,%r12)
orl $-0x1, 0x8(%rcx,%r12)
movq 0x8(%rsp), %rdx
movl %edx, 0xc(%rcx,%r12)
addl %eax, %r15d
movl 0x30(%rsp), %r14d
incl %r14d
jmp 0x8145
movslq (%r13), %rbx
cmpl 0x4(%r13), %ebx
jne 0x824f
movl %ebx, %eax
sarl %eax
addl %ebx, %eax
testl %ebx, %ebx
pushq $0x10
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x4(%r13)
movq 0x8(%r13), %rdi
movslq %eax, %rsi
shlq $0x4, %rsi
callq 0x2320
movq %rax, 0x8(%r13)
jmp 0x8253
movq 0x8(%r13), %rax
leal 0x1(%rbx), %ecx
movl %ecx, (%r13)
shlq $0x4, %rbx
movq 0x10(%rsp), %rcx
movl %ecx, (%rax,%rbx)
movq 0x18(%rsp), %rcx
movl %ecx, 0x4(%rax,%rbx)
orl $-0x1, 0x8(%rax,%rbx)
movq 0x8(%rsp), %rcx
movl %ecx, 0xc(%rax,%rbx)
jmp 0x7f2c
movq %rbx, 0x20(%rsp)
movb $0x1, %al
jmp 0x8096
movq 0x80(%rsp), %rdi
callq 0x2040
movq 0x60(%rsp), %rdi
callq 0x10e31
movq 0x68(%rsp), %rdi
callq 0x2030
movq 0x40(%rsp), %rcx
testq %rcx, %rcx
je 0x842c
xorl %edx, %edx
xorl %ebx, %ebx
xorl %r8d, %r8d
movq 0x50(%rsp), %rax
movl 0x10(%rax), %eax
cmpq %rax, %rdx
jae 0x8430
movq %r8, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
movq %rdx, 0x18(%rsp)
movq %rdx, %rax
shlq $0x4, %rax
leaq (%rcx,%rax), %rdx
movq %rdx, 0x30(%rsp)
movl (%rcx,%rax), %ebx
movslq %ebx, %r12
movq 0x8(%rcx,%rax), %r15
movq %r12, %rsi
shlq $0x4, %rsi
addq %r15, %rsi
movq %r15, %rdi
callq 0x7bbf
xorl %eax, %eax
testl %r12d, %r12d
movl $0x0, %r14d
movq %r12, 0x48(%rsp)
cmovgl %r12d, %r14d
movq %r14, %r13
negq %r13
leaq 0x10(%r15), %r12
pushq $0x1
popq %rbp
movq %r13, %rcx
addq %rbp, %rcx
cmpq $0x1, %rcx
je 0x8371
movslq %eax, %rdi
cmpq %rbp, %rbx
je 0x8357
movl (%r12), %ecx
movq %rdi, %rdx
shlq $0x4, %rdx
cmpl (%r15,%rdx), %ecx
je 0x8368
shlq $0x4, %rdi
addq %r15, %rdi
movq %r12, %rsi
callq 0x7e35
movl %ebp, %eax
incq %rbp
addq $0x10, %r12
jmp 0x8332
shlq $0x4, %r14
shlq $0x4, %rbx
addq $-0x10, %rbx
xorl %eax, %eax
pushq $0x1
popq %rcx
xorl %edx, %edx
xorl %esi, %esi
movq 0x30(%rsp), %r13
movslq %esi, %r12
cmpq %rax, %r14
je 0x83ed
movslq %edx, %rdi
cmpq %rax, %rbx
je 0x83bb
movl 0x10(%r15,%rax), %r9d
movq %rdi, %r8
shlq $0x4, %r8
cmpl (%r15,%r8), %r9d
jne 0x83bb
addq %r15, %r8
movl 0x14(%r15,%rax), %r9d
cmpl 0x4(%r8), %r9d
je 0x83e5
movq %r12, %rsi
shlq $0x4, %rsi
shlq $0x4, %rdi
movups (%r15,%rdi), %xmm0
movups %xmm0, (%r15,%rsi)
movl %ecx, %edi
subl %edx, %edi
movq 0x8(%r13), %r15
incl %r12d
movl %edi, 0x8(%r15,%rsi)
movl %ecx, %edx
movl %r12d, %esi
addq $0x10, %rax
incl %ecx
jmp 0x838b
movq 0x8(%rsp), %rbx
addq 0x48(%rsp), %rbx
movq %r12, %rsi
shlq $0x4, %rsi
movq %r15, %rdi
callq 0x2320
movq %rax, 0x8(%r13)
movl %r12d, 0x4(%r13)
movl %r12d, (%r13)
movq 0x10(%rsp), %r8
addq %r12, %r8
movq 0x18(%rsp), %rdx
incq %rdx
movq 0x40(%rsp), %rcx
jmp 0x82c4
xorl %ecx, %ecx
jmp 0x843c
leaq 0x2a2c9(%rip), %rax     # 0x32700
cmpl $0x3, (%rax)
jge 0x8451
movq %rcx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x29ba0(%rip), %rax     # 0x31ff8
movq (%rax), %rdi
leaq 0x20243(%rip), %rsi     # 0x286a5
leaq 0x20273(%rip), %rdx     # 0x286dc
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2260
movq 0x40(%rsp), %rcx
jmp 0x843c