// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/rld0.c
// Function: rld_restore_mmap
rld_t *rld_restore_mmap(const char *fn)
{
	FILE *fp;
	rld_t *e;
	int i;
	int64_t n_blks;

	e = rld_restore_header(fn, &fp);
	fclose(fp);
	free(e->z[0]); free(e->z);
	e->n = (e->n_bytes / 8 + RLD_LSIZE - 1) / RLD_LSIZE;
	e->z = xcalloc(e->n, sizeof(void*));
	e->fd = open(fn, O_RDONLY);
	e->mem = (uint64_t*)mmap(0, rld_file_size(e), PROT_READ, MAP_PRIVATE, e->fd, 0);
	for (i = 0; i < e->n; ++i) e->z[i] = e->mem + (4 + e->asize) + (size_t)i * RLD_LSIZE;
	e->frame = e->mem + (4 + e->asize) + e->n_bytes/8;
	n_blks = e->n_bytes * 8 / 64 / e->ssize + 1;
	e->ibits = ilog2(e->mcnt[0] / n_blks) + RLD_IBITS_PLUS;
	return e;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0xc800
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20a0
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
callq 0x2040
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2040
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
shrq $0x3, %rax
addq $0x800000, %rax         # imm = 0x800000
subq $0x1, %rax
shrq $0x17, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x2240
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
addl $0x4, %eax
shll $0x3, %eax
movslq %eax, %rsi
movq -0x18(%rbp), %rax
addq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
shlq $0x3, %rax
movq -0x18(%rbp), %rcx
movzbl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rax
movl 0x40(%rax), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, %edx
movl $0x2, %ecx
movq %r9, %rdi
callq 0x20c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0xcb43
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdx
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
addl $0x4, %eax
cltq
shlq $0x3, %rax
addq %rax, %rdx
movslq -0x1c(%rbp), %rax
shlq $0x17, %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xcaf2
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
addl $0x4, %eax
cltq
shlq $0x3, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
shrq $0x3, %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
shlq $0x3, %rax
shrq $0x6, %rax
movq -0x18(%rbp), %rcx
movslq 0x8(%rcx), %rcx
xorl %edx, %edx
divq %rcx
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x28(%rbp)
movq %rax, %rdi
callq 0xb5f0
addl $0x4, %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x18(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop