// File: /workspace/github_c_makefile_star2_O2/tvlabs[P]edge264/edge264_headers.c
// Function: parse_hrd_parameters
static void parse_hrd_parameters(Edge264Decoder *dec, Edge264SeqParameterSet *sps, int8_t *cpb_cnt, const char *indent) {
	*cpb_cnt = get_ue16(&dec->_gb, 31) + 1;
	int bit_rate_scale = get_uv(&dec->_gb, 4);
	int cpb_size_scale = get_uv(&dec->_gb, 4);
	log_dec(dec, "%scpbs:\n", indent);
	for (int i = 0; i < *cpb_cnt; i++) {
		unsigned long long bit_rate_value = get_ue32(&dec->_gb, 4294967294) + 1;
		unsigned long long cpb_size_value = get_ue32(&dec->_gb, 4294967294) + 1;
		int cbr_flag = get_u1(&dec->_gb);
		log_dec(dec, "%s  - {bit_rate: %llu, size: %llu, cbr_flag: %u}\n",
			indent, bit_rate_value << (6 + bit_rate_scale), cpb_size_value << (4 + cpb_size_scale), cbr_flag);
	}
	unsigned delays = get_uv(&dec->_gb, 20);
	sps->initial_cpb_removal_delay_length = (delays >> 15) + 1;
	sps->cpb_removal_delay_length = ((delays >> 10) & 0x1f) + 1;
	sps->dpb_output_delay_length = ((delays >> 5) & 0x1f) + 1;
	sps->time_offset_length = delays & 0x1f;
	log_dec(dec, "%sinitial_cpb_removal_delay_length: %u\n"
		"%scpb_removal_delay_length: %u\n"
		"%sdpb_output_delay_length: %u\n"
		"%stime_offset_length: %u\n",
		indent, sps->initial_cpb_removal_delay_length,
		indent, sps->cpb_removal_delay_length,
		indent, sps->dpb_output_delay_length,
		indent, sps->time_offset_length);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, (%rsp)
movq %rdx, %r13
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
pushq $0x1f
popq %rsi
callq 0x1f4be
incb %al
movb %al, (%r13)
pushq $0x4
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1539a
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1539a
movq %rax, 0x8(%rsp)
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x2bfd0
leaq (%rbx,%rax), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
leaq 0x9211(%rip), %rdx      # 0x351cf
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
leaq 0x7cb2(%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rax
addl $0x6, %eax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rax
addl $0x4, %eax
movq %rax, 0x8(%rsp)
pushq $-0x2
popq %r14
xorl %r15d, %r15d
movsbl (%r13), %eax
cmpl %eax, %r15d
jge 0x2c095
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1f4be
movl %eax, %r12d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1f4be
movl %eax, %ebp
movq %rbx, %rdi
callq 0x1f662
movl %eax, %r10d
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x2c08d
incl %ebp
incl %r12d
movq %rax, %rdi
addq 0x18(%rsp), %rdi
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
movq 0x10(%rsp), %rax
shlxq %rax, %r12, %r8
movq 0x8(%rsp), %rax
shlxq %rax, %rbp, %r9
subq $0x8, %rsp
leaq 0x9162(%rip), %rdx      # 0x351d8
movq 0x8(%rsp), %rcx
xorl %eax, %eax
pushq %r10
callq 0x1070
popq %rcx
popq %rdx
addw %ax, 0x7cb0(%rbx)
incl %r15d
jmp 0x2bffd
pushq $0x14
popq %rsi
movq %rbx, %rdi
callq 0x1539a
movl %eax, %r10d
shrl $0xf, %eax
incb %al
movq 0x20(%rsp), %rdi
movb %al, 0x17(%rdi)
movl %r10d, %ecx
shrl $0xa, %ecx
andb $0x1f, %cl
incb %cl
movb %cl, 0x18(%rdi)
movl %r10d, %edx
shrl $0x5, %edx
andb $0x1f, %dl
incb %dl
movb %dl, 0x19(%rdi)
movl %r10d, %esi
andb $0x1f, %sil
movb %sil, 0x1a(%rdi)
movzwl 0x7cb0(%rbx), %esi
cmpq $0x2542, %rsi           # imm = 0x2542
jae 0x2c139
movq 0x18(%rsp), %rdi
addq %rsi, %rdi
movl $0x2542, %r8d           # imm = 0x2542
subl %esi, %r8d
movzwl %r8w, %esi
movsbl %al, %r8d
movzbl %cl, %r11d
movzbl %dl, %r14d
andl $0x1f, %r10d
subq $0x8, %rsp
leaq 0x90f3(%rip), %rdx      # 0x3520a
movq 0x8(%rsp), %rcx
movq %rcx, %r9
xorl %eax, %eax
pushq %r10
pushq %rcx
pushq %r14
pushq %rcx
pushq %r11
callq 0x1070
addq $0x30, %rsp
addw %ax, 0x7cb0(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq