// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/htab.cpp
// Function: write_ct_index(void*, char*)
int write_ct_index(void *i_ct_idx, char* file_name)
{
	char* gfa_name = (char*)malloc(strlen(file_name)+25);
    sprintf(gfa_name, "%s.ct_flt", file_name);
    FILE* fp = fopen(gfa_name, "w");
	if (!fp) {
		free(gfa_name);
        return 0;
    }
	ha_ct_t* ct_idx = (ha_ct_t*)i_ct_idx;
	int i;
	ha_ct1_t *g;
	fwrite(&ct_idx->k, sizeof(ct_idx->k), 1, fp);
	fwrite(&ct_idx->pre, sizeof(ct_idx->pre), 1, fp);
	fwrite(&ct_idx->n_hash, sizeof(ct_idx->n_hash), 1, fp);
	fwrite(&ct_idx->n_shift, sizeof(ct_idx->n_shift), 1, fp);
	fwrite(&ct_idx->tot, sizeof(ct_idx->tot), 1, fp);
	for (i = 0; i < 1<<ct_idx->pre; i++)
	{
		g = &(ct_idx->h[i]);
		yak_ct_save(g->h, fp);
	}


	fprintf(stderr, "[M::%s] Index has been written.\n", __func__);
    free(gfa_name);
	fclose(fp);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r12
movq %rsi, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
callq 0x2280
movq %rax, %r14
leaq 0x115dbb(%rip), %rsi    # 0x1ec158
movl $0x0, 0xc(%rsp)
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1242e8(%rip), %rsi    # 0x1fa6a1
movq %r14, %rdi
callq 0x2210
testq %rax, %rax
jne 0xd63e1
movq %r14, %rdi
callq 0x2220
movl 0xc(%rsp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq %r14, 0x10(%rsp)
pushq $0x4
popq %rbx
pushq $0x1
popq %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x2410
leaq 0x4(%r12), %rdi
movq %rdi, 0x20(%rsp)
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2410
leaq 0x8(%r12), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2410
leaq 0xc(%r12), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2410
leaq 0x10(%r12), %rdi
pushq $0x8
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2410
xorl %r13d, %r13d
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
xorl %ebx, %ebx
movq %r12, 0x18(%rsp)
jmp 0xd6545
movq 0x20(%r12), %rax
movq (%rax,%r13), %r14
testq %r14, %r14
je 0xd653e
cmpq $0x0, 0x10(%r14)
je 0xd648b
movb (%r14), %cl
pushq $0x1
popq %rax
shll %cl, %eax
jmp 0xd648d
xorl %eax, %eax
pushq $0x4
popq %r12
movl %eax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
pushq $0x1
popq %rbp
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2410
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2410
leaq 0x4(%r14), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2410
movq %r12, %rbp
movq 0x8(%r14), %r12
xorl %edi, %edi
testq %r12, %r12
setne %dil
movq %r15, %rsi
callq 0x2270
testq %r12, %r12
je 0xd650c
movq 0x8(%r14), %rdi
movl 0x8(%rsp), %eax
movl %eax, %edx
shrl $0x5, %edx
cmpl $0x20, %eax
pushq $0x1
popq %rax
cmovbl %eax, %edx
movq %rbp, %rsi
movq %r15, %rcx
callq 0x2410
movq 0x10(%r14), %r12
xorl %edi, %edi
testq %r12, %r12
setne %dil
movq %r15, %rsi
callq 0x2270
testq %r12, %r12
je 0xd6539
movq 0x10(%r14), %rdi
movl 0x8(%rsp), %edx
pushq $0x8
popq %rsi
movq %r15, %rcx
callq 0x2410
movq 0x18(%rsp), %r12
incq %rbx
addq $0x10, %r13
movq 0x20(%rsp), %rax
movb (%rax), %cl
pushq $0x1
popq %rax
shll %cl, %eax
cltq
cmpq %rax, %rbx
jl 0xd6468
movq 0x17ca7d(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x115bf5(%rip), %rsi    # 0x1ec162
leaq 0x115c0f(%rip), %rdx    # 0x1ec183
xorl %eax, %eax
callq 0x22b0
movq 0x10(%rsp), %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2190
jmp 0xd63ce