// File: chhylp123[P]hifiasm/rcut.cpp
// Function: load_mc_gg_dump(kv_u_trans_t**, unsigned int*, kv_gg_status**, unsigned short*, char const*)
uint32_t load_mc_gg_dump(kv_u_trans_t **rta, uint32_t *un, kv_gg_status **rs, uint16_t *hapN, const char* fn)
{
	fprintf(stderr, "\n[M::%s]\n", __func__);
	kv_u_trans_t *ta = NULL;
	kv_gg_status *s = NULL;
	uint64_t flag = 0;
    char *buf = (char*)calloc(strlen(fn) + 25, 1);
    sprintf(buf, "%s.hic.dbg.dump.bin", fn);

    FILE* fp = NULL; 
    fp = fopen(buf, "r"); 
    if(!fp)
	{
		free(buf);
		return 0;
	} 
	CALLOC(ta, 1);
	flag += fread(&ta->n, sizeof(ta->n), 1, fp);
	ta->m = ta->n; MALLOC(ta->a, ta->n);
	flag += fread(ta->a, sizeof(u_trans_t), ta->n, fp);

	flag += fread(&ta->idx.n, sizeof(ta->idx.n), 1, fp);
	ta->idx.m = ta->idx.n; MALLOC(ta->idx.a, ta->idx.n);
    flag += fread(ta->idx.a, sizeof(uint64_t), ta->idx.n, fp);

	flag += fread(un, sizeof(*un), 1, fp);

	CALLOC(s, 1);
	flag += fread(&(s->n), sizeof(s->n), 1, fp);
	s->m = s->n; MALLOC(s->a, s->n);
    flag += fread(s->a, sizeof(mc_gg_status), s->n, fp);

	flag += fread(hapN, sizeof(*hapN), 1, fp);
	*rta = ta; *rs = s;
	fclose(fp);
    free(buf);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq 0x199a4d(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x162b8f(%rip), %rsi    # 0x38d12c
leaq 0x163b2e(%rip), %rdx    # 0x38e0d2
movb $0x0, %al
callq 0x22a0
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x19, %rdi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x163ace(%rip), %rsi    # 0x38e0be
movb $0x0, %al
callq 0x2050
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x165dcc(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x22a62f
movq -0x50(%rbp), %rdi
callq 0x2210
movl $0x0, -0x4(%rbp)
jmp 0x22a815
movl $0x1, %edi
movl $0x30, %esi
callq 0x2140
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
imulq $0x30, (%rax), %rdi
callq 0x2270
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rdx
movq -0x58(%rbp), %rcx
movl $0x30, %esi
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x58(%rbp), %rcx
movl $0x8, %esi
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2140
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
movq -0x58(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
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 (%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x58(%rbp), %rcx
movl $0x20, %esi
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
movq -0x58(%rbp), %rcx
movl $0x2, %esi
movl $0x1, %edx
callq 0x22e0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rdi
callq 0x21a0
movq -0x50(%rbp), %rdi
callq 0x2210
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop