// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x20(%rbp)
movl %esi, -0x24(%rbp)
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x65d80
movq -0x20(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x6512c
movq -0x20(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x20(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x20(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
leaq 0x6aaf4(%rip), %rdx     # 0xcfc03
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x20(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
movq -0x20(%rbp), %rdi
callq 0x65e20
cmpl $0x0, %eax
je 0x65146
movl $0x5f, -0x14(%rbp)
jmp 0x65431
movl $0x0, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
shlq %rcx
movb $0x1, %al
cmpq $0x0, %rcx
movb %al, -0x71(%rbp)
jne 0x651a1
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
subq $0x1, %rax
andq %rax, %rcx
movb $0x1, %al
cmpq $0x0, %rcx
movb %al, -0x71(%rbp)
jne 0x651a1
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
cmpq $0x0, %rax
setg %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x651ad
jmp 0x65374
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x20(%rbp), %rdi
movl $0x8, %esi
callq 0x65e90
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $0xff, -0x40(%rbp)
je 0x651bb
jmp 0x651e0
movq -0x20(%rbp), %rdi
movl $0x8, %esi
callq 0x65e90
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0xff, -0x40(%rbp)
je 0x651e0
movq -0x20(%rbp), %rax
movswq 0x7ca0(%rax), %rax
cmpq $0x2542, %rax           # imm = 0x2542
jae 0x6527d
movq -0x20(%rbp), %rdi
addq $0x7ca2, %rdi           # imm = 0x7CA2
movq -0x20(%rbp), %rax
movswl 0x7ca0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x20(%rbp), %rax
movswq 0x7ca0(%rax), %rax
movl $0x2542, %esi           # imm = 0x2542
subq %rax, %rsi
movslq -0x44(%rbp), %rcx
leaq 0x702af(%rip), %rax     # 0xd5500
movq (%rax,%rcx,8), %rcx
movl -0x44(%rbp), %r8d
leaq 0x6a9b4(%rip), %rdx     # 0xcfc14
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x20(%rbp), %rax
movswl 0x7ca0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x7ca0(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x68(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x60(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x5f, -0x6c(%rbp)
cmpl $0xcd, -0x44(%rbp)
jg 0x652da
movslq -0x44(%rbp), %rcx
leaq 0x708b5(%rip), %rax     # 0xd5b70
cmpq $0x0, (%rax,%rcx,8)
je 0x652da
movslq -0x44(%rbp), %rcx
leaq 0x708a3(%rip), %rax     # 0xd5b70
movq (%rax,%rcx,8), %rax
movq -0x20(%rbp), %rdi
callq *%rax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
je 0x65325
movq -0x20(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
movq -0x60(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl -0x48(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x48(%rbp)
cmpl $0x0, %eax
jle 0x65323
movq -0x20(%rbp), %rdi
movl $0x8, %esi
callq 0x65e90
jmp 0x65303
jmp 0x65355
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
tzcntq %rax, %rax
movl %eax, %ecx
movl $0x3f, %eax
subl %ecx, %eax
andl $0x7, %eax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x70(%rbp)
je 0x65353
movq -0x20(%rbp), %rdi
movl -0x70(%rbp), %esi
callq 0x65e90
jmp 0x65355
movq -0x20(%rbp), %rdi
callq 0x65e20
cmpl $0x0, %eax
je 0x6536f
movl $0x5f, -0x14(%rbp)
jmp 0x65431
jmp 0x6514d
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x3f, %rax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
tzcntq %rax, %rax
movl %eax, %ecx
movl $0x7f, %eax
subl %ecx, %eax
subl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x72(%rbp)
jne 0x6540c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
subq $0x1, %rax
andq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x72(%rbp)
jne 0x6540c
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movl -0x10(%rbp), %ecx
shrl $0x3, %ecx
movl %ecx, %ecx
addq %rcx, %rax
cmpq $0x0, %rax
sete %al
movb %al, -0x72(%rbp)
movb -0x72(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x65421
movl -0x3c(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x6542b
movl $0x4a, %eax
movl %eax, -0x78(%rbp)
jmp 0x6542b
movl -0x78(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)