// File: /workspace/github_c_makefile_star2_O2/lh3[P]minimap2/map.c
// Function: mm_split_merge
int mm_split_merge(int n_segs, const char **fn, const mm_mapopt_t *opt, int n_split_idx)
{
	int i;
	pipeline_t pl;
	mm_idx_t *mi;
	if (n_segs < 1 || n_split_idx < 1) return -1;
	memset(&pl, 0, sizeof(pipeline_t));
	pl.n_fp = n_segs;
	pl.fp = open_bseqs(pl.n_fp, fn);
	if (pl.fp == 0) return -1;
	pl.opt = opt;
	pl.mini_batch_size = opt->mini_batch_size;

	pl.n_parts = n_split_idx;
	pl.fp_parts  = CALLOC(FILE*, pl.n_parts);
	pl.rid_shift = CALLOC(uint32_t, pl.n_parts);
	pl.mi = mi = mm_split_merge_prep(opt->split_prefix, n_split_idx, pl.fp_parts, pl.rid_shift);
	if (pl.mi == 0) {
		free(pl.fp_parts);
		free(pl.rid_shift);
		return -1;
	}
	for (i = n_split_idx - 1; i > 0; --i)
		pl.rid_shift[i] = pl.rid_shift[i - 1];
	for (pl.rid_shift[0] = 0, i = 1; i < n_split_idx; ++i)
		pl.rid_shift[i] += pl.rid_shift[i - 1];
	if (opt->flag & MM_F_OUT_SAM)
		for (i = 0; i < (int32_t)pl.mi->n_seq; ++i)
			printf("@SQ\tSN:%s\tLN:%d\n", pl.mi->seq[i].name, pl.mi->seq[i].len);

	kt_pipeline(2, worker_pipeline, &pl, 3);

	free(pl.str.s);
	mm_idx_destroy(mi);
	free(pl.rid_shift);
	for (i = 0; i < n_split_idx; ++i)
		fclose(pl.fp_parts[i]);
	free(pl.fp_parts);
	for (i = 0; i < pl.n_fp; ++i)
		mm_bseq_close(pl.fp[i]);
	free(pl.fp);
	mm_split_rm_tmp(opt->split_prefix, n_split_idx);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, %ebx
testl %edi, %edi
setle %al
testl %ecx, %ecx
setle %cl
orb %al, %cl
pushq $-0x1
popq %rbp
jne 0xc5bd
movq %rdx, %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl %edi, 0x18(%rsp)
callq 0xb636
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0xc5bd
movq %r12, 0x28(%rsp)
movq 0xe8(%r12), %rax
movq %rax, 0x20(%rsp)
movl %ebx, 0x58(%rsp)
movl %ebx, %r15d
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x2230
movq %rax, %r14
movq %rax, 0x70(%rsp)
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x2230
movq %rax, %r13
movq %rax, 0x60(%rsp)
movq %r12, 0x8(%rsp)
movq 0x100(%r12), %rdi
movl %ebx, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0x102af
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0xc5ad
movq %rax, %r12
movq %r15, %rax
cmpq $0x2, %rax
jl 0xc4f2
movl -0x8(%r13,%rax,4), %ecx
movl %ecx, -0x4(%r13,%rax,4)
decq %rax
jmp 0xc4dd
andl $0x0, (%r13)
pushq $0x1
popq %rax
cmpq %rax, %r15
je 0xc50e
movl -0x4(%r13,%rax,4), %ecx
addl %ecx, (%r13,%rax,4)
incq %rax
jmp 0xc4fa
movq 0x8(%rsp), %rax
testb $0x8, (%rax)
jne 0xc5ce
leaq -0xe3e(%rip), %rsi      # 0xb6e5
pushq $0x2
popq %rdi
leaq 0x10(%rsp), %r14
pushq $0x3
popq %rcx
movq %r14, %rdx
callq 0x10711
movq 0x40(%r14), %rdi
callq 0x2040
movq %r12, %rdi
callq 0x5951
movq 0x50(%r14), %rdi
callq 0x2040
xorl %r14d, %r14d
movq 0x8(%rsp), %r12
movq 0x70(%rsp), %rdi
cmpq %r14, %r15
je 0xc570
movq (%rdi,%r14,8), %rdi
callq 0x2120
incq %r14
jmp 0xc558
callq 0x2040
xorl %r14d, %r14d
movslq 0x18(%rsp), %rax
movq 0x30(%rsp), %rdi
cmpq %rax, %r14
jge 0xc595
movq (%rdi,%r14,8), %rdi
callq 0x1141b
incq %r14
jmp 0xc578
callq 0x2040
movq 0x100(%r12), %rdi
movl %ebx, %esi
callq 0x104f2
xorl %ebp, %ebp
jmp 0xc5bd
movq %r14, %rdi
callq 0x2040
movq %r13, %rdi
callq 0x2040
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %r14
leaq 0x1c308(%rip), %r13     # 0x288e1
xorl %ebp, %ebp
movslq 0x10(%r12), %rax
cmpq %rax, %rbp
jge 0xc51c
movq 0x20(%r12), %rax
movq -0x10(%rax,%r14), %rsi
movl (%rax,%r14), %edx
movq %r13, %rdi
xorl %eax, %eax
callq 0x2150
incq %rbp
addq $0x18, %r14
jmp 0xc5db