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

    do {
        s.read_bits(1, drpm.adaptive_ref_pic_marking_mode_flag);
        if (drpm.adaptive_ref_pic_marking_mode_flag) {
            size_t i = 0;
            uint32_t memory_management_control_operation;
            uint32_t difference_of_pic_nums_minus1;
            uint32_t long_term_pic_num;
            uint32_t long_term_frame_idx;
            uint32_t max_long_term_frame_idx_plus1;

            do {
                s.read_exp_golomb_u(memory_management_control_operation);

                difference_of_pic_nums_minus1 = 0;
                long_term_pic_num = 0;
                long_term_frame_idx = 0;
                max_long_term_frame_idx_plus1 = 0;

                if (memory_management_control_operation) {
                    if (memory_management_control_operation == 1 ||
                        memory_management_control_operation == 3)
                        s.read_exp_golomb_u(difference_of_pic_nums_minus1);

                    if (memory_management_control_operation == 2)
                        s.read_exp_golomb_u(long_term_pic_num);

                    if (memory_management_control_operation == 3 ||
                        memory_management_control_operation == 6)
                        s.read_exp_golomb_u(long_term_frame_idx);

                    if (memory_management_control_operation == 4)
                        s.read_exp_golomb_u(max_long_term_frame_idx_plus1);
                }

                if (i < TABLE_ELEMENTS(drpm.mmco)) {
                    drpm.mmco[i].memory_management_control_operation = memory_management_control_operation;
                    drpm.mmco[i].difference_of_pic_nums_minus1 = difference_of_pic_nums_minus1;
                    drpm.mmco[i].long_term_pic_num = long_term_pic_num;
                    drpm.mmco[i].long_term_frame_idx = long_term_frame_idx;
                    drpm.mmco[i].max_long_term_frame_idx_plus1 = max_long_term_frame_idx_plus1;
                }

                i++;
            } while ((s.status() == ISTREAM_STATUS_OK) && (memory_management_control_operation != 0));
        }

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

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

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
addq $0xc, %rdx
movq %rsi, %rdi
movl $0x1, %esi
callq 0x6ee2
cmpl $0x0, 0xc(%rbx)
je 0x4829
movq %rbx, 0x20(%rsp)
leaq 0x20(%rbx), %r12
xorl %r13d, %r13d
leaq 0xc(%rsp), %r15
leaq 0x14(%rsp), %rbp
xorl %ebx, %ebx
movq %r14, %rdi
movq %r15, %rsi
callq 0x70b4
movl %r13d, 0x1c(%rsp)
movl %r13d, 0x18(%rsp)
movl %r13d, 0x14(%rsp)
movl %r13d, 0x10(%rsp)
movl 0xc(%rsp), %eax
movl $0x0, %ecx
testl %eax, %eax
je 0x47dd
movl %eax, %ecx
andl $-0x3, %ecx
cmpl $0x1, %ecx
jne 0x4796
movq %r14, %rdi
leaq 0x1c(%rsp), %rsi
callq 0x70b4
movl 0xc(%rsp), %eax
cmpl $0x2, %eax
jne 0x47ac
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x70b4
movl 0xc(%rsp), %eax
cmpl $0x6, %eax
je 0x47b6
cmpl $0x3, %eax
jne 0x47c5
movq %r14, %rdi
movq %rbp, %rsi
callq 0x70b4
movl 0xc(%rsp), %eax
movl %eax, %ecx
cmpl $0x4, %eax
jne 0x47dd
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x70b4
movl 0xc(%rsp), %ecx
cmpq $0x3, %rbx
ja 0x480b
movl %ecx, -0x10(%r12)
movl 0x1c(%rsp), %eax
movl %eax, -0xc(%r12)
movl 0x18(%rsp), %eax
movl %eax, -0x8(%r12)
movl 0x14(%rsp), %eax
movl %eax, -0x4(%r12)
movl 0x10(%rsp), %eax
movl %eax, (%r12)
movl 0x20(%r14), %eax
testl %eax, %eax
jne 0x4822
incq %rbx
addq $0x14, %r12
testl %ecx, %ecx
jne 0x474f
movq 0x20(%rsp), %rbx
jmp 0x482d
movl 0x20(%r14), %eax
testl %eax, %eax
jne 0x4835
movb $0x1, 0x8(%rbx)
testl %eax, %eax
sete %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop