// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_parser.cpp
// Function: ymn::h264_parser::parse_hrd_parameters(ymn::istream<0>&, ymn::h264::hrd_parameters&)
bool h264_parser::parse_hrd_parameters(istream_be& s, h264::hrd_parameters& hrd)
{
    bool retval = false;

    do {
        if (!CHK_EXPR(s.read_exp_golomb_u(hrd.cpb_cnt_minus1), std::cout) ||
            !CHK_STRUCT_RANGE(hrd, cpb_cnt_minus1, 0U, 31U, std::cout)) {
            s.mark_corrupted();
            break;
        }

        s.read_bits(4, hrd.bit_rate_scale);
        s.read_bits(4, hrd.cpb_size_scale);

        for (uint32_t schedSelIdx = 0;
            (schedSelIdx <= hrd.cpb_cnt_minus1) && (s.status() == ISTREAM_STATUS_OK);
           ++schedSelIdx) {
            s.read_exp_golomb_u(hrd.bit_rate_value_minus1[schedSelIdx]);
            s.read_exp_golomb_u(hrd.cpb_size_value_minus1[schedSelIdx]);
            s.read_bits(1, hrd.cbr_flag[schedSelIdx]);
        }

        s.read_bits(5, hrd.initial_cpb_removal_delay_length_minus1);
        s.read_bits(5, hrd.cpb_removal_delay_length_minus1);
        s.read_bits(5, hrd.dpb_output_delay_length_minus1);
        s.read_bits(5, hrd.time_offset_length);

        if (s.status() != ISTREAM_STATUS_OK)
            break;

        hrd.set_valid(true);
        retval = true;
    } while (0);

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %rbx
leaq 0xc(%rdx), %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x70b4
testb %al, %al
je 0x40f7
movl (%r15), %esi
leaq 0x14666(%rip), %rdi     # 0x1863d
movq 0x1cfe2(%rip), %r8      # 0x20fc0
xorl %edx, %edx
movl $0x1f, %ecx
callq 0x716b
testb %al, %al
je 0x4170
leaq 0x10(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x6ee2
movq %r14, 0x8(%rsp)
leaq 0x14(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x6ee2
cmpl $0x0, 0x20(%rbx)
jne 0x408f
movq 0x8(%rsp), %rax
leaq 0x18(%rax), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x98(%rax), %r13
leaq 0x118(%rax), %rbp
movl $0x1, %r14d
leal -0x1(%r14), %r12d
movq 0x10(%rsp), %rax
leaq (%rax,%r12,4), %rsi
movq %rbx, %rdi
callq 0x70b4
leaq (,%r12,4), %rsi
addq %r13, %rsi
movq %rbx, %rdi
callq 0x70b4
leaq (,%r12,4), %rdx
addq %rbp, %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x6ee2
cmpl (%r15), %r14d
ja 0x408f
incl %r14d
cmpl $0x0, 0x20(%rbx)
je 0x4041
movq 0x8(%rsp), %r14
leaq 0x198(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x6ee2
leaq 0x19c(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x6ee2
leaq 0x1a0(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x6ee2
leaq 0x1a4(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x6ee2
cmpl $0x0, 0x20(%rbx)
jne 0x4174
movb $0x1, 0x8(%r14)
movb $0x1, %al
jmp 0x4176
movq 0x1cec2(%rip), %r14     # 0x20fc0
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%r14,%rax)
jne 0x4170
leaq 0x14c4d(%rip), %rsi     # 0x18d61
movl $0x7, %edx
movq %r14, %rdi
callq 0x21d0
leaq 0x144ed(%rip), %rsi     # 0x18615
movl $0x27, %edx
movq %r14, %rdi
callq 0x21d0
leaq 0x14c2d(%rip), %rsi     # 0x18d69
movl $0x7, %edx
movq %r14, %rdi
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
orb $0x4, 0x20(%rbx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop