// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/htab.cpp
// Function: load_ct_index(void**, char*)
int load_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, "r");
	if (!fp) {
		free(gfa_name);
        return 0;
    }
	ha_ct_t** ct_idx = (ha_ct_t**)i_ct_idx;
	double index_time = 0;
	uint64_t flag = 0;
	int i;
	ha_ct_t *h = 0;
	ha_ct1_t *g;
	CALLOC(h, 1);

	flag += fread(&h->k, sizeof(h->k), 1, fp);
	flag += fread(&h->pre, sizeof(h->pre), 1, fp);
	flag += fread(&h->n_hash, sizeof(h->n_hash), 1, fp);
	flag += fread(&h->n_shift, sizeof(h->n_shift), 1, fp);
	flag += fread(&h->tot, sizeof(h->tot), 1, fp);
	CALLOC(h->h, 1<<h->pre);


	index_time = yak_realtime();
	for (i = 0; i < 1<<h->pre; ++i) 
	{
		g = &(h->h[i]);
		yak_ct_load(&(g->h), fp);
	}

	(*ct_idx) = h;
	fprintf(stderr, "[M::%s::%.3f] ==> Loaded count table\n", __func__, yak_realtime() - index_time);
	fprintf(stderr, "[M::%s] Index has been loaded.\n", __func__);
	free(gfa_name);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r12
movq %rsi, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
callq 0x2280
movq %rax, %r14
leaq 0x1152da(%rip), %rsi    # 0x1ec158
xorl %ebp, %ebp
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x11a823(%rip), %rsi    # 0x1f16b7
movq %r14, %rdi
callq 0x2210
testq %rax, %rax
jne 0xd6eba
movq %r14, %rdi
callq 0x2220
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq %r12, 0x20(%rsp)
movq %r14, 0x28(%rsp)
pushq $0x1
popq %r12
pushq $0x28
popq %rsi
movq %r12, %rdi
callq 0x2120
movq %rax, %rbx
pushq $0x4
popq %r13
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
leaq 0x4(%rbx), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
leaq 0x8(%rbx), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
leaq 0xc(%rbx), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
leaq 0x10(%rbx), %rdi
pushq $0x8
popq %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
movb 0x4(%rbx), %cl
pushq $0x1
popq %rax
shll %cl, %eax
movslq %eax, %rdi
pushq $0x10
popq %rsi
movq %rdi, 0x30(%rsp)
callq 0x2120
movq %rax, %r14
movq %rbx, 0x18(%rsp)
movq %rax, 0x20(%rbx)
xorl %ebp, %ebp
callq 0xefea7
movsd %xmm0, 0x10(%rsp)
jmp 0xd7056
callq 0xda119
movq %rax, (%r14)
leaq 0xc(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
movq (%r14), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
movq (%r14), %rdi
addq $0x4, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
leaq 0xb(%rsp), %rdi
movq %r12, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
cmpb $0x0, 0xb(%rsp)
je 0xd7008
movl 0xc(%rsp), %eax
movl %eax, %edi
shrl $0x3, %edi
andl $-0x4, %edi
movl %eax, %ebx
shrl $0x5, %ebx
cmpl $0x20, %eax
pushq $0x4
popq %rax
cmovbl %eax, %edi
pushq $0x1
popq %rax
cmovbl %eax, %ebx
callq 0x2280
movq (%r14), %rcx
movq %rax, 0x8(%rcx)
movq (%r14), %rax
movq 0x8(%rax), %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x22f0
leaq 0xb(%rsp), %rdi
movq %r12, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
cmpb $0x0, 0xb(%rsp)
je 0xd704f
movl 0xc(%rsp), %ebx
leaq (,%rbx,8), %rdi
callq 0x2280
movq (%r14), %rcx
movq %rax, 0x10(%rcx)
movq (%r14), %rax
movq 0x10(%rax), %rdi
pushq $0x8
popq %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x22f0
incq %rbp
addq $0x10, %r14
cmpq 0x30(%rsp), %rbp
jl 0xd6f6c
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq 0x17bf6b(%rip), %r15    # 0x252fe0
movq (%r15), %rbx
callq 0xefea7
subsd 0x10(%rsp), %xmm0
leaq 0x115108(%rip), %rsi    # 0x1ec192
leaq 0x115127(%rip), %r14    # 0x1ec1b8
movq %rbx, %rdi
movq %r14, %rdx
movb $0x1, %al
callq 0x22b0
movq (%r15), %rdi
leaq 0x11511e(%rip), %rsi    # 0x1ec1c6
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
movq 0x28(%rsp), %r14
pushq $0x1
popq %rbp
jmp 0xd6ea1