// File: /workspace/github_c_makefile_star2_O3/lh3[P]bgt/pbwt.c
// Function: pbf_open_r
pbf_t *pbf_open_r(const char *fn)
{
	pbf_t *pb;
	FILE *fp;
	int32_t i, v[3];
	char magic[4];
	if (fn && strcmp(fn, "-") != 0) {
		if ((fp = fopen(fn, "rb")) == 0)
			return 0;
	} else fp = stdin;
	fread(magic, 1, 4, fp);
	if (strncmp(magic, "PBF\1", 4) != 0) {
		fclose(fp);
		return 0;
	}
	pb = (pbf_t*)calloc(1, sizeof(pbf_t));
	fread(v, 4, 3, fp);
	pb->m = v[0], pb->g = v[1], pb->shift = v[2];
	pb->pb = (pbc_t**)calloc(pb->g, sizeof(void*));
	for (i = 0; i < pb->g; ++i)
		pb->pb[i] = pbc_init(pb->m);
	pb->buf = (uint8_t*)calloc(pb->m + 1, 1);
	pb->invS = (int32_t*)calloc(pb->m, 4);
	pb->ret = (const uint8_t**)calloc(pb->g, sizeof(uint8_t*));
	for (i = 0; i < pb->g; ++i) pb->ret[i] = pb->pb[i]->u;
	pb->sub = (pbs_dat_t**)calloc(pb->g, sizeof(pbs_dat_t*));
	if (fseek(fp, -8, SEEK_END) >= 0) {
		uint64_t off;
		uint8_t t;
		fread(&off, 8, 1, fp);
		fseek(fp, off, SEEK_SET);
		fread(&t, 1, 1, fp);
		fread(&pb->n, 8, 1, fp);
		fread(&pb->n_idx, 4, 1, fp);
		pb->m_idx = pb->n_idx;
		pb->idx = (uint64_t*)calloc(pb->n_idx, 8);
		fread(pb->idx, 8, pb->n_idx, fp);
		fseek(fp, 16, SEEK_SET);
	}
	pb->fp = fp;
	return pb;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x157df
cmpb $0x2d, (%rdi)
jne 0x157c9
cmpb $0x0, 0x1(%rdi)
je 0x157df
leaq 0x9890(%rip), %rsi      # 0x1f060
callq 0x23b0
movq %rax, %rbx
testq %rax, %rax
jne 0x157e9
jmp 0x15814
movq 0x107a2(%rip), %rax     # 0x25f88
movq (%rax), %rbx
leaq 0xc(%rsp), %r14
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x20f0
cmpl $0x1464250, (%r14)      # imm = 0x1464250
je 0x1581c
movq %rbx, %rdi
callq 0x2160
xorl %r14d, %r14d
jmp 0x159b0
movl $0x1, %edi
movl $0x70, %esi
callq 0x2220
movq %rax, %r14
leaq 0x1c(%rsp), %r15
movl $0x4, %esi
movl $0x3, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x20f0
movslq (%r15), %r13
movl %r13d, 0x8(%r14)
movq 0x4(%r15), %rax
movq %rax, 0xc(%r14)
movslq %eax, %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0x2220
movq %rax, %r12
movq %rax, 0x20(%r14)
testl %r15d, %r15d
jle 0x15889
xorl %ebp, %ebp
movl %r13d, %edi
callq 0x151b5
movq %rax, (%r12,%rbp,8)
incq %rbp
cmpq %rbp, %r15
jne 0x15875
leaq 0x1(%r13), %rdi
movl $0x1, %esi
callq 0x2220
movq %rax, 0x60(%r14)
movl $0x4, %esi
movq %r13, %rdi
callq 0x2220
movq %rax, 0x68(%r14)
movl $0x8, %esi
movq %r15, %rdi
callq 0x2220
movq %rax, 0x28(%r14)
testl %r15d, %r15d
jle 0x158d8
xorl %ecx, %ecx
movq (%r12,%rcx,8), %rdx
movq 0x18(%rdx), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x158c4
movl $0x8, %esi
movq %r15, %rdi
callq 0x2220
movq %rax, 0x48(%r14)
movq %rbx, %rdi
movq $-0x8, %rsi
movl $0x2, %edx
callq 0x2310
testl %eax, %eax
js 0x159ad
leaq 0x10(%rsp), %r15
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x20f0
movq (%r15), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2310
leaq 0xb(%rsp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x20f0
leaq 0x18(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x20f0
movq %r14, %rdi
addq $0x30, %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x20f0
movslq 0x30(%r14), %r15
movl %r15d, 0x34(%r14)
movl $0x8, %esi
movq %r15, %rdi
callq 0x2220
movq %rax, 0x38(%r14)
movl $0x8, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x20f0
movl $0x10, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2310
movq %rbx, (%r14)
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq