// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rdi, %rbx
callq 0x15327
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x14b77
leaq (%rbx,%rax), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
leaq 0x1ec4e(%rip), %rdx     # 0x337b7
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
movq %rbx, %rdi
callq 0x15361
pushq $0x5f
popq %rcx
testl %eax, %eax
jne 0x14cba
leaq 0x7cb2(%rbx), %r13
pushq $0x8
popq %r14
movq 0x18(%rbx), %rdx
leaq (,%rdx,2), %rax
testq %rax, %rax
jne 0x14bc7
movq 0x10(%rbx), %rsi
blsrq %rsi, %rax
jne 0x14bc7
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq %rcx, %rdi
subq %rax, %rdi
testq %rdi, %rdi
jle 0x14ccb
xorl %ebp, %ebp
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1539a
addl %eax, %ebp
cmpl $0xff, %eax
je 0x14bc9
xorl %r15d, %r15d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1539a
addl %eax, %r15d
cmpl $0xff, %eax
je 0x14be0
movzwl 0x7cb0(%rbx), %eax
movslq %ebp, %r12
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x14c3d
movq %rax, %rdi
addq %r13, %rdi
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
leaq 0x1cbc2(%rip), %rax     # 0x317e0
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
leaq 0x1eb9c(%rip), %rdx     # 0x337c8
movl %r12d, %r8d
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
vmovups (%rbx), %ymm0
vmovups %ymm0, (%rsp)
cmpl $0xcd, %ebp
jg 0x14c6a
leaq 0x24aab(%rip), %rax     # 0x39700
movq (%rax,%r12,8), %rax
testq %rax, %rax
je 0x14c6a
movq %rbx, %rdi
vzeroupper
callq *%rax
testl %eax, %eax
je 0x14c8b
vmovups (%rsp), %ymm0
vmovups %ymm0, (%rbx)
testl %r15d, %r15d
jle 0x14ca4
decl %r15d
movq %rbx, %rdi
movl %r14d, %esi
vzeroupper
callq 0x1539a
jmp 0x14c73
tzcntq 0x10(%rbx), %rsi
andl $0x7, %esi
cmpl $0x7, %esi
je 0x14ca4
xorl $0x7, %esi
movq %rbx, %rdi
callq 0x1539a
movq %rbx, %rdi
vzeroupper
callq 0x15361
testl %eax, %eax
je 0x14b95
pushq $0x5f
popq %rcx
movl %ecx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %rdi
shrq $0x3f, %rdi
shlxq %rdi, %rdx, %rdx
testq %rdx, %rdx
jne 0x14cf4
tzcntq %rsi, %rdx
addl %edi, %edx
subl %ecx, %eax
leal (%rdx,%rax,8), %eax
addl $0xffffff78, %eax       # imm = 0xFFFFFF78
xorl %ecx, %ecx
cmpl $-0x11, %eax
ja 0x14cba
pushq $0x4a
jmp 0x14cb9