// File: chhylp123[P]hifiasm/inter.cpp
// Function: load_emask_t(idx_emask_t**, char*, ma_ug_t*)
int32_t load_emask_t(idx_emask_t **z, char* file_name, ma_ug_t *ug)
{
	char* gfa_name = NULL; MALLOC(gfa_name, strlen(file_name)+50);
    sprintf(gfa_name, "%s.ul.msk.bin", file_name);
    FILE* fp = fopen(gfa_name, "r"); free(gfa_name);
    if (!fp) return 0;
    if(ug && (!test_dbug(ug, fp))) {
        fprintf(stderr, "[M::%s] Renew UL Index\n", __func__);
        fclose(fp);
        return 0;
    }
    uint64_t k; kv_emask_t *p; idx_emask_t *x; CALLOC(x, 1);


	fread(&x->n, sizeof(x->n), 1, fp); MALLOC(x->a, x->n); 
	for (k = 0; k < x->n; k++) {
		p = &(x->a[k]);
		fread(&p->n, sizeof(p->n), 1, fp); MALLOC(p->a, p->n); p->m = p->n;
		fread(p->a, sizeof((*(p->a))), p->n, fp);
	}
	
    fprintf(stderr, "[M::%s] Index has been loaded.\n", __func__);
    fclose(fp);
	*z = x;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x32, %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x987e5(%rip), %rsi     # 0x39546d
movb $0x0, %al
callq 0x2050
movq -0x28(%rbp), %rdi
leaq 0x9373c(%rip), %rsi     # 0x3903d6
callq 0x2200
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x2210
cmpq $0x0, -0x30(%rbp)
jne 0x2fccbf
movl $0x0, -0x4(%rbp)
jmp 0x2fce31
cmpq $0x0, -0x20(%rbp)
je 0x2fcd0c
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x101650
cmpl $0x0, %eax
jne 0x2fcd0c
movq 0xc7301(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
leaq 0x8e2aa(%rip), %rsi     # 0x38af93
leaq 0x9878b(%rip), %rdx     # 0x39547b
movb $0x0, %al
callq 0x22a0
movq -0x30(%rbp), %rdi
callq 0x21a0
movl $0x0, -0x4(%rbp)
jmp 0x2fce31
movl $0x1, %edi
movl $0x10, %esi
callq 0x2140
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
movq -0x30(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
imulq $0x18, %rax, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movl 0x8(%rcx), %ecx
cmpq %rcx, %rax
jae 0x2fcdf7
movq -0x48(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
movq -0x30(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
shlq $0x5, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x30(%rbp), %rcx
movl $0x20, %esi
callq 0x22e0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2fcd5c
movq 0xc71e2(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
leaq 0x8e09e(%rip), %rsi     # 0x38aea6
leaq 0x9866c(%rip), %rdx     # 0x39547b
movb $0x0, %al
callq 0x22a0
movq -0x30(%rbp), %rdi
callq 0x21a0
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)