// File: /workspace/github_c_makefile_star2_O1/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 0xddd7
movq %rdx, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x60(%rsp)
movl %edi, 0x8(%rsp)
callq 0xcd46
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0xddd7
movq %r14, 0x18(%rsp)
movq 0xe8(%r14), %rax
movq %rax, 0x10(%rsp)
movl %ebx, 0x48(%rsp)
movl %ebx, %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0x2230
movq %rax, %r12
movq %rax, 0x60(%rsp)
movl $0x4, %esi
movq %r15, %rdi
callq 0x2230
movq %rax, 0x50(%rsp)
movq 0x100(%r14), %rdi
movl %ebx, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0x11eb5
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0xddc3
movq %rax, 0x70(%rsp)
cmpl $0x2, %ebx
jl 0xdcb3
movq 0x50(%rsp), %rax
leaq 0x1(%r15), %rcx
movl -0xc(%rax,%rcx,4), %edx
movl %edx, -0x8(%rax,%rcx,4)
decq %rcx
cmpq $0x2, %rcx
jg 0xdca2
movq 0x50(%rsp), %rax
movl $0x0, (%rax)
cmpl $0x2, %ebx
jl 0xdcd8
movl (%rax), %ecx
movl $0x1, %edx
addl (%rax,%rdx,4), %ecx
movl %ecx, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %r15
jne 0xdcca
testb $0x8, (%r14)
je 0xdd23
movq 0x28(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jle 0xdd23
movl $0x10, %ebp
leaq 0x1ebcc(%rip), %r13     # 0x2c8c1
xorl %r12d, %r12d
movq 0x20(%rax), %rax
movq -0x10(%rax,%rbp), %rsi
movl (%rax,%rbp), %edx
movq %r13, %rdi
xorl %eax, %eax
callq 0x2150
incq %r12
movq 0x28(%rsp), %rax
movslq 0x10(%rax), %rcx
addq $0x18, %rbp
cmpq %rcx, %r12
jl 0xdcf8
leaq -0xf59(%rip), %rsi      # 0xcdd1
movq %rsp, %r13
movl $0x2, %edi
movq %r13, %rdx
movl $0x3, %ecx
callq 0x12308
movq 0x40(%r13), %rdi
callq 0x2040
movq 0x70(%rsp), %rdi
callq 0x6bc5
movq 0x50(%r13), %rdi
callq 0x2040
testl %ebx, %ebx
jle 0xdd78
xorl %r12d, %r12d
movq 0x60(%rsp), %rax
movq (%rax,%r12,8), %rdi
callq 0x2120
incq %r12
cmpq %r12, %r15
jne 0xdd62
movq 0x60(%rsp), %rdi
callq 0x2040
cmpl $0x0, 0x8(%rsp)
jle 0xdda7
xorl %r15d, %r15d
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rdi
callq 0x130f8
incq %r15
movslq 0x8(%rsp), %rax
cmpq %rax, %r15
jl 0xdd8c
movq 0x20(%rsp), %rdi
callq 0x2040
movq 0x100(%r14), %rdi
movl %ebx, %esi
callq 0x120d8
xorl %ebp, %ebp
jmp 0xddd7
movq 0x60(%rsp), %rdi
callq 0x2040
movq 0x50(%rsp), %rdi
callq 0x2040
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq