// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/ogg.c
// Function: do_identify_bitstream
static void do_identify_bitstream(deark *c, lctx *d, struct stream_info *si, i64 pos, i64 len)
{
	u8 idbuf[16];
	size_t bytes_to_scan;
	size_t k;

	bytes_to_scan = (size_t)len;
	if(bytes_to_scan > sizeof(idbuf)) {
		bytes_to_scan = sizeof(idbuf);
	}

	de_read(idbuf, pos, bytes_to_scan);

	for(k=0; k<DE_ARRAYCOUNT(stream_type_info_arr); k++) {
		if(!de_memcmp(idbuf, stream_type_info_arr[k].magic,
			stream_type_info_arr[k].magic_len))
		{
			si->sti = &stream_type_info_arr[k];
			si->stream_type = si->sti->stream_type;
			break;
		}
	}

	if(si->stream_type==STREAMTYPE_VORBIS) {
		d->found_vorbis = 1;
	}
	else if(si->stream_type==STREAMTYPE_THEORA) {
		d->found_theora = 1;
	}
	else if(si->stream_type==STREAMTYPE_SKELETON) {
		d->found_skeleton = 1;
	}
	else if(si->sti && (si->sti->flags&0x1)) {
		d->found_ogm = 1;
	}

	if(si->stream_type!=STREAMTYPE_VORBIS && si->stream_type!=STREAMTYPE_THEORA) {
		d->has_non_vorbis_non_theora_stream = 1;
	}

	de_dbg(c, "bitstream type: %s", si->sti?si->sti->name:"unknown");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x10, -0x48(%rbp)
jbe 0xc9e63
movq $0x10, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0x164d10
movq $0x0, -0x50(%rbp)
cmpq $0xf, -0x50(%rbp)
jae 0xc9ef8
leaq -0x40(%rbp), %rdi
leaq 0x1506da(%rip), %rax    # 0x21a570
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
leaq 0x1506c7(%rip), %rax    # 0x21a570
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rdx
callq 0x19170
cmpl $0x0, %eax
jne 0xc9ee8
leaq 0x1506aa(%rip), %rcx    # 0x21a570
imulq $0x28, -0x50(%rbp), %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xc9ef8
jmp 0xc9eea
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xc9e84
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0xc9f0b
movq -0x10(%rbp), %rax
movb $0x1, 0x23(%rax)
jmp 0xc9f5d
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0xc9f1e
movq -0x10(%rbp), %rax
movb $0x1, 0x24(%rax)
jmp 0xc9f5b
movq -0x18(%rbp), %rax
cmpl $0x3, (%rax)
jne 0xc9f31
movq -0x10(%rbp), %rax
movb $0x1, 0x21(%rax)
jmp 0xc9f59
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xc9f57
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xc9f57
movq -0x10(%rbp), %rax
movb $0x1, 0x22(%rax)
jmp 0xc9f59
jmp 0xc9f5b
jmp 0xc9f5d
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
je 0xc9f7a
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
je 0xc9f7a
movq -0x10(%rbp), %rax
movl $0x1, 0x34(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xc9f9f
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0xc9fac
leaq 0xd45b6(%rip), %rax     # 0x19e55c
movq %rax, -0x60(%rbp)
jmp 0xc9fac
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rdx
leaq 0xeeafe(%rip), %rsi     # 0x1b8ab9
movb $0x0, %al
callq 0x15b0d0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)