// File: /workspace/github_c_makefile_star2_O0/lh3[P]bgt/pbwt.c
// Function: pbf_write
int pbf_write(pbf_t *pb, uint8_t *const*a)
{
	int g;
	if (!pb->is_writing) return -1;
	if ((pb->n & ((1ULL<<pb->shift) - 1)) == 0) {
		if (pb->n_idx == pb->m_idx) {
			pb->m_idx = pb->m_idx? pb->m_idx<<1 : 8;
			pb->idx = (uint64_t*)realloc(pb->idx, pb->m_idx * 8);
		}
		pb->idx[pb->n_idx++] = ftell(pb->fp); // save the index offset
		fputc('S', pb->fp);
		for (g = 0; g < pb->g; ++g) // write S[]
			fwrite(pb->pb[g]->S, 4, pb->m, pb->fp);
	}
	fputc('B', pb->fp);
	for (g = 0; g < pb->g; ++g) {
		pbc_t *pbc = pb->pb[g];
		pbc_enc(pbc, a[g]);
		fwrite(&pbc->l, 4, 1, pb->fp);
		fwrite(pbc->u, 1, pbc->l, pb->fp);
	}
	++pb->n;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x1b9b6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1bb7b
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
subq $0x1, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x1bacd
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jne 0x1ba42
movq -0x10(%rbp), %rax
cmpl $0x0, 0x34(%rax)
je 0x1ba09
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
shll %eax
movl %eax, -0x2c(%rbp)
jmp 0x1ba13
movl $0x8, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1ba13
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
shll $0x3, %eax
movslq %eax, %rsi
callq 0x2340
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2270
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rsi
movl 0x30(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x30(%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl $0x53, %edi
callq 0x21f0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x1bacb
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl $0x4, %esi
callq 0x2420
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1ba87
jmp 0x1bacd
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl $0x42, %edi
callq 0x21f0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x1bb64
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1ab10
movq -0x28(%rbp), %rdi
addq $0x4, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x2420
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rax
movslq 0x4(%rax), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %esi
callq 0x2420
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1bae5
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)