// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/rld0.c
// Function: rld_restore_header
static rld_t *rld_restore_header(const char *fn, FILE **_fp)
{
	FILE *fp;
	rld_t *e;
	char magic[4];
	uint64_t a[3];
	int32_t i, x;

	if (strcmp(fn, "-") == 0) *_fp = fp = stdin;
	else if ((*_fp = fp = fopen(fn, "rb")) == 0) return 0;
	fread(magic, 1, 4, fp);
	if (strncmp(magic, "RLD\3", 4)) return 0;
	fread(&x, 4, 1, fp);
	e = rld_init(x>>16, x&0xffff);
	fread(a, 8, 3, fp);
	e->n_bytes = a[1]; e->n_frames = a[2];
	fread(e->mcnt + 1, 8, e->asize, fp);
	for (i = 0; i <= e->asize; ++i) e->cnt[i] = e->mcnt[i];
	for (i = 1; i <= e->asize; ++i) e->cnt[i] += e->cnt[i - 1];
	e->mcnt[0] = e->cnt[e->asize];
	return e;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x18bc1(%rip), %rsi     # 0x253dc
callq 0x2150
cmpl $0x0, %eax
jne 0xc83c
movq 0x1d79c(%rip), %rax     # 0x29fc8
movq (%rax), %rcx
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0xc86c
movq -0x10(%rbp), %rdi
leaq 0x18e89(%rip), %rsi     # 0x256d0
callq 0x2250
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xc86a
movq $0x0, -0x8(%rbp)
jmp 0xc9da
jmp 0xc86c
leaq -0x2c(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x1, %esi
movl $0x4, %edx
callq 0x2070
leaq -0x2c(%rbp), %rdi
leaq 0x18e3d(%rip), %rsi     # 0x256cb
movl $0x4, %edx
callq 0x2060
cmpl $0x0, %eax
je 0xc8aa
movq $0x0, -0x8(%rbp)
jmp 0xc9da
movq -0x20(%rbp), %rcx
leaq -0x58(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x2070
movl -0x58(%rbp), %edi
sarl $0x10, %edi
movl -0x58(%rbp), %esi
andl $0xffff, %esi           # imm = 0xFFFF
callq 0xb4b0
movq %rax, -0x28(%rbp)
leaq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x8, %esi
movl $0x3, %edx
callq 0x2070
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rdi
addq $0x8, %rdi
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %edx
movq -0x20(%rbp), %rcx
movl $0x8, %esi
callq 0x2070
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xc96b
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x54(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0xc932
movl $0x1, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xc9b4
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x54(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0xc972
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)