// File: /workspace/github_c_makefile_star2_O3/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
movq 0x4(%rsi), %rax
leaq 0x20(%rsp), %r15
movq %rax, (%r15)
movl (%rsi), %eax
movl %eax, 0x8(%r15)
movq 0xc(%rsi), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0xc(%r15)
leaq 0x2556c(%rip), %rdi     # 0x2d30d
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 0x7e7a
movq 0x20(%r14), %rax
movl $0x10, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq -0x10(%rax,%r13), %rdi
testq %rdi, %rdi
je 0x7e29
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 0x7e33
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), %ecx
addq %rcx, %r12
incq %r15
movl 0x10(%r14), %ecx
addq $0x18, %r13
cmpq %rcx, %r15
jb 0x7de5
addq $0x7, %r12
shrq $0x3, %r12
movq %r12, 0x8(%rsp)
jmp 0x7e83
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 0x7ea2
movl 0x4(%r12), %ecx
jmp 0x7ea4
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 0x7f63
movl (%r12), %eax
testl %eax, %eax
je 0x7f63
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x10(%r12), %rcx
movq %r13, %rdx
shrq $0x4, %rdx
movl (%rcx,%rdx,4), %edx
movl %r15d, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0x7f55
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
movl (%r12), %eax
incq %r13
movl %eax, %ecx
addl $0x2, %r15d
cmpq %rcx, %r13
jb 0x7f02
incl %ebp
movb (%r14), %cl
movl %ebp, %eax
shrl %cl, %eax
testl %eax, %eax
je 0x7e83
testb $0x2, 0xc(%r14)
jne 0x7f91
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