// File: /workspace/github_c_makefile_star2_O1/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 0x18605
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x17de0
leaq (%rbx,%rax), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movswq %cx, %rsi
leaq 0x219b5(%rip), %rdx     # 0x39787
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
movzwl 0x7cb0(%rbx), %ecx
movw $0x0, 0x7cb0(%rbx)
movl $0x5f, %eax
cmpw $0x2541, %cx            # imm = 0x2541
ja 0x17f73
leaq 0x7cb2(%rbx), %rdi
movq 0x7ca8(%rbx), %rsi
movq %rdi, 0x8(%rsp)
vzeroupper
callq *0x7ca0(%rbx)
movq 0x18(%rbx), %rsi
leaq (,%rsi,2), %rax
testq %rax, %rax
jne 0x17e4e
movq 0x10(%rbx), %rcx
blsrq %rcx, %rax
jne 0x17e4e
movq (%rbx), %r8
movq 0x8(%rbx), %rdx
movq %rdx, %rdi
subq %r8, %rdi
testq %rdi, %rdi
jle 0x17f85
xorl %ebp, %ebp
movq %rbx, %rdi
movl $0x8, %esi
callq 0x1875d
addl %eax, %ebp
cmpl $0xff, %eax
je 0x17e50
xorl %r14d, %r14d
movl %r14d, %r15d
movq %rbx, %rdi
movl $0x8, %esi
callq 0x1875d
movl %eax, %r12d
leal (%r12,%r15), %r14d
cmpl $0xff, %eax
je 0x17e69
movzwl 0x7cb0(%rbx), %eax
movslq %ebp, %r13
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x17ed2
movq %rax, %rdi
addq 0x8(%rsp), %rdi
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movswq %cx, %rsi
leaq 0x1f8fd(%rip), %rax     # 0x377b0
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
leaq 0x218d7(%rip), %rdx     # 0x39798
movl %r13d, %r8d
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
vmovups (%rbx), %ymm0
vmovups %ymm0, 0x10(%rsp)
cmpl $0xcd, %ebp
jg 0x17f00
leaq 0x26815(%rip), %rax     # 0x3e700
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x17f00
movq %rbx, %rdi
vzeroupper
callq *%rax
testl %eax, %eax
je 0x17f53
vmovups 0x10(%rsp), %ymm0
vmovups %ymm0, (%rbx)
testl %r14d, %r14d
jle 0x17f2c
leal (%r12,%r15), %ebp
incl %ebp
movq %rbx, %rdi
movl $0x8, %esi
vzeroupper
callq 0x1875d
decl %ebp
cmpl $0x1, %ebp
jg 0x17f15
movzwl 0x7cb0(%rbx), %eax
movw $0x0, 0x7cb0(%rbx)
cmpw $0x2541, %ax            # imm = 0x2541
ja 0x17f6e
movq 0x7ca8(%rbx), %rsi
movq 0x8(%rsp), %rdi
jmp 0x17e13
tzcntq 0x10(%rbx), %rsi
andl $0x7, %esi
cmpl $0x7, %esi
je 0x17f2c
xorl $0x7, %esi
movq %rbx, %rdi
callq 0x1875d
jmp 0x17f2c
movl $0x5f, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
movq %rsi, %rdi
shrq $0x3f, %rdi
shlxq %rdi, %rsi, %rsi
movl $0x4a, %eax
testq %rsi, %rsi
jne 0x17f73
tzcntq %rcx, %rcx
subl %edx, %r8d
addl %edi, %ecx
leal (%rcx,%r8,8), %eax
addl $0xffffff78, %eax       # imm = 0xFFFFFF78
xorl %ecx, %ecx
cmpl $-0x10, %eax
movl $0x4a, %eax
cmovael %ecx, %eax
jmp 0x17f73