// File: /workspace/github_c_makefile_star2_O2/lh3[P]minimap/index.c
// Function: mm_idx_dump
void mm_idx_dump(FILE *fp, const mm_idx_t *mi)
{
	uint32_t x[6];
	int i;
	x[0] = mi->w, x[1] = mi->k, x[2] = mi->b, x[3] = mi->n, x[4] = mi->name? 1 : 0, x[5] = mi->max_occ;
	fwrite(MM_IDX_MAGIC, 1, 4, fp);
	fwrite(x, 4, 6, fp);
	fwrite(&mi->freq_thres, sizeof(float), 1, fp);
	fwrite(mi->len, 4, mi->n, fp);
	if (mi->name) {
		for (i = 0; i < mi->n; ++i) {
			uint8_t l;
			l = strlen(mi->name[i]);
			fwrite(&l, 1, 1, fp);
			fwrite(mi->name[i], 1, l, fp);
		}
	}
	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);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbp
movq %rdi, %r14
movdqu (%rsi), %xmm0
pshufd $0xc9, %xmm0, %xmm0     # xmm0 = xmm0[1,2,0,3]
leaq 0x30(%rsp), %r15
movdqa %xmm0, (%r15)
xorl %eax, %eax
cmpq $0x0, 0x28(%rsi)
setne %al
movl %eax, 0x10(%r15)
movl 0x18(%rsi), %eax
movl %eax, 0x14(%r15)
leaq 0x4752(%rip), %rdi      # 0x87da
pushq $0x1
popq %r12
pushq $0x4
popq %r13
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x2290
pushq $0x6
popq %rdx
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
callq 0x2290
leaq 0x1c(%rbp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2290
movq 0x20(%rbp), %rdi
movl 0xc(%rbp), %edx
movq %r13, %rsi
movq %r14, %rcx
callq 0x2290
cmpq $0x0, 0x28(%rbp)
je 0x4120
xorl %ebx, %ebx
pushq $0x1
popq %r15
movl 0xc(%rbp), %eax
cmpq %rax, %rbx
jae 0x4120
movq 0x28(%rbp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x20d0
movq %rax, %r12
movsbl %r12b, %edi
movq %r14, %rsi
callq 0x2140
movq 0x28(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movzbl %r12b, %edx
movq %r15, %rsi
movq %r14, %rcx
callq 0x2290
incq %rbx
jmp 0x40e0
xorl %edx, %edx
pushq $0x8
popq %r13
movq %rbp, 0x10(%rsp)
movb (%rbp), %cl
pushq $0x1
popq %rax
shll %cl, %eax
cltq
cmpq %rax, %rdx
jge 0x4218
movq 0x10(%rbp), %r15
movq %rdx, 0x18(%rsp)
imulq $0x30, %rdx, %rax
movq 0x28(%r15,%rax), %rbx
testq %rbx, %rbx
je 0x415a
movl 0x4(%rbx), %ecx
jmp 0x415c
xorl %ecx, %ecx
addq %rax, %r15
movl %ecx, 0xc(%rsp)
leaq 0x18(%r15), %rdi
pushq $0x4
popq %rbp
movq %rbp, %rsi
pushq $0x1
popq %r12
movq %r12, %rdx
movq %r14, %rcx
callq 0x2290
movq 0x20(%r15), %rdi
movslq 0x18(%r15), %rdx
movq %r13, %rsi
movq %r14, %rcx
callq 0x2290
leaq 0xc(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2290
cmpl $0x0, 0xc(%rsp)
leaq 0x20(%rsp), %r12
je 0x4206
xorl %ebp, %ebp
xorl %r15d, %r15d
movl (%rbx), %eax
cmpq %rax, %r15
jae 0x4206
movq 0x10(%rbx), %rax
movq %r15, %rcx
shrq $0x4, %rcx
movl (%rax,%rcx,4), %eax
movl %ebp, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x41fe
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rbx), %rax
movq (%rax,%r15,8), %rax
movq %rax, 0x28(%rsp)
movq %r12, %rdi
movq %r13, %rsi
pushq $0x2
popq %rdx
movq %r14, %rcx
callq 0x2290
incq %r15
addl $0x2, %ebp
jmp 0x41b3
movq 0x18(%rsp), %rdx
incq %rdx
movq 0x10(%rsp), %rbp
jmp 0x412b
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq