// File: /workspace/github_c_makefile_star2_O2/tvlabs[P]edge264/./edge264_sei.c
// Function: parse_pic_timing
static int parse_pic_timing(Edge264Decoder *dec) {
	static const char * const pic_struct_names[16] = {
		"progressive frame", "top field", "bottom field", "top then bottom",
		"bottom then top", "top then bottom then top",
		"bottom then top then bottom", "frame doubling", "frame tripling",
		[9 ... 15] = "Unknown"};
	static const char * const ct_type_names[4] = {
		"progressive", "interlaced", [2 ... 3] = "unknown"};
	
	if (dec->sps.nal_hrd_cpb_cnt | dec->sps.vcl_hrd_cpb_cnt) {
		int cpb_removal_delay = get_uv(&dec->_gb, dec->sps.cpb_removal_delay_length);
		int dpb_output_delay = get_uv(&dec->_gb, dec->sps.dpb_output_delay_length);
		log_dec(dec, "    cpb_removal_delay: %u\n"
			"    dpb_output_delay: %u\n",
			cpb_removal_delay, dpb_output_delay);
	}
	if (dec->sps.pic_struct_present_flag) {
		int pic_struct = get_uv(&dec->_gb, 4);
		int NumClockTS = 0x3be95 >> (pic_struct * 2) & 3;
		log_dec(dec, "    pic_struct: %s (%u)\n",
			pic_struct_names[pic_struct], pic_struct);
		log_dec(dec, "    clock_timestamps:\n");
		while (NumClockTS--) {
			if (!get_u1(&dec->_gb)) // clock_timestamp_flag
				continue;
			unsigned u = get_uv(&dec->_gb, 19);
			if (u & 1 << 10) {
				unsigned v = get_uv(&dec->_gb, 17);
				dec->sS = v >> 11;
				dec->mM = v >> 5 & 0x3f;
				dec->hH = v & 0x1f;
			} else if (get_u1(&dec->_gb)) { // seconds_flag
				unsigned w = get_uv(&dec->_gb, 7);
				dec->sS = w >> 1;
				if (w & 1) {
					unsigned x = get_uv(&dec->_gb, 7);
					dec->mM = x >> 1;
					if (x & 1)
						dec->hH = get_uv(&dec->_gb, 5);
				}
			}
			int tOffset = 0;
			if (dec->sps.time_offset_length)
				tOffset = get_uv(&dec->_gb, dec->sps.time_offset_length);
			log_dec(dec, "      - scan_type: %s (%u)\n"
				"        discontinuity_flag: %u\n"
				"        clockTimestamp: \"%02u:%02u:%02u+%u/%u\"\n",
				ct_type_names[u >> 17], u >> 17,
				u >> 9 & 1,
				dec->hH, dec->mM, dec->sS, (u & 0xff) * (dec->sps.num_units_in_tick * (1 + (u >> 16 & 1))) + tOffset, dec->sps.time_scale);
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x546(%rdi), %al
orb 0x545(%rdi), %al
je 0x14f60
movsbl 0x548(%rbx), %esi
movq %rbx, %rdi
callq 0x1539a
movl %eax, %ebp
movsbl 0x549(%rbx), %esi
movq %rbx, %rdi
callq 0x1539a
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x14f60
leaq (%rbx,%rcx), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movzwl %dx, %esi
leaq 0x1f4e0(%rip), %rdx     # 0x3442d
movl %ebp, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
cmpb $0x0, 0x54b(%rbx)
je 0x1516c
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x1539a
leal (%rax,%rax), %ecx
movl $0x3be95, %edx          # imm = 0x3BE95
shrxl %ecx, %edx, %r14d
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x1500c
leaq (%rbx,%rcx), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %ebp           # imm = 0x2542
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movzwl %dx, %esi
movslq %eax, %rcx
leaq 0x1d547(%rip), %rdx     # 0x32500
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
leaq 0x1f49a(%rip), %rdx     # 0x34461
movl %eax, %r8d
xorl %eax, %eax
callq 0x1070
addw 0x7cb0(%rbx), %ax
movw %ax, 0x7cb0(%rbx)
cmpw $0x2541, %ax            # imm = 0x2541
ja 0x1500c
leaq 0x7cb2(%rbx), %rcx
movzwl %ax, %edi
addq %rcx, %rdi
subl %eax, %ebp
movzwl %bp, %esi
leaq 0x1f47c(%rip), %rdx     # 0x3447a
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
andl $0x3, %r14d
leaq 0x7cb2(%rbx), %rax
movq %rax, (%rsp)
pushq $0x13
popq %r12
subl $0x1, %r14d
jb 0x1516c
movq %rbx, %rdi
callq 0x1f662
testl %eax, %eax
je 0x1501f
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1539a
movl %eax, %r15d
movq %rbx, %rdi
btl $0xa, %eax
jb 0x1508e
callq 0x1f662
testl %eax, %eax
je 0x150ae
movq %rbx, %rdi
pushq $0x7
popq %rsi
callq 0x1539a
movl %eax, %ecx
shrl %ecx
movb %cl, 0x28(%rbx)
testb $0x1, %al
je 0x150ae
movq %rbx, %rdi
pushq $0x7
popq %rsi
callq 0x1539a
movl %eax, %ecx
shrl %ecx
movb %cl, 0x27(%rbx)
testb $0x1, %al
je 0x150ae
movq %rbx, %rdi
pushq $0x5
popq %rsi
callq 0x1539a
jmp 0x150ab
pushq $0x11
popq %rsi
callq 0x1539a
movl %eax, %ecx
shrl $0xb, %ecx
movb %cl, 0x28(%rbx)
movl %eax, %ecx
shrl $0x5, %ecx
andb $0x3f, %cl
movb %cl, 0x27(%rbx)
andb $0x1f, %al
movb %al, 0x26(%rbx)
movsbl 0x54a(%rbx), %esi
testl %esi, %esi
je 0x150c3
movq %rbx, %rdi
callq 0x1539a
jmp 0x150c5
xorl %eax, %eax
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2542, %rcx           # imm = 0x2542
jae 0x1501f
movq %rcx, %rdi
addq (%rsp), %rdi
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movzwl %dx, %esi
movl %r15d, %r8d
shrl $0x11, %r8d
leaq 0x1d448(%rip), %rdx     # 0x32540
movslq (%rdx,%r8,4), %rcx
addq %rdx, %rcx
movl %r15d, %r9d
shrl $0x9, %r9d
andl $0x1, %r9d
movsbl 0x26(%rbx), %r10d
movsbl 0x27(%rbx), %r11d
movsbl 0x28(%rbx), %ebp
movzbl %r15b, %edx
btl $0x10, %r15d
movl $0x0, %r15d
adcl $0x1, %r15d
imull %edx, %r15d
imull 0x550(%rbx), %r15d
addl %eax, %r15d
movl 0x554(%rbx), %r13d
subq $0x8, %rsp
leaq 0x1f345(%rip), %rdx     # 0x34491
xorl %eax, %eax
pushq %r13
pushq %r15
pushq %rbp
pushq %r11
pushq %r10
callq 0x1070
addq $0x30, %rsp
addw %ax, 0x7cb0(%rbx)
jmp 0x1501f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq