// File: /workspace/github_c_makefile_star2_O0/lh3[P]bgt/atomic.c
// Function: bcf_atom_read
const bcf_atom_t *bcf_atom_read(bcf_atombuf_t *buf)
{
	if (buf->start == buf->a.n) {
		if (buf->no_vcf) return 0;
		buf->a.n = buf->start = 0;
		bcf_atomize(buf->h, buf->b, &buf->a);
		if (flt_read1(buf->in, buf->h, buf->b, buf->keep_flt) < 0)
			buf->no_vcf = 1;
	}
	assert(buf->start < buf->a.n);
	for (;;) {
		if (buf->no_vcf || buf->a.a[buf->start].rid < buf->b->rid || (buf->a.a[buf->start].rid == buf->b->rid && buf->a.a[buf->start].pos < buf->b->pos))
			return &buf->a.a[buf->start++];
		if (buf->start != 0) {
			bcf_atom_t *tmp;
			tmp = (bcf_atom_t*)malloc(buf->start * sizeof(bcf_atom_t));
			memcpy(tmp, buf->a.a, buf->start * sizeof(bcf_atom_t));
			memmove(buf->a.a, &buf->a.a[buf->start], (buf->a.n - buf->start) * sizeof(bcf_atom_t));
			buf->a.n -= buf->start;
			memcpy(buf->a.a + buf->a.n, tmp, buf->start * sizeof(bcf_atom_t));
			buf->start = 0;
			free(tmp);
		}
		bcf_atomize(buf->h, buf->b, &buf->a);
		if (flt_read1(buf->in, buf->h, buf->b, buf->keep_flt) < 0)
			buf->no_vcf = 1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x17dd1
movq -0x10(%rbp), %rax
movl 0x24(%rax), %eax
andl $0xffff, %eax           # imm = 0xFFFF
cmpl $0x0, %eax
je 0x17d5e
movq $0x0, -0x8(%rbp)
jmp 0x17fde
movq -0x10(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
callq 0x16780
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x24(%rax), %ecx
shrl $0x10, %ecx
callq 0x17c20
cmpl $0x0, %eax
jge 0x17dcf
movq -0x10(%rbp), %rax
movl 0x24(%rax), %ecx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl $0x1, %ecx
movl %ecx, 0x24(%rax)
jmp 0x17dd1
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x17de3
jmp 0x17e02
leaq 0x105c5(%rip), %rdi     # 0x283af
leaq 0x1052f(%rip), %rsi     # 0x28320
movl $0xe5, %edx
leaq 0x105c8(%rip), %rcx     # 0x283c5
callq 0x21b0
jmp 0x17e04
movq -0x10(%rbp), %rax
movl 0x24(%rax), %eax
andl $0xffff, %eax           # imm = 0xFFFF
cmpl $0x0, %eax
jne 0x17e88
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x20(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jl 0x17e88
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x20(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x17eb2
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x20(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x17eb2
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rdx
movl 0x20(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x20(%rdx)
movslq %ecx, %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x17fde
movq -0x10(%rbp), %rax
cmpl $0x0, 0x20(%rax)
je 0x17f7e
movq -0x10(%rbp), %rax
movslq 0x20(%rax), %rdi
shlq $0x6, %rdi
callq 0x22f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0x20(%rax), %rdx
shlq $0x6, %rdx
callq 0x2290
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0x20(%rax), %rax
shlq $0x6, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x20(%rcx), %eax
movslq %eax, %rdx
shlq $0x6, %rdx
callq 0x2370
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rax
shlq $0x6, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq 0x20(%rax), %rdx
shlq $0x6, %rdx
callq 0x2290
movq -0x10(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x18(%rbp), %rdi
callq 0x2040
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
callq 0x16780
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x24(%rax), %ecx
shrl $0x10, %ecx
callq 0x17c20
cmpl $0x0, %eax
jge 0x17fd9
movq -0x10(%rbp), %rax
movl 0x24(%rax), %ecx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl $0x1, %ecx
movl %ecx, 0x24(%rax)
jmp 0x17e04
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)