// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x4(%rsi), %rax
leaq 0x30(%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 0x21619(%rip), %rdi     # 0x2830d
pushq $0x1
popq %r12
pushq $0x4
popq %r13
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x23f0
pushq $0x5
popq %rdx
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
callq 0x23f0
pushq $0x10
popq %r15
xorl %r13d, %r13d
xorl %ebp, %ebp
movl 0x10(%r14), %eax
cmpq %rax, %r13
jae 0x6db9
movq 0x20(%r14), %rax
movq -0x10(%rax,%r15), %rdi
testq %rdi, %rdi
je 0x6d83
callq 0x2130
movq %r13, 0x8(%rsp)
movq %r12, %r13
movq %rbp, %r12
movq %rax, %rbp
movsbl %bpl, %edi
movq %rbx, %rsi
callq 0x21f0
movq 0x20(%r14), %rax
movq -0x10(%rax,%r15), %rdi
movzbl %bpl, %edx
movq %r12, %rbp
movq %r13, %r12
movq 0x8(%rsp), %r13
movq %r12, %rsi
movq %rbx, %rcx
callq 0x23f0
jmp 0x6d8d
xorl %edi, %edi
movq %rbx, %rsi
callq 0x21f0
movq 0x20(%r14), %rdi
addq %r15, %rdi
pushq $0x4
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x23f0
movq 0x20(%r14), %rax
movl (%rax,%r15), %eax
addq %rax, %rbp
incq %r13
addq $0x18, %r15
jmp 0x6d24
movq %rbp, 0x10(%rsp)
xorl %r15d, %r15d
pushq $0x8
popq %rbp
movq %r14, 0x18(%rsp)
movb (%r14), %cl
movl %r15d, %eax
shrl %cl, %eax
testl %eax, %eax
jne 0x6ebe
movq 0x30(%r14), %r14
movl %r15d, %eax
imulq $0x30, %rax, %rax
movq 0x28(%r14,%rax), %r12
testq %r12, %r12
movl %r15d, 0x8(%rsp)
je 0x6dfa
movl 0x4(%r12), %ecx
jmp 0x6dfc
xorl %ecx, %ecx
addq %rax, %r14
movl %ecx, 0x4(%rsp)
leaq 0x18(%r14), %rdi
pushq $0x4
popq %r13
movq %r13, %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
movq %rbx, %rcx
callq 0x23f0
movq 0x20(%r14), %rdi
movslq 0x18(%r14), %rdx
movq %rbp, %rsi
movq %rbx, %rcx
callq 0x23f0
leaq 0x4(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x23f0
cmpl $0x0, 0x4(%rsp)
movl 0x8(%rsp), %r15d
je 0x6eb1
xorl %r13d, %r13d
xorl %r14d, %r14d
movl (%r12), %eax
cmpq %rax, %r14
jae 0x6eb1
movq 0x10(%r12), %rax
movq %r14, %rcx
shrq $0x4, %rcx
movl (%rax,%rcx,4), %eax
movl %r13d, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x6ea8
movq 0x18(%r12), %rax
movq (%rax,%r14,8), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%r12), %rax
movq (%rax,%r14,8), %rax
movq %rax, 0x28(%rsp)
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
pushq $0x2
popq %rdx
movq %rbx, %rcx
callq 0x23f0
incq %r14
addl $0x2, %r13d
jmp 0x6e55
incl %r15d
movq 0x18(%rsp), %r14
jmp 0x6dc9
testb $0x2, 0xc(%r14)
jne 0x6ee1
movq 0x28(%r14), %rdi
movq 0x10(%rsp), %rdx
addq $0x7, %rdx
shrq $0x3, %rdx
pushq $0x4
popq %rsi
movq %rbx, %rcx
callq 0x23f0
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2300