// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
cmpl $0x1, -0x8(%rbp)
jl 0x12c05
cmpl $0x1, -0x1c(%rbp)
jge 0x12c11
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12e78
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x21b0
movl -0x8(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x11d90
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x12c4d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12e78
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq 0xe8(%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x40(%rbp)
movslq -0x40(%rbp), %rdi
movl $0x8, %esi
callq 0x2220
movq %rax, -0x28(%rbp)
movslq -0x40(%rbp), %rdi
movl $0x4, %esi
callq 0x2220
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x100(%rax), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x19c30
movq %rax, -0x90(%rbp)
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x12cd9
movq -0x28(%rbp), %rdi
callq 0x2040
movq -0x38(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12e78
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jle 0x12d0e
movq -0x38(%rbp), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x12ce2
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x12d50
movq -0x38(%rbp), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x12d1f
movq -0x18(%rbp), %rax
movq (%rax), %rax
andq $0x8, %rax
cmpq $0x0, %rax
je 0x12dbb
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x12db9
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
leaq 0x44722(%rip), %rdi     # 0x574c9
movb $0x0, %al
callq 0x2150
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x12d68
jmp 0x12dbb
movl $0x2, %edi
leaq -0xf27(%rip), %rsi      # 0x11ea0
leaq -0x88(%rbp), %rdx
movl $0x3, %ecx
callq 0x1a200
movq -0x48(%rbp), %rdi
callq 0x2040
movq -0x90(%rbp), %rdi
callq 0x7c50
movq -0x38(%rbp), %rdi
callq 0x2040
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x12e21
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2120
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x12dfd
movq -0x28(%rbp), %rdi
callq 0x2040
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x80(%rbp), %eax
jge 0x12e55
movq -0x68(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1bbd0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x12e31
movq -0x68(%rbp), %rdi
callq 0x2040
movq -0x18(%rbp), %rax
movq 0x100(%rax), %rdi
movl -0x1c(%rbp), %esi
callq 0x19f40
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)