// File: /workspace/github_c_makefile_star2_O3/tvlabs[P]edge264/./edge264_sei.c
// Function: parse_sei_log
int ADD_VARIANT(parse_sei)(Edge264Decoder *dec, int non_blocking, void(*free_cb)(void*,int), void *free_arg)
{
	static const char * const payloadType_names[206] = {
		[0 ... 205] = "Unknown",
		[0] = "Buffering period",
		[1] = "Picture timing",
		[2] = "Pan-scan rectangle",
	};
	static const SEI_Parser parse_sei_message[206] = {
		[0] = parse_buffering_period,
		[1] = parse_pic_timing,
		[2] = parse_pan_scan_rect,
	};
	
	refill(&dec->_gb, 0);
	log_dec(dec, "  sei_messages:\n");
	if (print_dec(dec))
		return ENOTSUP;
	int ret = 0;
	while (dec->_gb.msb_cache << 1 || (dec->_gb.lsb_cache & (dec->_gb.lsb_cache - 1)) || (intptr_t)(dec->_gb.end - dec->_gb.CPB) > 0) {
		int byte, payloadType = 0, payloadSize = 0;
		do {
			byte = get_uv(&dec->_gb, 8);
			payloadType += byte;
		} while (byte == 255);
		do {
			byte = get_uv(&dec->_gb, 8);
			payloadSize += byte;
		} while (byte == 255);
		log_dec(dec, "  - payloadType: %s (%u)\n",
			payloadType_names[payloadType], payloadType);
		Edge264GetBits start = dec->_gb;
		int res = ENOTSUP;
		if (payloadType <= 205 && parse_sei_message[payloadType])
			res = parse_sei_message[payloadType](dec);
		if (res) {
			//ret = ENOTSUP;
			dec->_gb = start;
			while (payloadSize-- > 0)
				get_uv(&dec->_gb, 8);
		} else {
			int skip = (SIZE_BIT - 1 - ctz(dec->_gb.lsb_cache)) & 7;
			if (skip)
				get_uv(&dec->_gb, skip);
		}
		if (print_dec(dec))
			return ENOTSUP;
	}
	return rbsp_end(&dec->_gb) ? ret : EBADMSG;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
callq 0x18999
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x182f5
leaq (%rbx,%rax), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
leaq 0x217aa(%rip), %rdx     # 0x39907
xorl %eax, %eax
callq 0x1070
addw 0x7cb0(%rbx), %ax
movw $0x0, 0x7cb0(%rbx)
movzwl %ax, %ecx
movl $0x5f, %eax
cmpl $0x2541, %ecx           # imm = 0x2541
ja 0x18303
leaq 0x7cb2(%rbx), %rdi
movq 0x7ca8(%rbx), %rsi
movq %rdi, 0x8(%rsp)
vzeroupper
callq *0x7ca0(%rbx)
movq 0x18(%rbx), %rdx
leaq (,%rdx,2), %rax
testq %rax, %rax
jne 0x181d6
movq 0x10(%rbx), %rsi
blsrq %rsi, %rax
jne 0x181d6
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq %rcx, %rdi
subq %rax, %rdi
testq %rdi, %rdi
jle 0x18315
xorl %ebp, %ebp
movq %rbx, %rdi
movl $0x8, %esi
callq 0x18ad7
addl %eax, %ebp
cmpl $0xff, %eax
je 0x181d8
xorl %r14d, %r14d
movl %r14d, %r15d
movq %rbx, %rdi
movl $0x8, %esi
callq 0x18ad7
movl %eax, %r12d
leal (%r12,%r15), %r14d
cmpl $0xff, %eax
je 0x181f1
movzwl 0x7cb0(%rbx), %eax
movslq %ebp, %r13
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x18259
movq %rax, %rdi
addq 0x8(%rsp), %rdi
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
leaq 0x1f6e6(%rip), %rax     # 0x37920
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
leaq 0x216d0(%rip), %rdx     # 0x39918
movl %r13d, %r8d
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
vmovups (%rbx), %ymm0
vmovups %ymm0, 0x10(%rsp)
cmpl $0xcd, %ebp
jg 0x18287
leaq 0x2648e(%rip), %rax     # 0x3e700
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x18287
movq %rbx, %rdi
vzeroupper
callq *%rax
testl %eax, %eax
je 0x182da
vmovups 0x10(%rsp), %ymm0
vmovups %ymm0, (%rbx)
testl %r14d, %r14d
jle 0x182b3
leal (%r12,%r15), %ebp
incl %ebp
movq %rbx, %rdi
movl $0x8, %esi
vzeroupper
callq 0x18ad7
decl %ebp
cmpl $0x1, %ebp
ja 0x1829c
movzwl 0x7cb0(%rbx), %eax
movw $0x0, 0x7cb0(%rbx)
cmpw $0x2542, %ax            # imm = 0x2542
jae 0x182fe
movq 0x7ca8(%rbx), %rsi
movq 0x8(%rsp), %rdi
jmp 0x1819b
tzcntq 0x10(%rbx), %rsi
andl $0x7, %esi
cmpl $0x7, %esi
je 0x182b3
xorl $0x7, %esi
movq %rbx, %rdi
callq 0x18ad7
jmp 0x182b3
movw $0x0, 0x7cb0(%rbx)
movl $0x5f, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
movq %rdx, %rdi
shrq $0x3f, %rdi
shlxq %rdi, %rdx, %rdx
testq %rdx, %rdx
jne 0x1833f
tzcntq %rsi, %rdx
addl %edi, %edx
subl %ecx, %eax
leal (%rdx,%rax,8), %ecx
addl $0xffffff78, %ecx       # imm = 0xFFFFFF78
xorl %eax, %eax
cmpl $-0x11, %ecx
ja 0x18303
movl $0x4a, %eax
jmp 0x18303