// File: /workspace/github_c_makefile_star2_O1/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 0x18223
movsbl 0x548(%rbx), %esi
movq %rbx, %rdi
callq 0x1875d
movl %eax, %ebp
movsbl 0x549(%rbx), %esi
movq %rbx, %rdi
callq 0x1875d
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x18223
leaq (%rbx,%rcx), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movswq %dx, %rsi
leaq 0x221ed(%rip), %rdx     # 0x3a3fd
movl %ebp, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
cmpb $0x0, 0x54b(%rbx)
je 0x18436
movq %rbx, %rdi
movl $0x4, %esi
callq 0x1875d
leal (%rax,%rax), %ecx
movl $0x3be95, %edx          # imm = 0x3BE95
shrxl %ecx, %edx, %r15d
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x18299
leaq (%rbx,%rcx), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movswq %dx, %rsi
movslq %eax, %rcx
leaq 0x20256(%rip), %rdx     # 0x384d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
leaq 0x221a9(%rip), %rdx     # 0x3a431
movl %eax, %r8d
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
andl $0x3, %r15d
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x182d7
leaq (%rbx,%rax), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movswq %cx, %rsi
leaq 0x22181(%rip), %rdx     # 0x3a44a
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
testl %r15d, %r15d
je 0x18436
leaq 0x7cb2(%rbx), %r12
movq %rbx, %rdi
callq 0x2551d
testl %eax, %eax
je 0x1842d
movq %rbx, %rdi
movl $0x13, %esi
callq 0x1875d
movl %eax, %ebp
movq %rbx, %rdi
btl $0xa, %eax
jb 0x18357
callq 0x2551d
testl %eax, %eax
je 0x18379
movq %rbx, %rdi
movl $0x7, %esi
callq 0x1875d
movl %eax, %ecx
shrl %ecx
movb %cl, 0x28(%rbx)
testb $0x1, %al
je 0x18379
movq %rbx, %rdi
movl $0x7, %esi
callq 0x1875d
movl %eax, %ecx
shrl %ecx
movb %cl, 0x27(%rbx)
testb $0x1, %al
je 0x18379
movq %rbx, %rdi
movl $0x5, %esi
callq 0x1875d
jmp 0x18376
movl $0x11, %esi
callq 0x1875d
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 0x1838e
movq %rbx, %rdi
callq 0x1875d
jmp 0x18390
xorl %eax, %eax
movzwl 0x7cb0(%rbx), %ecx
cmpq $0x2541, %rcx           # imm = 0x2541
ja 0x1842d
movq %rcx, %rdi
addq %r12, %rdi
movl $0x2542, %edx           # imm = 0x2542
subl %ecx, %edx
movswq %dx, %rsi
movl %ebp, %r8d
shrl $0x11, %r8d
leaq 0x2014d(%rip), %rdx     # 0x38510
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 0x2204f(%rip), %rdx     # 0x3a461
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 0x182e7
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq