// File: /workspace/github_c_makefile_star2_O1/lh3[P]minimap2/index.c
// Function: mm_idx_dump
void mm_idx_dump(FILE *fp, const mm_idx_t *mi)
{
	uint64_t sum_len = 0;
	uint32_t x[5], i;

	x[0] = mi->w, x[1] = mi->k, x[2] = mi->b, x[3] = mi->n_seq, x[4] = mi->flag;
	fwrite(MM_IDX_MAGIC, 1, 4, fp);
	fwrite(x, 4, 5, fp);
	for (i = 0; i < mi->n_seq; ++i) {
		if (mi->seq[i].name) {
			uint8_t l = strlen(mi->seq[i].name);
			fwrite(&l, 1, 1, fp);
			fwrite(mi->seq[i].name, 1, l, fp);
		} else {
			uint8_t l = 0;
			fwrite(&l, 1, 1, fp);
		}
		fwrite(&mi->seq[i].len, 4, 1, fp);
		sum_len += mi->seq[i].len;
	}
	for (i = 0; i < 1<<mi->b; ++i) {
		mm_idx_bucket_t *b = &mi->B[i];
		khint_t k;
		idxhash_t *h = (idxhash_t*)b->h;
		uint32_t size = h? h->size : 0;
		fwrite(&b->n, 4, 1, fp);
		fwrite(b->p, 8, b->n, fp);
		fwrite(&size, 4, 1, fp);
		if (size == 0) continue;
		for (k = 0; k < kh_end(h); ++k) {
			uint64_t x[2];
			if (!kh_exist(h, k)) continue;
			x[0] = kh_key(h, k), x[1] = kh_val(h, k);
			fwrite(x, 8, 2, fp);
		}
	}
	if (!(mi->flag & MM_I_NO_SEQ))
		fwrite(mi->S, 4, (sum_len + 7) / 8, fp);
	fflush(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x4(%rsi), %eax
leaq 0x20(%rsp), %r15
movl %eax, (%r15)
movl 0x8(%rsi), %eax
movl %eax, 0x4(%r15)
movl (%rsi), %eax
movl %eax, 0x8(%r15)
movl 0x10(%rsi), %eax
movl %eax, 0xc(%r15)
movl 0xc(%rsi), %eax
movl %eax, 0x10(%r15)
leaq 0x24511(%rip), %rdi     # 0x2c2e9
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x23f0
movl $0x4, %esi
movl $0x5, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x23f0
xorl %ebp, %ebp
cmpl $0x0, 0x10(%r14)
je 0x7eb1
movl $0x10, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x20(%r14), %rax
movq -0x10(%rax,%r13), %rdi
testq %rdi, %rdi
je 0x7e60
callq 0x2130
movq %r12, 0x8(%rsp)
movq %rax, %r12
movsbl %r12b, %edi
movq %rbx, %rsi
callq 0x21f0
movq 0x20(%r14), %rax
movq -0x10(%rax,%r13), %rdi
movzbl %r12b, %edx
movq 0x8(%rsp), %r12
movl $0x1, %esi
movq %rbx, %rcx
callq 0x23f0
jmp 0x7e6a
xorl %edi, %edi
movq %rbx, %rsi
callq 0x21f0
movq 0x20(%r14), %rdi
addq %r13, %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x23f0
movq 0x20(%r14), %rax
movl (%rax,%r13), %eax
addq %rax, %r12
incq %r15
movl 0x10(%r14), %eax
addq $0x18, %r13
cmpq %rax, %r15
jb 0x7e18
addq $0x7, %r12
shrq $0x3, %r12
movq %r12, 0x8(%rsp)
jmp 0x7eba
movq $0x0, 0x8(%rsp)
movq 0x30(%r14), %r15
movl %ebp, %eax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq 0x28(%r15,%rax), %r12
testq %r12, %r12
je 0x7ed9
movl 0x4(%r12), %ecx
jmp 0x7edb
xorl %ecx, %ecx
addq %rax, %r15
movl %ecx, 0x4(%rsp)
leaq 0x18(%r15), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x23f0
movq 0x20(%r15), %rdi
movslq 0x18(%r15), %rdx
movl $0x8, %esi
movq %rbx, %rcx
callq 0x23f0
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq %rbx, %rcx
callq 0x23f0
cmpl $0x0, 0x4(%rsp)
je 0x7f95
cmpl $0x0, (%r12)
je 0x7f95
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x10(%r12), %rax
movl %r13d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %r15d, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x7f85
movq 0x18(%r12), %rax
movq (%rax,%r13,8), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%r12), %rax
movq (%rax,%r13,8), %rax
movq %rax, 0x18(%rsp)
movl $0x8, %esi
movl $0x2, %edx
leaq 0x10(%rsp), %rdi
movq %rbx, %rcx
callq 0x23f0
incq %r13
movl (%r12), %eax
addl $0x2, %r15d
cmpq %rax, %r13
jb 0x7f38
incl %ebp
movb (%r14), %cl
movl %ebp, %eax
shrl %cl, %eax
testl %eax, %eax
je 0x7eba
testb $0x2, 0xc(%r14)
jne 0x7fc3
movq 0x28(%r14), %rdi
movl $0x4, %esi
movq 0x8(%rsp), %rdx
movq %rbx, %rcx
callq 0x23f0
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2300