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

	if(pgi->is_first_page) {
		do_theora_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>=0x80) {
		// 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<0x80) {
		// Reached the end of headers (by encountering a non-header page).
		// (There is required to be an Ogg page break immediately after the
		// Theora headers, so the start of the first data *page* must correspond
		// to the start of the first data *packet*. A Theora data packet always
		// begins with a byte < 0x80.)
		do_theora_vorbis_after_headers(c, d, si);
	}

done:
	;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %rbx
cmpl $0x0, 0x4(%rdx)
je 0x88fde
movq 0x20(%r15), %rax
addq $0x7, %rax
movq %rsp, %r12
movq %rax, (%r12)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movl %eax, %ebp
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movl %eax, %r13d
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movzbl %bpl, %edx
movzbl %r13b, %ecx
movzbl %al, %r8d
leaq 0x9d970(%rip), %rsi     # 0x1267ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb91
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb91
leaq 0xa3f87(%rip), %rsi     # 0x12cdfd
movq %rbx, %rdi
movl %r13d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq (%r12), %rsi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xef0f6
movq %rax, %r13
movq (%r12), %rsi
addq $0x3, %rsi
movq %rsi, (%r12)
movq 0x18(%rbx), %rdi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xef0f6
addq $0x3, (%r12)
leaq 0xa3f58(%rip), %rsi     # 0x12ce22
movq %rbx, %rdi
movl %r13d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movzbl %al, %ebp
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movzbl %al, %ecx
leaq 0xa3f46(%rip), %rsi     # 0x12ce44
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeed31
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeed31
leaq 0xa3f3c(%rip), %rsi     # 0x12ce68
movq %rbx, %rdi
movl %r13d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq (%r12), %rsi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xef0f6
movq %rax, %r13
movq (%r12), %rsi
addq $0x3, %rsi
movq %rsi, (%r12)
movq 0x18(%rbx), %rdi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xef0f6
addq $0x3, (%r12)
leaq 0xa3efa(%rip), %rsi     # 0x12ce7a
movq %rbx, %rdi
movl %r13d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movzbl %al, %edx
leaq 0xa3ee9(%rip), %rsi     # 0x12ce8e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq (%r12), %rsi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xef0f6
addq $0x3, (%r12)
leaq 0xa3ecc(%rip), %rsi     # 0x12ce9e
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
cmpl $0x0, 0x20(%r14)
je 0x88ff4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x28(%r15)
jle 0x88fe5
movq 0x18(%rbx), %rdi
movq 0x20(%r15), %rsi
callq 0xeead3
cmpq $0x0, 0x18(%r14)
je 0x88fe5
movq 0x18(%r15), %rcx
testq %rcx, %rcx
je 0x88fe5
testb $0x2, 0x1(%r15)
jne 0x88fe5
testq %rcx, %rcx
setg %cl
testb %al, %al
sets %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x89069
movq 0x28(%r14), %rcx
testq %rcx, %rcx
jne 0x89053
movl $0x100000, %esi         # imm = 0x100000
movq %rbx, %rdi
movl $0x1, %edx
callq 0xf09c5
movq %rax, %rcx
movq %rax, 0x28(%r14)
movq 0x18(%rbx), %rdi
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
callq 0xef481
jmp 0x88fe5
testb %al, %al
js 0x88fe5
movq %rbx, %rdi
movq %r14, %rsi
callq 0x897c7
jmp 0x88fe5