// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
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 0xc(%rsi), %eax
movl %eax, 0xc(%r15)
xorl %eax, %eax
cmpq $0x0, 0x28(%rsi)
setne %al
movl %eax, 0x10(%r15)
movl 0x18(%rsi), %eax
movl %eax, 0x14(%r15)
leaq 0x4466(%rip), %rdi      # 0x880a
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x2290
movl $0x4, %esi
movl $0x6, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2290
leaq 0x1c(%rbx), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2290
movq 0x20(%rbx), %rdi
movl 0xc(%rbx), %edx
movl $0x4, %esi
movq %r14, %rcx
callq 0x2290
cmpq $0x0, 0x28(%rbx)
je 0x4445
cmpl $0x0, 0xc(%rbx)
je 0x4445
xorl %r12d, %r12d
movq 0x28(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x20d0
movq %rax, %r15
movsbl %r15b, %edi
movq %r14, %rsi
callq 0x2140
movq 0x28(%rbx), %rax
movq (%rax,%r12,8), %rdi
movzbl %r15b, %edx
movl $0x1, %esi
movq %r14, %rcx
callq 0x2290
incq %r12
movl 0xc(%rbx), %eax
cmpq %rax, %r12
jb 0x4405
cmpl $0x1f, (%rbx)
je 0x4542
xorl %r13d, %r13d
movq 0x10(%rbx), %r15
leaq (,%r13,2), %rax
addq %r13, %rax
shlq $0x4, %rax
movq 0x28(%r15,%rax), %rbp
movl $0x0, %ecx
testq %rbp, %rbp
je 0x4476
movl 0x4(%rbp), %ecx
addq %rax, %r15
movl %ecx, 0xc(%rsp)
leaq 0x18(%r15), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2290
movq 0x20(%r15), %rdi
movslq 0x18(%r15), %rdx
movl $0x8, %esi
movq %r14, %rcx
callq 0x2290
movl $0x4, %esi
movl $0x1, %edx
leaq 0xc(%rsp), %rdi
movq %r14, %rcx
callq 0x2290
cmpl $0x0, 0xc(%rsp)
je 0x452b
cmpl $0x0, (%rbp)
je 0x452b
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x10(%rbp), %rax
movl %r12d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %r15d, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x451c
movq 0x18(%rbp), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rbp), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x18(%rsp)
movl $0x8, %esi
movl $0x2, %edx
leaq 0x10(%rsp), %rdi
movq %r14, %rcx
callq 0x2290
incq %r12
movl (%rbp), %eax
addl $0x2, %r15d
cmpq %rax, %r12
jb 0x44d2
movb (%rbx), %cl
movl $0x1, %eax
shll %cl, %eax
incq %r13
cltq
cmpq %rax, %r13
jl 0x4451
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq