// File: /workspace/github_c_makefile_star2_O3/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, 0x8(%rsp)
movq %rdx, %r12
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
movl $0x1f, %esi
callq 0x25872
incb %al
movb %al, (%r12)
movq %rbx, %rdi
movl $0x4, %esi
callq 0x18ad7
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
movl $0x4, %esi
callq 0x18ad7
movq %rax, 0x10(%rsp)
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x3286d
leaq (%rbx,%rax), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
leaq 0x8ac5(%rip), %rdx      # 0x3b31f
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x1070
addw %ax, 0x7cb0(%rbx)
cmpb $0x0, (%r12)
jle 0x32932
leaq 0x7cb2(%rbx), %r13
movq 0x18(%rsp), %rax
addl $0x6, %eax
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rax
addl $0x4, %eax
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x25872
movl %eax, %r15d
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x25872
movl %eax, %r14d
movq %rbx, %rdi
callq 0x25dac
movl %eax, %r10d
movzwl 0x7cb0(%rbx), %eax
cmpq $0x2541, %rax           # imm = 0x2541
ja 0x32923
incl %r14d
incl %r15d
movq %rax, %rdi
addq %r13, %rdi
movl $0x2542, %ecx           # imm = 0x2542
subl %eax, %ecx
movzwl %cx, %esi
movq 0x18(%rsp), %rax
shlxq %rax, %r15, %r8
movq 0x10(%rsp), %rax
shlxq %rax, %r14, %r9
subq $0x8, %rsp
leaq 0x8a1e(%rip), %rdx      # 0x3b328
movq 0x10(%rsp), %rcx
xorl %eax, %eax
pushq %r10
callq 0x1070
addq $0x10, %rsp
addw %ax, 0x7cb0(%rbx)
incl %ebp
movsbl (%r12), %eax
cmpl %eax, %ebp
jl 0x3289b
movq %rbx, %rdi
movl $0x14, %esi
callq 0x18ad7
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 0x329db
leaq (%rbx,%rsi), %rdi
addq $0x7cb2, %rdi           # imm = 0x7CB2
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 0x89a1(%rip), %rdx      # 0x3b35a
movq 0x10(%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