// File: /workspace/github_c_makefile_star2_O3/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
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jne 0xdcf4
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 0xcc6e
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0xdcf4
movq %r12, 0x28(%rsp)
movq 0xe8(%r12), %rax
movq %rax, 0x20(%rsp)
movl %ebx, 0x58(%rsp)
movl %ebx, %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0x2230
movq %rax, %r14
movq %rax, 0x70(%rsp)
movl $0x4, %esi
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 0x11e29
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0xdbee
movq %rax, %r12
cmpl $0x1, %ebx
jbe 0xdc03
leaq 0x1(%r15), %rax
movl -0xc(%r13,%rax,4), %ecx
movl %ecx, -0x8(%r13,%rax,4)
decq %rax
cmpq $0x2, %rax
ja 0xdbb1
movl $0x0, (%r13)
cmpl $0x2, %ebx
jb 0xdc0b
movl (%r13), %eax
movl $0x1, %ecx
addl (%r13,%rcx,4), %eax
movl %eax, (%r13,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0xdbda
jmp 0xdc0b
movq %r14, %rdi
callq 0x2040
movq %r13, %rdi
callq 0x2040
jmp 0xdcf4
movl $0x0, (%r13)
movq 0x8(%rsp), %rax
testb $0x8, (%rax)
je 0xdc55
cmpl $0x0, 0x10(%r12)
jle 0xdc55
movl $0x10, %r13d
leaq 0x1fcb7(%rip), %r14     # 0x2d8e1
xorl %ebp, %ebp
movq 0x20(%r12), %rax
movq -0x10(%rax,%r13), %rsi
movl (%rax,%r13), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2150
incq %rbp
movslq 0x10(%r12), %rax
addq $0x18, %r13
cmpq %rax, %rbp
jl 0xdc2c
leaq -0xf63(%rip), %rsi      # 0xccf9
leaq 0x10(%rsp), %r14
movl $0x2, %edi
movq %r14, %rdx
movl $0x3, %ecx
callq 0x12278
movq 0x40(%r14), %rdi
callq 0x2040
movq %r12, %rdi
callq 0x6b4d
movq 0x50(%r14), %rdi
callq 0x2040
xorl %r14d, %r14d
movq 0x70(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x2120
incq %r14
cmpq %r14, %r15
jne 0xdc90
movq 0x70(%rsp), %rdi
callq 0x2040
cmpl $0x0, 0x18(%rsp)
movq 0x8(%rsp), %r15
jle 0xdcda
xorl %r14d, %r14d
movq 0x30(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x13060
incq %r14
movslq 0x18(%rsp), %rax
cmpq %rax, %r14
jl 0xdcbf
movq 0x30(%rsp), %rdi
callq 0x2040
movq 0x100(%r15), %rdi
movl %ebx, %esi
callq 0x1204f
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq