// File: /workspace/github_c_makefile_star2_O1/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, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rsi, %rsi
je 0x9060
movq %rsi, %r14
leaq 0x23747(%rip), %rsi     # 0x2c78a
movq %r14, %rdi
callq 0x2240
testl %eax, %eax
je 0x9060
leaq 0x22c05(%rip), %rsi     # 0x2bc5b
movq %r14, %rdi
callq 0x2350
jmp 0x907d
movq 0x2bf71(%rip), %rax     # 0x34fd8
movq (%rax), %rdi
callq 0x22b0
leaq 0x22be5(%rip), %rsi     # 0x2bc5b
movl %eax, %edi
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x9485
movq 0x40(%rsp), %rax
movl 0x10(%rax), %edi
movl $0x10, %esi
callq 0x2230
movq %rax, 0x30(%rsp)
movq %rbx, 0x80(%rsp)
movq %rbx, %rdi
callq 0x129a4
leaq 0x60(%rsp), %rdx
movq %rax, 0x58(%rsp)
movq %rax, %rdi
movl $0x2, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x12a05
testl %eax, %eax
js 0x945d
leaq 0x23005(%rip), %rbx     # 0x2c0e0
movq 0x70(%rsp), %r15
leaq 0x1(%r15), %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x48(%rsp)
movl $0x3fffffff, %r12d      # imm = 0x3FFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movl $0xffffffff, 0x10(%rsp) # imm = 0xFFFFFFFF
movq $0x0, 0x18(%rsp)
movzbl -0x1(%r14), %r13d
cmpl $0x9, %r13d
je 0x9125
testl %r13d, %r13d
jne 0x9244
movb $0x0, -0x1(%r14)
cmpl $0xb, %ebp
ja 0x9230
movl %ebp, %eax
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
movq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x7108
movl %eax, 0x10(%rsp)
testl %eax, %eax
jns 0x9230
xorl %eax, %eax
xorl %ebp, %ebp
jmp 0x9240
callq 0x2460
movq (%rax), %rax
movsbq (%r15), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x9223
movl $0x9, %ebp
jmp 0x923e
movq %r15, %rdi
callq 0x2360
movq %rax, 0x8(%rsp)
testl %eax, %eax
jns 0x9230
movl $0x1, %ebp
jmp 0x923e
movq %r15, 0x28(%rsp)
jmp 0x9230
movq %r15, 0x20(%rsp)
movl $0xb, %ebp
jmp 0x923e
movq %r15, %rdi
callq 0x2360
movq %rax, 0x48(%rsp)
testl %eax, %eax
jns 0x9230
movl $0x2, %ebp
jmp 0x923e
movb (%r15), %cl
addb $-0x30, %cl
movl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpb $0x9, %cl
ja 0x91ee
movq %r15, %rdi
callq 0x2360
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
andl $0xc0000000, %r12d      # imm = 0xC0000000
orl %eax, %r12d
jmp 0x9230
movb (%r15), %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
andl $0x3fffffff, %r12d      # imm = 0x3FFFFFFF
orl %ecx, %r12d
jmp 0x9230
movq %r15, %rdi
callq 0x2360
movq %rax, 0x18(%rsp)
testb %r13b, %r13b
je 0x923e
incl %ebp
movb $0x1, %al
movq %r14, %r15
jmp 0x9240
xorl %eax, %eax
testb %al, %al
je 0x924c
incq %r14
jmp 0x9111
movl 0x10(%rsp), %ecx
testl %ecx, %ecx
js 0x943c
cmpl $0x0, 0x8(%rsp)
js 0x943c
movq 0x48(%rsp), %rax
cmpl %eax, 0x8(%rsp)
jge 0x943c
cmpl $0x0, 0x3c(%rsp)
jle 0x928e
leal (,%r12,4), %eax
sarl $0x2, %eax
cmpl 0x3c(%rsp), %eax
jl 0x943c
cmpl $0x0, 0x54(%rsp)
sete %al
movl %ecx, %r13d
shlq $0x4, %r13
addq 0x30(%rsp), %r13
cmpl $0xb, %ebp
setl %cl
orb %al, %cl
jne 0x93d6
movq 0x20(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
movq %rax, %r15
incq 0x20(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
incq 0x28(%rsp)
cmpl $0x2, 0x18(%rsp)
jl 0x943c
movq %rax, %r14
addl 0x8(%rsp), %r15d
addl %r15d, %r14d
movl (%r13), %ebp
movq %r13, 0x10(%rsp)
movl 0x4(%r13), %r13d
movq 0x18(%rsp), %rax
decl %eax
movq %rax, 0x18(%rsp)
cmpl %r13d, %ebp
jne 0x934a
movl %r13d, %r15d
sarl %r15d
addl %r13d, %r15d
testl %r13d, %r13d
movl $0x10, %eax
cmovel %eax, %r15d
movq 0x10(%rsp), %r13
movq 0x8(%r13), %rdi
movslq %r15d, %rsi
shlq $0x4, %rsi
callq 0x2320
movq %rax, 0x8(%r13)
movl %r15d, %r13d
movq 0x20(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
movq %rax, %r15
incq 0x20(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0xa, %edx
callq 0x2290
incq 0x28(%rsp)
addl 0x8(%rsp), %r15d
cmpl %r14d, %r15d
jle 0x93b1
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rcx
movslq %ebp, %rdx
incl %ebp
shlq $0x4, %rdx
movl %r14d, (%rcx,%rdx)
movl %r15d, 0x4(%rcx,%rdx)
movl $0xffffffff, 0x8(%rcx,%rdx) # imm = 0xFFFFFFFF
movl %r12d, 0xc(%rcx,%rdx)
addl %eax, %r15d
movl %r15d, %r14d
movq 0x18(%rsp), %rax
decl %eax
movq %rax, 0x18(%rsp)
jne 0x9314
movq 0x10(%rsp), %rax
movl %ebp, (%rax)
movl %r13d, 0x4(%rax)
jmp 0x943c
movslq (%r13), %r14
movl 0x4(%r13), %eax
cmpl %eax, %r14d
jne 0x940b
movl %eax, %ecx
sarl %ecx
addl %eax, %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, 0x4(%r13)
movq 0x8(%r13), %rdi
movslq %ecx, %rsi
shlq $0x4, %rsi
callq 0x2320
movq %rax, 0x8(%r13)
movq 0x8(%r13), %rax
leal 0x1(%r14), %ecx
movl %ecx, (%r13)
shlq $0x4, %r14
movq 0x8(%rsp), %rcx
movl %ecx, (%rax,%r14)
movq 0x48(%rsp), %rcx
movl %ecx, 0x4(%rax,%r14)
movl $0xffffffff, 0x8(%rax,%r14) # imm = 0xFFFFFFFF
movl %r12d, 0xc(%rax,%r14)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
leaq 0x60(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x12a05
testl %eax, %eax
jns 0x90db
movq 0x70(%rsp), %rdi
callq 0x2040
movq 0x58(%rsp), %rdi
callq 0x129e9
movq 0x80(%rsp), %rdi
callq 0x2030
movq 0x30(%rsp), %rbp
jmp 0x9487
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x960d
movq 0x40(%rsp), %rax
cmpl $0x0, 0x10(%rax)
je 0x9611
xorl %ebx, %ebx
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %rbp, 0x30(%rsp)
movq %rbx, %r13
shlq $0x4, %r13
movq %rbp, %r12
addq %r13, %r12
movslq (%rbp,%r13), %rsi
movq 0x8(%rbp,%r13), %rdi
movq %rsi, 0x8(%rsp)
shlq $0x4, %rsi
addq %rdi, %rsi
callq 0x8d34
movl (%rbp,%r13), %ecx
testl %ecx, %ecx
jle 0x9533
xorl %eax, %eax
movl $0x1, %r13d
movl $0x10, %ebp
movl %ecx, %ecx
movslq %eax, %rdi
cmpq %rcx, %r13
je 0x9508
movq 0x8(%r12), %rcx
movl (%rcx,%rbp), %edx
movq %rdi, %rsi
shlq $0x4, %rsi
cmpl (%rcx,%rsi), %edx
je 0x951f
movq 0x8(%r12), %rsi
shlq $0x4, %rdi
addq %rsi, %rdi
addq %rbp, %rsi
callq 0x8fab
movl %r13d, %eax
leaq 0x1(%r13), %rdx
movslq (%r12), %rcx
addq $0x10, %rbp
cmpq %rcx, %r13
movq %rdx, %r13
jl 0x94ea
movl (%r12), %edi
xorl %eax, %eax
testl %edi, %edi
jle 0x95c8
movl $0x1, %edx
movl $0x14, %ecx
xorl %esi, %esi
movq 0x30(%rsp), %rbp
movl %edi, %r8d
movslq %esi, %rdi
cmpq %r8, %rdx
je 0x9581
movq 0x8(%r12), %r8
movl -0x4(%r8,%rcx), %r10d
movq %rdi, %r9
shlq $0x4, %r9
cmpl (%r8,%r9), %r10d
jne 0x9581
addq %r8, %r9
movl (%r8,%rcx), %r8d
cmpl 0x4(%r9), %r8d
je 0x95b2
movq 0x8(%r12), %rsi
cltq
movq %rax, %r8
shlq $0x4, %r8
movq %rdi, %r9
shlq $0x4, %r9
movups (%rsi,%r9), %xmm0
movups %xmm0, (%rsi,%r8)
movl %edx, %esi
subl %edi, %esi
movq 0x8(%r12), %rdi
incl %eax
movl %esi, 0x8(%rdi,%r8)
movl %edx, %esi
leaq 0x1(%rdx), %r8
movslq (%r12), %rdi
addq $0x10, %rcx
cmpq %rdi, %rdx
movq %r8, %rdx
jl 0x9552
jmp 0x95cd
movq 0x30(%rsp), %rbp
addq 0x8(%rsp), %r14
movq 0x8(%r12), %rdi
movslq %eax, %r13
movq %r13, %rsi
shlq $0x4, %rsi
callq 0x2320
movq %rax, 0x8(%r12)
movl %r13d, 0x4(%r12)
movl %r13d, (%r12)
addq %r13, %r15
incq %rbx
movq 0x40(%rsp), %rax
movl 0x10(%rax), %eax
cmpq %rax, %rbx
jb 0x94ac
jmp 0x9617
xorl %ebp, %ebp
jmp 0x9623
xorl %r14d, %r14d
xorl %r15d, %r15d
leaq 0x2c0e2(%rip), %rax     # 0x35700
cmpl $0x3, (%rax)
jge 0x9638
movq %rbp, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b9b9(%rip), %rax     # 0x34ff8
movq (%rax), %rdi
leaq 0x23038(%rip), %rsi     # 0x2c681
leaq 0x23068(%rip), %rdx     # 0x2c6b8
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x2260
jmp 0x9623