// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/splitidx.c
// Function: mm_split_merge_prep
mm_idx_t *mm_split_merge_prep(const char *prefix, int n_splits, FILE **fp, uint32_t *n_seq_part)
{
	mm_idx_t *mi = 0;
	char *fn;
	int i, j;

	if (n_splits < 1) return 0;
	fn = CALLOC(char, strlen(prefix) + 10);
	for (i = 0; i < n_splits; ++i) {
		sprintf(fn, "%s.%.4d.tmp", prefix, i);
		if ((fp[i] = fopen(fn, "rb")) == 0) {
			if (mm_verbose >= 1)
				fprintf(stderr, "ERROR: failed to open temporary file '%s': %s\n", fn, strerror(errno));
			for (j = 0; j < i; ++j)
				fclose(fp[j]);
			free(fn);
			return 0;
		}
	}
	free(fn);

	mi = CALLOC(mm_idx_t, 1);
	for (i = 0; i < n_splits; ++i) {
		mm_err_fread(&mi->k, 4, 1, fp[i]); // TODO: check if k is all the same
		mm_err_fread(&n_seq_part[i], 4, 1, fp[i]);
		mi->n_seq += n_seq_part[i];
	}
	mi->seq = CALLOC(mm_idx_seq_t, mi->n_seq);
	for (i = j = 0; i < n_splits; ++i) {
		uint32_t k;
		for (k = 0; k < n_seq_part[i]; ++k, ++j) {
			uint32_t l;
			mm_err_fread(&l, 1, 4, fp[i]);
			mi->seq[j].name = (char*)calloc(l + 1, 1);
			mm_err_fread(mi->seq[j].name, 1, l, fp[i]);
			mm_err_fread(&mi->seq[j].len, 4, 1, fp[i]);
		}
	}
	return mi;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpl $0x1, -0x14(%rbp)
jge 0x19c62
movq $0x0, -0x8(%rbp)
jmp 0x19f33
movq -0x10(%rbp), %rdi
callq 0x2130
movq %rax, %rdi
addq $0xa, %rdi
movl $0x1, %esi
callq 0x2220
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x19d6a
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl -0x3c(%rbp), %ecx
leaq 0x3df45(%rip), %rsi     # 0x57bea
movb $0x0, %al
callq 0x23c0
movq -0x38(%rbp), %rdi
leaq 0x3d261(%rip), %rsi     # 0x56f18
callq 0x2380
movq -0x20(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x19d5a
leaq 0x44a37(%rip), %rax     # 0x5e710
cmpl $0x1, (%rax)
jl 0x19d19
movq 0x44313(%rip), %rax     # 0x5dff8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
callq 0x2060
movl (%rax), %edi
callq 0x2410
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
leaq 0x3df23(%rip), %rsi     # 0x57c35
movb $0x0, %al
callq 0x2250
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x19d44
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2120
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x19d20
movq -0x38(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
jmp 0x19f33
jmp 0x19d5c
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x19c87
movq -0x38(%rbp), %rdi
callq 0x2040
movl $0x1, %edi
movl $0x60, %esi
callq 0x2220
movq %rax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x19e02
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x55c0
movq -0x28(%rbp), %rdi
movslq -0x3c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x55c0
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x30(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x19d8d
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edi
movl $0x18, %esi
callq 0x2220
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x19f2b
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x28(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jae 0x19f1b
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x55c0
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2220
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x40(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x40(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movl -0x48(%rbp), %eax
movl %eax, %edx
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x1, %esi
callq 0x55c0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movslq -0x40(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x10, %rdi
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x55c0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x19e41
jmp 0x19f1d
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x19e2e
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)