// File: /workspace/github_c_makefile_star2_O3/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 0x9742
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), %r13
movq %r13, %rax
shrq $0x3, %rax
movq %rax, 0x8(%rsp)
leaq 0x7fffff(%rax), %rbp
shrq $0x17, %rbp
movl %ebp, 0xc(%rbx)
movslq %ebp, %r12
movl $0x8, %esi
movq %r12, %rdi
callq 0x2130
movq %rax, %r14
movq %rax, 0x18(%rbx)
movq %r15, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2220
movl %eax, 0x40(%rbx)
movzbl (%rbx), %r15d
leaq (,%r15,8), %rcx
addq %r13, %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)
testl %r12d, %r12d
jle 0x99e6
leaq (%rax,%r15,8), %rcx
addq $0x20, %rcx
movl %ebp, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
incl %ebp
andl $-0x2, %ebp
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0xddf9(%rip), %xmm1     # 0x17750
xorl %edx, %edx
movdqa 0xddff(%rip), %xmm2     # 0x17760
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0xddff(%rip), %xmm4     # 0x17770
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm5     # xmm5 = xmm5[1,1,3,3]
pand %xmm6, %xmm5
pshufd $0xf5, %xmm6, %xmm6     # xmm6 = xmm6[1,1,3,3]
por %xmm5, %xmm6
movdqa %xmm1, %xmm5
psllq $0x1a, %xmm5
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0x99b8
movq %xmm5, %rsi
addq %rcx, %rsi
movq %rsi, (%r14,%rdx,8)
pxor %xmm3, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0x99d9
pshufd $0xee, %xmm5, %xmm5     # xmm5 = xmm5[2,3,2,3]
movq %xmm5, %rsi
addq %rcx, %rsi
movq %rsi, 0x8(%r14,%rdx,8)
addq $0x2, %rdx
paddq %xmm4, %xmm1
cmpq %rdx, %rbp
jne 0x9971
leaq (%rax,%r15,8), %rax
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
addq $0x20, %rax
movq %rax, 0x38(%rbx)
movabsq $0x3ffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFF
andq %rcx, %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 0x9a4b
cmpq $0x10000, %rax          # imm = 0x10000
jae 0x9a66
cmpq $0x100, %rax            # imm = 0x100
jae 0x9a94
leaq 0xdd9d(%rip), %rcx      # 0x177e0
movb (%rax,%rcx), %al
jmp 0x9ad4
movq %rax, %rdx
shrq $0x30, %rdx
jne 0x9a80
shrq $0x28, %rax
jne 0x9aa6
leaq 0xdd7f(%rip), %rax      # 0x177e0
movb (%rcx,%rax), %al
jmp 0x9ad2
cmpq $0x1000000, %rax        # imm = 0x1000000
jae 0x9ab4
shrq $0x10, %rax
leaq 0xdd67(%rip), %rcx      # 0x177e0
movb (%rax,%rcx), %al
addb $0x10, %al
jmp 0x9ad4
shrq $0x38, %rax
jne 0x9ac6
leaq 0xdd53(%rip), %rax      # 0x177e0
movb (%rdx,%rax), %al
addb $0x10, %al
jmp 0x9ad2
shrq $0x8, %rax
leaq 0xdd41(%rip), %rcx      # 0x177e0
movb (%rax,%rcx), %al
addb $0x8, %al
jmp 0x9ad4
leaq 0xdd33(%rip), %rcx      # 0x177e0
movb (%rax,%rcx), %al
addb $0x8, %al
jmp 0x9ad2
shrq $0x18, %rax
leaq 0xdd21(%rip), %rcx      # 0x177e0
movb (%rax,%rcx), %al
addb $0x18, %al
jmp 0x9ad4
leaq 0xdd13(%rip), %rcx      # 0x177e0
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