// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x93ac
movq %rax, %rbx
movq (%r14), %rdi
callq 0x2090
movq 0x18(%rbx), %r14
movq (%r14), %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
movq 0x10(%rbx), %r12
movq %r12, %r13
shrq $0x3, %r13
leaq 0x7fffff(%r13), %rbp
shrq $0x17, %rbp
movl %ebp, 0xc(%rbx)
movslq %ebp, %rdi
movq %rdi, 0x8(%rsp)
movl $0x8, %esi
callq 0x2130
movq %rax, %r14
movq %rax, 0x18(%rbx)
movq %r15, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2230
movl %eax, 0x40(%rbx)
movzbl (%rbx), %r15d
leaq (%r12,%r15,8), %rcx
leaq 0x1(%r15), %rdx
imulq 0x30(%rbx), %rdx
leaq (%rcx,%rdx,8), %rsi
addq $0x20, %rsi
xorl %edi, %edi
movl $0x1, %edx
movl $0x2, %ecx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x20b0
movq %rax, 0x48(%rbx)
cmpl $0x0, 0x8(%rsp)
jle 0x95c1
leaq (%rax,%r15,8), %rcx
addq $0x20, %rcx
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %edx, %edx
movq %rcx, (%r14,%rdx,8)
incq %rdx
addq $0x4000000, %rcx        # imm = 0x4000000
cmpq %rdx, %rbp
jne 0x95ae
leaq (%rax,%r15,8), %rax
leaq (%rax,%r13,8), %rax
addq $0x20, %rax
movq %rax, 0x38(%rbx)
movabsq $0x3ffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFF
andq %r13, %rax
movslq 0x8(%rbx), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
incq %rcx
movq 0x28(%rbx), %rax
movq (%rax), %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
shrq $0x20, %rcx
jne 0x9621
cmpq $0x10000, %rax          # imm = 0x10000
jae 0x963c
cmpq $0x100, %rax            # imm = 0x100
jae 0x966a
leaq 0xe157(%rip), %rcx      # 0x17770
movb (%rax,%rcx), %al
jmp 0x96aa
movq %rax, %rdx
shrq $0x30, %rdx
jne 0x9656
shrq $0x28, %rax
jne 0x967c
leaq 0xe139(%rip), %rax      # 0x17770
movb (%rcx,%rax), %al
jmp 0x96a8
cmpq $0x1000000, %rax        # imm = 0x1000000
jae 0x968a
shrq $0x10, %rax
leaq 0xe121(%rip), %rcx      # 0x17770
movb (%rax,%rcx), %al
addb $0x10, %al
jmp 0x96aa
shrq $0x38, %rax
jne 0x969c
leaq 0xe10d(%rip), %rax      # 0x17770
movb (%rdx,%rax), %al
addb $0x10, %al
jmp 0x96a8
shrq $0x8, %rax
leaq 0xe0fb(%rip), %rcx      # 0x17770
movb (%rax,%rcx), %al
addb $0x8, %al
jmp 0x96aa
leaq 0xe0ed(%rip), %rcx      # 0x17770
movb (%rax,%rcx), %al
addb $0x8, %al
jmp 0x96a8
shrq $0x18, %rax
leaq 0xe0db(%rip), %rcx      # 0x17770
movb (%rax,%rcx), %al
addb $0x18, %al
jmp 0x96aa
leaq 0xe0cd(%rip), %rcx      # 0x17770
movb (%rax,%rcx), %al
addb $0x18, %al
addb $0x20, %al
addb $0x4, %al
movb %al, 0x4(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq