// File: /workspace/github_c_makefile_star2_O3/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 0x185ba
movsbl 0x548(%rbx), %esi
movq %rbx, %rdi
callq 0x18ad7
movl %eax, %ebp
movsbl 0x549(%rbx), %esi
movq %rbx, %rdi
callq 0x18ad7
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x185ba
leaq (%rbx,%rcx), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movzwl %dx, %esi
leaq 0x21fd6(%rip), %rdx     # 0x3a57d
movl %ebp, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
cmpb $0x0, 0x54b(%rbx)
je 0x187ce
movq %rbx, %rdi
movl $0x4, %esi
callq 0x18ad7
leal (%rax,%rax), %ecx
movl $0x3be95, %edx          # imm = 0x3BE95
shrxl %ecx, %edx, %r15d
andl $0x3, %r15d
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x18670
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 0x20027(%rip), %rdx     # 0x38640
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
leaq 0x21f8a(%rip), %rdx     # 0x3a5b1
movl %eax, %r8d
xorl %eax, %eax
callq 0x1070
addw 0x7cb0(%rbx), %ax
movw %ax, 0x7cb0(%rbx)
movzwl %ax, %eax
cmpl $0x2541, %eax           # imm = 0x2541
ja 0x18670
leaq 0x7cb2(%rbx), %rcx
movq %rax, %rdi
addq %rcx, %rdi
subl %eax, %ebp
movzwl %bp, %esi
leaq 0x21f68(%rip), %rdx     # 0x3a5ca
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
testl %r15d, %r15d
je 0x187ce
leaq 0x7cb2(%rbx), %r12
movq %rbx, %rdi
callq 0x25dac
testl %eax, %eax
je 0x187c5
movq %rbx, %rdi
movl $0x13, %esi
callq 0x18ad7
movl %eax, %ebp
movq %rbx, %rdi
btl $0xa, %eax
jb 0x186f0
callq 0x25dac
testl %eax, %eax
je 0x18712
movq %rbx, %rdi
movl $0x7, %esi
callq 0x18ad7
movl %eax, %ecx
shrl %ecx
movb %cl, 0x28(%rbx)
testb $0x1, %al
je 0x18712
movq %rbx, %rdi
movl $0x7, %esi
callq 0x18ad7
movl %eax, %ecx
shrl %ecx
movb %cl, 0x27(%rbx)
testb $0x1, %al
je 0x18712
movq %rbx, %rdi
movl $0x5, %esi
callq 0x18ad7
jmp 0x1870f
movl $0x11, %esi
callq 0x18ad7
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 0x18727
movq %rbx, %rdi
callq 0x18ad7
jmp 0x18729
xorl %eax, %eax
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x187c5
movq %rcx, %rdi
addq %r12, %rdi
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movzwl %dx, %esi
movl %ebp, %r8d
shrl $0x11, %r8d
leaq 0x1ff25(%rip), %rdx     # 0x38680
movslq (%rdx,%r8,4), %rcx
addq %rdx, %rcx
movl %ebp, %r9d
shrl $0x9, %r9d
andl $0x1, %r9d
movsbl 0x26(%rbx), %r10d
movsbl 0x27(%rbx), %r11d
movsbl 0x28(%rbx), %r14d
movzbl %bpl, %edx
btl $0x10, %ebp
movl $0x0, %ebp
adcl $0x1, %ebp
imull %edx, %ebp
imull 0x550(%rbx), %ebp
addl %eax, %ebp
movl 0x554(%rbx), %r13d
subq $0x8, %rsp
leaq 0x21e37(%rip), %rdx     # 0x3a5e1
xorl %eax, %eax
pushq %r13
pushq %rbp
pushq %r14
pushq %r11
pushq %r10
callq 0x1070
addq $0x30, %rsp
addw %ax, 0x7cb0(%rbx)
decl %r15d
jne 0x18680
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq