// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1b531
movq -0x10(%rbp), %rdi
leaq 0xbfb6(%rip), %rsi      # 0x274b4
callq 0x2240
cmpl $0x0, %eax
je 0x1b531
movq -0x10(%rbp), %rdi
leaq 0xca6d(%rip), %rsi      # 0x27f80
callq 0x23c0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x1b52f
movq $0x0, -0x8(%rbp)
jmp 0x1b7de
jmp 0x1b53f
movq 0x12a50(%rip), %rax     # 0x2df88
movq (%rax), %rax
movq %rax, -0x20(%rbp)
leaq -0x34(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x1, %esi
movl $0x4, %edx
callq 0x20f0
leaq -0x34(%rbp), %rdi
leaq 0xcf00(%rip), %rsi      # 0x28461
movl $0x4, %edx
callq 0x2080
cmpl $0x0, %eax
je 0x1b586
movq -0x20(%rbp), %rdi
callq 0x2160
movq $0x0, -0x8(%rbp)
jmp 0x1b7de
movl $0x1, %edi
movl $0x70, %esi
callq 0x2230
movq %rax, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x4, %esi
movl $0x3, %edx
callq 0x20f0
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x28(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rdi
movl $0x8, %esi
callq 0x2230
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x1b628
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x1aa20
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b5f2
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x2230
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rax
movslq 0x8(%rax), %rdi
movl $0x4, %esi
callq 0x2230
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rdi
movl $0x8, %esi
callq 0x2230
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x1b6c6
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1b68b
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rdi
movl $0x8, %esi
callq 0x2230
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rdi
movq $-0x8, %rsi
movl $0x2, %edx
callq 0x2320
cmpl $0x0, %eax
jl 0x1b7cb
movq -0x20(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x20f0
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x2320
movq -0x20(%rbp), %rcx
leaq -0x41(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x20f0
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x20f0
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
movq -0x20(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x20f0
movq -0x18(%rbp), %rax
movl 0x30(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x18(%rbp), %rax
movslq 0x30(%rax), %rdi
movl $0x8, %esi
callq 0x2230
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x30(%rax), %rdx
movq -0x20(%rbp), %rcx
movl $0x8, %esi
callq 0x20f0
movq -0x20(%rbp), %rdi
movl $0x10, %esi
xorl %edx, %edx
callq 0x2320
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)