// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/ogg.c
// Function: do_vorbis_page
static void do_vorbis_page(deark *c, lctx *d, struct page_info *pgi, struct stream_info *si)
{
	u8 firstbyte;

	if(pgi->is_first_page) {
		// The first Ogg page of a bitstream usually contains enough data to be
		// useful. So, we'll try to process it directly, without reconstructing
		// the codec bitstream.
		do_vorbis_id_header(c, d, pgi, si);
	}

	// We want to save a copy of the Comment and Setup header data,
	// but not the Identification header which is handled elsewhere.

	if(si->stream_state!=0) {
		// We've already handled the Comment & Setup headers.
		goto done;
	}

	if(pgi->dlen<1) goto done;

	firstbyte = de_getbyte(pgi->dpos);

	if(si->page_count==0 || pgi->page_seq_num==0 || (pgi->hdr_type&0x02)) {
		// This appears to be the Identification header page. Skip it.
		goto done;
	}

	if(pgi->page_seq_num>=1 && (firstbyte&0x01)) {
		// This appears to be one of the pages we care about.
		// Save its data for later.
		if(!si->header_stream) {
			si->header_stream = dbuf_create_membuf(c, 1048576, 1);
		}
		dbuf_copy(c->infile, pgi->dpos, pgi->dlen, si->header_stream);
	}
	else if((firstbyte&0x01)==0) {
		// Reached the end of headers (by encountering a non-header page).
		// (There is required to be an Ogg page break immediately after the
		// Vorbis headers, so the start of the first data *page* must correspond
		// to the start of the first data *packet*. A Vorbis data packet always
		// begins with a byte whose low bit is 0.)
		do_theora_vorbis_after_headers(c, d, si);
	}

done:
	;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %rbx
cmpl $0x0, 0x4(%rdx)
je 0x83d5b
movq 0x20(%r15), %rax
addq $0x7, %rax
movq %rsp, %r12
movq %rax, (%r12)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe40bf
leaq 0xa5de3(%rip), %rsi     # 0x129a84
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3f2a
movzbl %al, %edx
leaq 0x9be05(%rip), %rsi     # 0x11fac8
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe40bf
leaq 0x9bdf5(%rip), %rsi     # 0x11fad5
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq (%r12), %rsi
callq 0xe40f2
addq $0x4, (%r12)
leaq 0x9bde0(%rip), %rsi     # 0x11fae5
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq (%r12), %rsi
callq 0xe40f2
addq $0x4, (%r12)
leaq 0x9bdcb(%rip), %rsi     # 0x11faf5
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq (%r12), %rsi
callq 0xe40f2
addq $0x4, (%r12)
leaq 0x9bdba(%rip), %rsi     # 0x11fb09
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
cmpl $0x0, 0x20(%r14)
je 0x83d6e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpq $0x0, 0x28(%r15)
jle 0x83d62
movq 0x18(%rbx), %rdi
movq 0x20(%r15), %rsi
callq 0xe3eb4
cmpq $0x0, 0x18(%r14)
je 0x83d62
movq 0x18(%r15), %rcx
testq %rcx, %rcx
je 0x83d62
testb $0x2, 0x1(%r15)
jne 0x83d62
testq %rcx, %rcx
setle %cl
testb $0x1, %al
sete %dl
orb %cl, %dl
je 0x83db9
testb $0x1, %al
jne 0x83d62
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8473a
jmp 0x83d62
movq 0x28(%r14), %rcx
testq %rcx, %rcx
jne 0x83dd9
pushq $0x1
popq %rdx
movl $0x100000, %esi         # imm = 0x100000
movq %rbx, %rdi
callq 0xe59cd
movq %rax, %rcx
movq %rax, 0x28(%r14)
movq 0x18(%rbx), %rdi
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
callq 0xe45f4
jmp 0x83d62