LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_parser.cpp
// Function: h264_parser_parse_pred_weight_table_lx(ymn::istream<0>&, ymn::h264::pred_weight_table::lx&, unsigned int, bool)
static void h264_parser_parse_pred_weight_table_lx(
    istream_be& s, h264::pred_weight_table::lx& lx, uint32_t num_ref_idx_lx_active_minus1, bool chroma_components_present)
{
    for (uint32_t i = 0;
        (i <= num_ref_idx_lx_active_minus1) && (s.status() == ISTREAM_STATUS_OK);
       ++i) {
        s.read_bits(1, lx.luma_weight_lx_flag[i]);
        if (lx.luma_weight_lx_flag[i]) {
            s.read_exp_golomb_s(lx.luma_weight_lx[i]);
            s.read_exp_golomb_s(lx.luma_offset_lx[i]);
        }
        if (chroma_components_present) {
            s.read_bits(1, lx.chroma_weight_lx_flag[i]);
            if (lx.chroma_weight_lx_flag[i]) {
                s.read_exp_golomb_s(lx.chroma_weight_lx[i][0]);
                s.read_exp_golomb_s(lx.chroma_offset_lx[i][0]);
                s.read_exp_golomb_s(lx.chroma_weight_lx[i][1]);
                s.read_exp_golomb_s(lx.chroma_offset_lx[i][1]);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, 0x4(%rsp)
cmpl $0x0, 0x20(%rdi)
jne 0x46b2
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x80(%rsi), %rax
movq %rax, 0x30(%rsp)
leaq 0x100(%rsi), %rax
movq %rax, 0x28(%rsp)
leaq 0x180(%rsi), %rax
movq %rax, 0x20(%rsp)
leaq 0x200(%rsi), %rax
movq %rax, 0x18(%rsp)
leaq 0x300(%rsi), %rax
movq %rax, 0x10(%rsp)
movl $0x1, %r13d
movq %rsi, 0x8(%rsp)
leal -0x1(%r13), %ebx
leaq (%r14,%rbx,4), %r12
movq %r15, %rdi
movl $0x1, %esi
movq %r12, %rdx
callq 0x6ee2
cmpl $0x0, (%r12)
je 0x4621
movq 0x30(%rsp), %rax
leaq (%rax,%rbx,4), %rsi
movq %r15, %rdi
callq 0x7410
movq 0x28(%rsp), %rax
leaq (%rax,%rbx,4), %rsi
movq %r15, %rdi
callq 0x7410
cmpb $0x0, 0x4(%rsp)
je 0x469f
movq 0x20(%rsp), %rax
leaq (%rax,%rbx,4), %r12
movq %r15, %rdi
movl $0x1, %esi
movq %r12, %rdx
callq 0x6ee2
cmpl $0x0, (%r12)
je 0x469f
movq 0x18(%rsp), %r12
leaq (%r12,%rbx,8), %rsi
movq %r15, %rdi
callq 0x7410
movl %ebp, %r14d
movq 0x10(%rsp), %rbp
leaq (,%rbx,8), %rsi
addq %rbp, %rsi
movq %r15, %rdi
callq 0x7410
leaq (%r12,%rbx,8), %rsi
addq $0x4, %rsi
movq %r15, %rdi
callq 0x7410
leaq 0x4(,%rbx,8), %rsi
addq %rbp, %rsi
movl %r14d, %ebp
movq 0x8(%rsp), %r14
movq %r15, %rdi
callq 0x7410
cmpl %ebp, %r13d
ja 0x46b2
incl %r13d
cmpl $0x0, 0x20(%r15)
je 0x45e0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_parser.cpp
// Function: ymn::h264_parser::parse_dec_ref_pic_marking_idr(ymn::istream<0>&, ymn::h264::dec_ref_pic_marking_idr&)
bool h264_parser::parse_dec_ref_pic_marking_idr(istream_be& s, h264::dec_ref_pic_marking_idr& drpm)
{
    bool retval = false;

    do {
        s.read_bits(1, drpm.no_output_of_prior_pics_flag);
        s.read_bits(1, drpm.long_term_reference_flag);

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

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

    return retval;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
addq $0xc, %rdx
movq %rsi, %rdi
movl $0x1, %esi
callq 0x6ee2
leaq 0x10(%rbx), %rdx
movq %r14, %rdi
movl $0x1, %esi
callq 0x6ee2
movl 0x20(%r14), %eax
testl %eax, %eax
jne 0x46fa
movb $0x1, 0x8(%rbx)
testl %eax, %eax
sete %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_parser.cpp
// Function: ymn::h264_parser::parse_aud(ymn::istream<0>&)
h264_parser_status_e h264_parser::parse_aud(istream_be& s)
{
    h264_parser_status_e retval = h264_parser_status_e::NAL_UNIT_CORRUPTED;

    do {
        h264::aud& aud = m_aud;
        aud.reset();

        if (!CHK_EXPR(s.read_bits(3, aud.primary_pic_type), std::cout) ||
            !CHK_STRUCT_RANGE(aud, primary_pic_type, 0U, 7U, std::cout)) {
            s.mark_corrupted();
            break;
        }

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

        aud.set_valid(true);
        retval = h264_parser_status_e::AUD_PARSED;
    } while (0);

    return retval;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movb $0x0, 0x120(%rdi)
leaq 0x124(%rdi), %r15
movq %rsi, %rdi
movl $0x3, %esi
movq %r15, %rdx
callq 0x6ee2
testb %al, %al
je 0x48bd
movl (%r15), %esi
leaq 0x13df4(%rip), %rdi     # 0x18675
movq 0x1c738(%rip), %r8      # 0x20fc0
xorl %edx, %edx
movl $0x7, %ecx
callq 0x716b
testb %al, %al
je 0x4936
movl $0x2, %eax
cmpl $0x0, 0x20(%rbx)
jne 0x493f
movb $0x1, 0x120(%r14)
movl $0x3, %eax
jmp 0x493f
movq 0x1c6fc(%rip), %r14     # 0x20fc0
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%r14,%rax)
jne 0x4936
leaq 0x14487(%rip), %rsi     # 0x18d61
movl $0x7, %edx
movq %r14, %rdi
callq 0x21d0
leaq 0x13d62(%rip), %rsi     # 0x18650
movl $0x24, %edx
movq %r14, %rdi
callq 0x21d0
leaq 0x14467(%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)
movl $0x2, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_parser.cpp
// Function: ymn::h264_parser::parse_sei(ymn::istream<0>&)
h264_parser_status_e h264_parser::parse_sei(istream_be& s)
{
    h264_parser_status_e retval = h264_parser_status_e::NAL_UNIT_CORRUPTED;

    do {
        bool status;
        uint8_t last;

        h264::sei& sei = m_sei;
        sei.reset();

        sei.payload_type = 0;
        sei.payload_size = 0;

        while ((true == (status = s.read_u8(last))) && 0xff == last)
            sei.payload_type += 255;

        if (status)
            sei.payload_type += last;
        else
            break;

        while ((true == (status = s.read_u8(last))) && 0xff == last)
            sei.payload_size += 255;

        if (status)
            sei.payload_size += last;
        else
            break;

        uint32_t i = 0;
        while ((i < sei.payload_size) && (i < sizeof(sei.payload_data)) && (true == (status = s.read_u8(sei.payload_data[i]))))
            ++i;

        if (!status)
            break;

        sei.set_valid(true);
        retval = h264_parser_status_e::SEI_PARSED;
    } while (0);

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movb $0x0, 0x87940(%rdi)
movq $0x0, 0x87944(%rdi)
leaq 0xf(%rsp), %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x7946
movb (%r15), %cl
cmpb $-0x1, %cl
sete %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x6099
leaq 0xf(%rsp), %r15
addl $0xff, 0x87944(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7946
movb 0xf(%rsp), %cl
testb %al, %al
je 0x6099
cmpb $-0x1, %cl
je 0x6077
movl $0x2, %ebp
testb %al, %al
je 0x613f
movzbl %cl, %eax
addl %eax, 0x87944(%rbx)
leaq 0xf(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x7946
movb (%r15), %cl
cmpb $-0x1, %cl
sete %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x60f6
leaq 0xf(%rsp), %r15
addl $0xff, 0x87948(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7946
movb 0xf(%rsp), %cl
testb %al, %al
je 0x60f6
cmpb $-0x1, %cl
je 0x60d4
testb %al, %al
je 0x613f
movzbl %cl, %eax
addl %eax, 0x87948(%rbx)
je 0x6133
leaq 0x8794c(%rbx), %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %rsi
movq %r14, %rdi
callq 0x7946
testb %al, %al
je 0x613f
cmpq $0xe, %r12
ja 0x6133
incq %r12
movl 0x87948(%rbx), %eax
cmpq %rax, %r12
jb 0x610f
movb $0x1, 0x87940(%rbx)
movl $0x6, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_parser.cpp
// Function: ymn::h264_parser::parse_byte_stream_nal_units()
h264_parser_status_e h264_parser::parse_byte_stream_nal_units()
{
    h264_parser_status_e status = h264_parser_status_e::NEED_BYTES;
    int num_bytes_in_nal_unit;

    if ((num_bytes_in_nal_unit = find_nal_unit()) > 0) {
        int rbsp_size;
        uint8_t* rbsp_buf;
        const uint8_t* p = m_flatbuffer.get_bookmark();

        rbsp_buf = new uint8_t[num_bytes_in_nal_unit];
        rbsp_size = h264_parser_nal_to_rbsp(rbsp_buf, num_bytes_in_nal_unit, p, num_bytes_in_nal_unit);

        if (rbsp_size > 0) {
            istream_be s(rbsp_buf, rbsp_size);

            status = parse_nal_unit(s);
        }
        else
            status = h264_parser_status_e::NAL_UNIT_CORRUPTED;

        delete [] rbsp_buf;
        m_flatbuffer.clear_bookmark();
    }

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
callq 0x3b26
testl %eax, %eax
jle 0x6eb5
movq 0xa0(%rbx), %rcx
movq 0xc0(%rbx), %r12
addq %rcx, %r12
xorl %r13d, %r13d
testq %rcx, %rcx
cmovsq %r13, %r12
movl %eax, %r15d
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
leaq -0x1(%r15), %rcx
xorl %esi, %esi
xorl %eax, %eax
xorl %edx, %edx
movl $0x2, %ebp
cmpq $0x2, %rsi
jne 0x6e3f
cmpb $0x3, (%r12,%rdx)
jb 0x6ebe
movl $0x2, %esi
jne 0x6e3f
cmpq %rcx, %rdx
jae 0x6e35
cmpb $0x3, 0x1(%r12,%rdx)
ja 0x6ebe
cmpq %rcx, %rdx
je 0x6e61
incq %rdx
xorl %esi, %esi
cmpq %rax, %r15
je 0x6eb9
movb (%r12,%rdx), %dil
incq %rsi
testb %dil, %dil
cmovneq %r13, %rsi
movb %dil, (%r14,%rax)
incq %rdx
incq %rax
cmpq %r15, %rdx
jb 0x6e0c
testl %eax, %eax
jle 0x6eb9
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rsp, %r15
movq %r14, (%r15)
movq %rax, 0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r15)
movups %xmm0, 0x38(%r15)
movups %xmm0, 0x10(%r15)
movl $0x0, 0x20(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6c1a
movl %eax, %ebp
movq 0x38(%r15), %rax
testq %rax, %rax
je 0x6ebe
leaq 0x28(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x6ebe
xorl %ebp, %ebp
jmp 0x6ed1
movl $0x2, %ebp
movq %r14, %rdi
callq 0x21f0
movq $-0x1, 0xa0(%rbx)
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/./utilities.hpp
// Function: ymn::chk_expr(char const*, bool, std::ostream&)
inline bool chk_expr(const char* expr, bool status, std::ostream& ostream)
{
    if (!status)
        if (ostream)
            ostream << "error: " << expr << " failed" << std::endl;

    return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
testl %esi, %esi
jne 0x70ab
movq %rdx, %r14
movq (%rdx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rdx,%rax)
jne 0x70ab
movq %rdi, %r15
leaq 0x11d33(%rip), %rsi     # 0x18d61
movl $0x7, %edx
movq %r14, %rdi
callq 0x21d0
testq %r15, %r15
je 0x7058
movq %r15, %rdi
callq 0x20b0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x21d0
jmp 0x7070
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x2290
leaq 0x11cf2(%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
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/./istream.hpp
// Function: ymn::istream<0>::read_exp_golomb_u(unsigned int&)
bool read_exp_golomb_u(uint32_t& value)
    {
        bool status;
        uint32_t leading_zero_bits;
        uint32_t v;

        leading_zero_bits = 0;
        while ((status = read_bits(1, v)) && (0 == v))
            leading_zero_bits++;

        if (!status) {
            m_position -= leading_zero_bits;
            return false;
        }

        if (leading_zero_bits) {
            status = read_bits(leading_zero_bits, v);
            if (!status) {
                m_position -= leading_zero_bits + 1;
                return false;
            }
            v += (1U << leading_zero_bits) - 1;
        } else
            v = 0;

        value = v;
        return true;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorl %r12d, %r12d
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x6ee2
decl %r12d
testb %al, %al
je 0x70ec
cmpl $0x0, 0xc(%rsp)
je 0x70ce
movl %r12d, %ebp
notl %ebp
testb %al, %al
je 0x711f
cmpl $-0x1, %r12d
je 0x7123
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6ee2
testb %al, %al
je 0x712c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %ebp, %ecx
shll %cl, %eax
notl %eax
addl 0xc(%rsp), %eax
jmp 0x7125
movl %ebp, %eax
jmp 0x7132
xorl %eax, %eax
movl %eax, (%r14)
movb $0x1, %al
jmp 0x715e
negl %r12d
movl %r12d, %eax
movq 0x18(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %rax
shrq $0x3, %rax
addq 0x10(%rbx), %rax
movabsq $0x1fffffffffffffff, %rdx # imm = 0x1FFFFFFFFFFFFFFF
andq %rax, %rdx
movq %rdx, 0x10(%rbx)
andl $0x7, %ecx
movq %rcx, 0x18(%rbx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/./istream.hpp
// Function: ymn::istream<0>::read_exp_golomb_s(int&)
bool read_exp_golomb_s(int32_t& value)
    {
        bool status;
        uint32_t leading_zero_bits;
        uint32_t v;

        leading_zero_bits = 0;
        while ((status = read_bits(1, v)) && (0 == v))
            leading_zero_bits++;

        if (!status) {
            m_position -= leading_zero_bits;
            return false;
        }

        if (leading_zero_bits) {
            status = read_bits(leading_zero_bits, v);
            if (!status) {
                m_position -= leading_zero_bits + 1;
                return false;
            }

            v += (1U << leading_zero_bits) - 1;
            if (v & 0x01)
                v = (v + 1) / 2;
            else
                v = -(v / 2);
        } else
            v = 0;

        value = v;
        return true;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorl %r12d, %r12d
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x6ee2
decl %r12d
testb %al, %al
je 0x7448
cmpl $0x0, 0xc(%rsp)
je 0x742a
movl %r12d, %ebp
notl %ebp
testb %al, %al
je 0x748a
cmpl $-0x1, %r12d
je 0x748e
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6ee2
testb %al, %al
je 0x7492
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
shll %cl, %edx
movl %edx, %ecx
notl %ecx
movl 0xc(%rsp), %eax
addl %eax, %ecx
testb $0x1, %cl
jne 0x74c6
shrl %ecx
negl %ecx
movl %ecx, %eax
jmp 0x74ca
movl %ebp, %eax
jmp 0x7498
xorl %eax, %eax
jmp 0x74ca
negl %r12d
movl %r12d, %eax
movq 0x18(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %rax
shrq $0x3, %rax
addq 0x10(%rbx), %rax
movabsq $0x1fffffffffffffff, %rdx # imm = 0x1FFFFFFFFFFFFFFF
andq %rax, %rdx
movq %rdx, 0x10(%rbx)
andl $0x7, %ecx
movq %rcx, 0x18(%rbx)
xorl %eax, %eax
jmp 0x74cf
subl %edx, %eax
shrl %eax
movl %eax, (%r14)
movb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/./istream.hpp
// Function: bool ymn::istream<0>::read<unsigned char>(unsigned char&)
bool read(T& value)
    {
        if (m_position.m_bit_position) {
            m_status |= ISTREAM_STATUS_IMPROPER_ALLIGMENT;
            if (m_error_function)
                m_error_function(m_position, m_position + sizeof(T) * BITS_PER_BYTE);
            return false;
        }

        const void* p = readbytes(sizeof(T));
        if (p) {
            value = *(reinterpret_cast<const T*>(p));
            return true;
        }
        else {
            m_status |= ISTREAM_STATUS_EOS_REACHED;
            if (m_error_function)
                m_error_function(m_position, m_position + sizeof(T) * BITS_PER_BYTE);
            return false;
        }
    }

// Assembly:
subq $0x18, %rsp
movq %rsi, %rcx
movq %rdi, %rax
leaq 0x10(%rdi), %rsi
movq 0x18(%rdi), %r8
testq %r8, %r8
je 0x799b
orb $0x2, 0x20(%rax)
cmpq $0x0, 0x38(%rax)
je 0x79f6
leaq 0x28(%rax), %rdi
leaq 0x8(%r8), %rcx
shrq $0x3, %rcx
addq 0x10(%rax), %rcx
movabsq $0x1fffffffffffffff, %r9 # imm = 0x1FFFFFFFFFFFFFFF
andq %rcx, %r9
andl $0x7, %r8d
leaq 0x8(%rsp), %rdx
movq %r9, (%rdx)
movq %r8, 0x8(%rdx)
jmp 0x79f3
movq 0x10(%rax), %rdi
leaq 0x1(%rdi), %rdx
cmpq 0x8(%rax), %rdx
jbe 0x79ae
movq %rdi, %rdx
jmp 0x79c4
movq (%rax), %r8
movq %rdx, 0x10(%rax)
testq %r8, %r8
je 0x79c4
movb (%r8,%rdi), %al
movb %al, (%rcx)
movb $0x1, %al
jmp 0x79f8
orb $0x1, 0x20(%rax)
cmpq $0x0, 0x38(%rax)
je 0x79f6
leaq 0x28(%rax), %rdi
incq %rdx
movabsq $0x1fffffffffffffff, %rcx # imm = 0x1FFFFFFFFFFFFFFF
andq %rdx, %rcx
leaq 0x8(%rsp), %rdx
movq %rcx, (%rdx)
movq $0x0, 0x8(%rdx)
callq *0x40(%rax)
xorl %eax, %eax
addq $0x18, %rsp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_cabac_decoder.cpp
// Function: ymn::h264_cabac_decoder::decode_bypass()
int h264_cabac_decoder::decode_bypass()
{
    uint32_t bits = 0;

    m_codIOffset <<= 1;
    m_stream.read_bits(1, bits);
    m_codIOffset |= bits;

    if (m_codIOffset < m_codIRange)
        return 0;
    else {
        m_codIOffset -= m_codIRange;
        return 1;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4(%rsp), %r14
movl $0x0, (%r14)
shll 0x4c(%rdi)
movl $0x1, %esi
movq %r14, %rdx
callq 0x6ee2
movl 0x4c(%rbx), %ecx
orl (%r14), %ecx
movl 0x48(%rbx), %edx
movl %ecx, 0x4c(%rbx)
xorl %eax, %eax
subl %edx, %ecx
jb 0x7a57
movl %ecx, 0x4c(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_cabac_decoder.cpp
// Function: ymn::h264_cabac_decoder::decode_terminate()
int h264_cabac_decoder::decode_terminate()
{
    m_codIRange -= 2;

    if (m_codIOffset < m_codIRange) {

        // renormalization process
        uint8_t shift = renormalization_shift_table[m_codIRange];
        m_codIRange <<= shift;
        m_codIOffset <<= shift;
        if (shift > 0) {
            uint32_t bits = 0;
            m_stream.read_bits(shift, bits);
            m_codIOffset |= bits;
        }

        return 0;
    }
    else
        return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl 0x48(%rdi), %eax
movl 0x4c(%rdi), %edx
addl $-0x2, %eax
movl %eax, 0x48(%rdi)
movl $0x1, %ebp
cmpl %eax, %edx
jae 0x7abc
movq %rdi, %rbx
movl %eax, %ecx
leaq 0x13647(%rip), %rsi     # 0x1b0d0
movzbl (%rcx,%rsi), %ecx
shll %cl, %eax
shll %cl, %edx
xorl %ebp, %ebp
movl %eax, 0x48(%rdi)
movl %edx, 0x4c(%rdi)
testl %ecx, %ecx
je 0x7abc
leaq 0xc(%rsp), %r14
movl $0x0, (%r14)
movq %rbx, %rdi
movl %ecx, %esi
movq %r14, %rdx
callq 0x6ee2
movl (%r14), %eax
orl %eax, 0x4c(%rbx)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_cabac_decoder.cpp
// Function: ymn::h264_cabac_decoder::decode_decision(int)
int h264_cabac_decoder::decode_decision(int ctxIdx)
{
    context_variable& state = m_context_variables[ctxIdx];
    int codIRangeLPS = range_tab_lps[(m_codIRange & 0xC0) + state.pStateIdx];
    int binVal;

    m_codIRange -= codIRangeLPS;

    if (m_codIOffset >= m_codIRange) {
        binVal = 1 - state.valMPS;
        m_codIOffset -= m_codIRange;
        m_codIRange = codIRangeLPS;
        state.pStateIdx = trans_idx_lps[state.pStateIdx];
        if (0 == state.pStateIdx)
            state.valMPS ^= 1;
    }
    else {
        binVal = state.valMPS;
        state.pStateIdx = trans_idx_mps[state.pStateIdx];
    }

    // renormalization process
    uint8_t shift = renormalization_shift_table[m_codIRange];
    m_codIRange <<= shift;
    m_codIOffset <<= shift;
    if (shift > 0) {
        uint32_t bits = 0;
        m_stream.read_bits(shift, bits);
        m_codIOffset |= bits;
    }

    return binVal;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movslq %esi, %rcx
movl 0x48(%rdi), %edi
movl 0x4c(%rbx), %r9d
movl %edi, %eax
andl $0xc0, %eax
movslq 0x50(%rbx,%rcx,8), %rsi
addl %esi, %eax
leaq 0x1145e(%rip), %rdx     # 0x18f50
movzbl (%rax,%rdx), %eax
subl %eax, %edi
movl %r9d, %edx
movl 0x54(%rbx,%rcx,8), %r8d
subl %edi, %edx
jae 0x7b1d
leaq 0x11585(%rip), %rax     # 0x19090
movzbl (%rsi,%rax), %eax
movl %eax, 0x50(%rbx,%rcx,8)
movl %r9d, %edx
movl %edi, %eax
movl %r8d, %ebp
jmp 0x7b42
movl $0x1, %ebp
subl %r8d, %ebp
leaq 0x11524(%rip), %rdi     # 0x19050
movzbl (%rsi,%rdi), %edi
movl %edi, 0x50(%rbx,%rcx,8)
cmpl $0x1, %esi
ja 0x7b42
xorl $0x1, %r8d
movl %r8d, 0x54(%rbx,%rcx,8)
movl %eax, %ecx
leaq 0x13585(%rip), %rsi     # 0x1b0d0
movzbl (%rcx,%rsi), %ecx
shll %cl, %eax
shll %cl, %edx
movl %eax, 0x48(%rbx)
movl %edx, 0x4c(%rbx)
testl %ecx, %ecx
je 0x7b7c
leaq 0xc(%rsp), %r14
movl $0x0, (%r14)
movq %rbx, %rdi
movl %ecx, %esi
movq %r14, %rdx
callq 0x6ee2
movl (%r14), %eax
orl %eax, 0x4c(%rbx)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_cabac_decoder.cpp
// Function: ymn::h264_cabac_decoder::init_context_variables(ymn::h264::slice_header const&, int)
void h264_cabac_decoder::init_context_variables(const h264::slice_header& slice_header, int32_t slice_qp)
{
    const int8_t (*table)[2];
    h264::slice_type_e slice_type = h264::to_slice_type_e(slice_header.slice_type);

    if ((slice_type == h264::slice_type_e::I) || (slice_type == h264::slice_type_e::SI))
        table = init_tab_context_variables_I;
    else
        table = init_tab_context_variables_PB[slice_header.cabac_init_idc];

    for (size_t ctxIdx = 0; ctxIdx < m_context_variables.size(); ++ctxIdx) {
        int preCtxState = (((table[ctxIdx][0]/*m*/ * slice_qp) >> 4) + table[ctxIdx][1]/*n*/);
        preCtxState = std::clamp(preCtxState, 1, 126);

        if (preCtxState <= 63) {
            m_context_variables[ctxIdx].pStateIdx = 63 - preCtxState; // 0 ... 62
            m_context_variables[ctxIdx].valMPS = 0;
        }
        else {
            m_context_variables[ctxIdx].pStateIdx = preCtxState - 64; // 0 ... 62
            m_context_variables[ctxIdx].valMPS = 1;
        }
    }
}

// Assembly:
movl 0x18(%rsi), %ecx
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
imulq %rcx, %rax
shrq $0x22, %rax
leal (%rax,%rax,4), %eax
subl %eax, %ecx
leaq 0x1152c(%rip), %rax     # 0x190d0
cmpl $0x2, %ecx
je 0x7bc2
cmpl $0x4, %ecx
je 0x7bc2
movl 0x958(%rsi), %ecx
shlq $0xb, %rcx
leaq 0x11d11(%rip), %rax     # 0x198d0
addq %rcx, %rax
xorl %ecx, %ecx
movsbl (%rax,%rcx,2), %esi
imull %edx, %esi
sarl $0x4, %esi
movsbl 0x1(%rax,%rcx,2), %r8d
addl %esi, %r8d
cmpl $0x7e, %r8d
movl $0x7e, %esi
cmovll %r8d, %esi
cmpl $0x2, %esi
jge 0x7bee
movl $0x1, %esi
movl $0x3f, %r9d
subl %esi, %r9d
addl $-0x40, %esi
xorl %r10d, %r10d
cmpl $0x40, %r8d
setge %r10b
cmovll %r9d, %esi
movl %esi, 0x50(%rdi,%rcx,8)
movl %r10d, 0x54(%rdi,%rcx,8)
incq %rcx
cmpq $0x400, %rcx            # imm = 0x400
jne 0x7bc4
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_cabac_decoder.cpp
// Function: ymn::h264_cabac_decoder::init_decoding_engine(ymn::h264::slice_data const&)
void h264_cabac_decoder::init_decoding_engine(const h264::slice_data& slice_data)
{
    if (slice_data.bit_pos > 0)
    {
        /* realign and init stream */
        m_stream = istream(slice_data.data + 1, slice_data.size - 1);
    }
    else
    {
        /* init stream (it's already aligned) */
        m_stream = istream(slice_data.data, slice_data.size);
    }

    m_codIRange = 0x1FE; // 510
    m_stream.read_bits(9, m_codIOffset);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
cmpq $0x0, 0x20(%rsi)
je 0x7c41
movq 0x10(%rsi), %rax
movq 0x18(%rsi), %rcx
incq %rax
decq %rcx
jmp 0x7c49
movq 0x10(%rsi), %rax
movq 0x18(%rsi), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
leaq 0x48(%rsp), %r14
movq %rax, -0x28(%r14)
movq %rcx, -0x20(%r14)
movups %xmm0, (%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, -0x18(%r14)
xorl %edx, %edx
movl %edx, -0x8(%r14)
movq %rax, (%rbx)
movq %rcx, 0x8(%rbx)
leaq 0x28(%rbx), %rdi
movups %xmm0, 0x10(%rbx)
movl %edx, 0x20(%rbx)
movq %r14, %rsi
callq 0x7cde
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x7ca6
movq %r14, %rdi
movq %r14, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x7cbd
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movl $0x1fe, 0x48(%rbx)      # imm = 0x1FE
leaq 0x4c(%rbx), %rdx
movq %rbx, %rdi
movl $0x9, %esi
callq 0x6ee2
addq $0x68, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_decoder.cpp
// Function: ymn::h264_decoder::feed(unsigned char const*, unsigned long)
void h264_decoder::feed(const uint8_t* data, std::size_t count)
{
    size_t n_written;

    do {
        n_written = m_parser.write(data, count);
        if (0 == n_written) {
            m_parser.reset();
            continue;
        }

        if (n_written > count) {
            std::cerr << "error: parser swallowed more data then requested (this is really bad)" << std::endl;
            m_parser.reset();
            continue;
        }

        parse();

        data += n_written;
        count -= n_written;
    } while (count > 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x80(%rdi), %r13
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x366a
testq %rax, %rax
je 0x7e28
movq %rax, %rbp
movq %r15, %r12
subq %rax, %r12
jae 0x7e55
movl $0x45, %edx
movq 0x191ff(%rip), %r12     # 0x20ff0
movq %r12, %rdi
leaq 0x10705(%rip), %rsi     # 0x18500
callq 0x21d0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
movq 0x40(%r14), %rax
xorl %ecx, %ecx
movq %rcx, 0x10(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, (%r13)
movq %rax, 0x98(%r14)
movq $-0x1, 0xa0(%r14)
movq %rcx, 0x100(%r14)
jmp 0x7e63
movq %r14, %rdi
callq 0x7e7c
addq %rbp, %rbx
movq %r12, %r15
testq %r15, %r15
jne 0x7dc7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_decoder.cpp
// Function: ymn::h264_decoder::init_chroma_qp_tables()
void h264_decoder::init_chroma_qp_tables()
{
    const int depth = m_active_sps->bit_depth_luma_minus8;
    const int max_qp = 51 + 6 * depth;
    int offset;

#define QP(qp, depth) ((qp) + 6 * (depth))
#define CHROMA_QP_TABLE_END(d)                                        \
    QP(0,  d), QP(1,  d), QP(2,  d), QP(3,  d), QP(4,  d), QP(5,  d), \
    QP(6,  d), QP(7,  d), QP(8,  d), QP(9,  d), QP(10, d), QP(11, d), \
    QP(12, d), QP(13, d), QP(14, d), QP(15, d), QP(16, d), QP(17, d), \
    QP(18, d), QP(19, d), QP(20, d), QP(21, d), QP(22, d), QP(23, d), \
    QP(24, d), QP(25, d), QP(26, d), QP(27, d), QP(28, d), QP(29, d), \
    QP(29, d), QP(30, d), QP(31, d), QP(32, d), QP(32, d), QP(33, d), \
    QP(34, d), QP(34, d), QP(35, d), QP(35, d), QP(36, d), QP(36, d), \
    QP(37, d), QP(37, d), QP(37, d), QP(38, d), QP(38, d), QP(38, d), \
    QP(39, d), QP(39, d), QP(39, d), QP(39, d)

    /* One chroma qp table for each supported bit depth (8, 9, 10). */
    static const uint8_t chroma_qp[3][H264_QP_MAX + 1] =
    {
        {CHROMA_QP_TABLE_END(0)},
        {0, 1, 2, 3, 4, 5, CHROMA_QP_TABLE_END(1)},
        {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, CHROMA_QP_TABLE_END(2)}
    };

    offset = m_active_pps->chroma_qp_index_offset;
    for (int q = 0; q < max_qp + 1; ++q)
        m_chroma_qp_table[0][q] = chroma_qp[depth][std::clamp(q + offset, 0, max_qp)];

    offset = m_active_pps->second_chroma_qp_index_offset;
    for (int q = 0; q < max_qp + 1; ++q)
        m_chroma_qp_table[1][q] = chroma_qp[depth][std::clamp(q + offset, 0, max_qp)];

#undef CHROMA_QP_TABLE_END
#undef QP
}

// Assembly:
pushq %rbx
movq 0x88358(%rdi), %rax
movslq 0x18(%rax), %rdx
cmpq $-0x8, %rdx
jl 0x828b
movq 0x88360(%rdi), %rsi
leal (%rdx,%rdx,2), %eax
leal 0x33(,%rax,2), %eax
movl 0x440(%rsi), %ecx
movslq %ecx, %r8
xorl %r9d, %r9d
testl %eax, %eax
movl $0x0, %r10d
cmovgl %eax, %r10d
incl %r10d
movq %rdx, %r11
shlq $0x6, %r11
leaq 0x1315a(%rip), %rcx     # 0x1b360
addq %r11, %rcx
leal (%r8,%r9), %r11d
cmpl %r11d, %eax
cmovll %eax, %r11d
movq %r8, %rbx
addq %r9, %rbx
movslq %r11d, %r11
movl $0x0, %ebx
cmovnsq %r11, %rbx
movb (%rbx,%rcx), %r11b
movb %r11b, 0xa63d0(%rdi,%r9)
incq %r9
cmpq %r9, %r10
jne 0x8209
cmpl $-0x8, %edx
jl 0x828b
movl 0x708(%rsi), %edx
movslq %edx, %rdx
xorl %esi, %esi
testl %eax, %eax
movl $0x0, %r8d
cmovgl %eax, %r8d
incl %r8d
leal (%rdx,%rsi), %r9d
cmpl %r9d, %eax
cmovll %eax, %r9d
movq %rdx, %r10
addq %rsi, %r10
movslq %r9d, %r9
movl $0x0, %r10d
cmovnsq %r9, %r10
movb (%r10,%rcx), %r9b
movb %r9b, 0xa6410(%rdi,%rsi)
incq %rsi
cmpq %rsi, %r8
jne 0x8259
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/h264_decoder.cpp
// Function: ymn::h264_decoder::init_dequantisation_tables()
void h264_decoder::init_dequantisation_tables()
{
    init_dequant4x4_coeff_table();
    if (m_active_pps->transform_8x8_mode_flag)
        init_dequant8x8_coeff_table();

    if (m_active_sps->qpprime_y_zero_transform_bypass_flag) {
        for (int i = 0; i < SL_4x4_NUM; ++i)
            for (int x = 0; x < 16; ++x)
                (*m_dequant4x4_coeff[i])[0][x] = 1 << 6;

        if (m_active_pps->transform_8x8_mode_flag)
            for (int i = 0; i < SL_8x8_NUM; ++i)
                for (int x = 0; x < 64; ++x)
                    (*m_dequant8x8_coeff[i])[0][x] = 1 << 6;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x828e
movq 0x88360(%rbx), %rax
cmpl $0x0, 0x450(%rax)
je 0x85cd
movq %rbx, %rdi
callq 0x83e8
movq 0x88358(%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x8637
xorl %eax, %eax
movaps 0x12d3d(%rip), %xmm0    # 0x1b320
movq 0xa6370(%rbx,%rax,8), %rcx
xorl %edx, %edx
movups %xmm0, (%rcx,%rdx,4)
addq $0x4, %rdx
cmpq $0x10, %rdx
jne 0x85ed
incq %rax
cmpq $0x6, %rax
jne 0x85e3
movq 0x88360(%rbx), %rax
cmpl $0x0, 0x450(%rax)
je 0x8637
xorl %eax, %eax
movq 0xa63a0(%rbx,%rax,8), %rcx
xorl %edx, %edx
movups %xmm0, (%rcx,%rdx,4)
addq $0x4, %rdx
cmpq $0x40, %rdx
jne 0x8620
incq %rax
cmpq $0x6, %rax
jne 0x8616
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/./aud.hpp
// Function: ymn::h264::aud::to_string[abi:cxx11]() const
inline std::string aud::to_string() const
{
    std::ostringstream stream;

    stream << "aud (access unit delimiter):" << std::endl;
    stream << P1_INFO(primary_pic_type, primary_pic_type_to_string(primary_pic_type));

    return stream.str();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %r15
movq %r15, %rdi
callq 0x2220
leaq 0x12dd4(%rip), %rsi     # 0x1b62c
movl $0x1c, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
movq (%r15), %rax
movq -0x18(%rax), %rax
movq $0x2, 0x10(%rsp,%rax)
leaq 0x14404(%rip), %rsi     # 0x1cca7
movq %r15, %rdi
xorl %edx, %edx
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rcx
movq $0x2e, 0x10(%rsp,%rcx)
movq -0x18(%rax), %rax
movl $0xffffff4f, %ecx       # imm = 0xFFFFFF4F
andl 0x18(%rsp,%rax), %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rsp,%rax)
leaq 0xfda1(%rip), %rsi      # 0x18679
movl $0x10, %edx
movq %r15, %rdi
callq 0x21d0
leaq 0xf7bb(%rip), %r12      # 0x180a7
movl $0x2, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x21d0
leaq 0xf721(%rip), %rsi      # 0x18024
movl $0x2, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x18(%rsp,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rsp,%rax)
movl 0xc(%r14), %esi
movq %r15, %rdi
callq 0x2100
movq %rax, %r15
leaq 0xf6ec(%rip), %rsi      # 0x18027
movl $0x2, %edx
movq %rax, %rdi
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x18(%r15,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%r15,%rax)
movl 0xc(%r14), %esi
movq %r15, %rdi
callq 0x2100
movq %rax, %r15
leaq 0x10101(%rip), %rsi     # 0x18a76
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movl $0x2, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x21d0
movl 0xc(%r14), %eax
cmpq $0x7, %rax
ja 0x89ac
leaq 0x12ac1(%rip), %rcx     # 0x1b464
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x89b3
leaq 0x13d05(%rip), %r14     # 0x1c6b8
movq %r14, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2260
movq 0x185b4(%rip), %rsi     # 0x20fb8
movq %rsp, %rdi
callq 0x20d0
leaq 0x70(%rsp), %rdi
callq 0x20a0
movq %rbx, %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture.cpp
// Function: ymn::h264::picture::picture(ymn::h264_decoder const&, ymn::h264::slice_header const&)
picture::picture(const h264_decoder& decoder, const h264::slice_header& sh) :
    m_decoder{decoder},
    m_picture_structure{},
    m_context_variables{},
    m_mbs{nullptr}
{
    init_coxtext_variables(sh);
    m_mbs = new h264::mb[m_decoder.m_dimensions.mb_num];
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
leaq 0xaddf(%rip), %rax      # 0x20d20
movq %rax, (%rdi)
movq %rsi, 0x8(%rdi)
movl $0x0, 0x10(%rdi)
addq $0x18, %rdi
movl $0xda8, %edx            # imm = 0xDA8
xorl %esi, %esi
callq 0x20e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x15f9c
movq 0x8(%rbx), %rax
movslq 0x88348(%rax), %rax
movl $0xb0, %ecx
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x2030
movq %rax, 0xdb8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture.cpp
// Function: ymn::h264::picture::advance_mb_pos()
mb* picture::advance_mb_pos()
{
    if (m_context_variables.mb_aff_frame) {
        if ((m_context_variables.mb_y & 1) == 0)
            m_context_variables.mb_y++; /* move to bottom macroblock of a macroblock pair */
        else {
            m_context_variables.mb_y--; /* move to top macroblock of a macroblock pair */
            m_context_variables.mb_x++; /* move to right macroblock pair */
            if (m_context_variables.mb_x >= m_decoder.m_dimensions.mb_width) {
                m_context_variables.mb_x = 0;
                m_context_variables.mb_y +=2;
            }
        }
    }
    else {
        m_context_variables.mb_x++; /* move to right macroblock */
        if (m_context_variables.mb_x >= m_decoder.m_dimensions.mb_width) {
            m_context_variables.mb_x = 0;
            m_context_variables.mb_y++;
            if (m_picture_structure != picture_structure_e::frame)
                m_context_variables.mb_y++;
        }
    }

    update_mb_pos();

    return m_context_variables.curr_mb;
}

// Assembly:
cmpb $0x1, 0x18(%rdi)
jne 0x1615d
movl 0x20(%rdi), %r8d
testb $0x1, %r8b
jne 0x16178
orl $0x1, %r8d
movl %r8d, 0x20(%rdi)
movl 0x1c(%rdi), %edx
movq 0x8(%rdi), %rcx
movl 0x88340(%rcx), %eax
jmp 0x161c9
movl 0x1c(%rdi), %edx
incl %edx
movl %edx, 0x1c(%rdi)
movq 0x8(%rdi), %rcx
movl 0x88340(%rcx), %eax
cmpl %eax, %edx
jge 0x161a7
movl 0x20(%rdi), %esi
jmp 0x161cc
leal -0x1(%r8), %esi
movl %esi, 0x20(%rdi)
movl 0x1c(%rdi), %edx
incl %edx
movl %edx, 0x1c(%rdi)
movq 0x8(%rdi), %rcx
movl 0x88340(%rcx), %eax
cmpl %eax, %edx
jl 0x161cc
movl $0x0, 0x1c(%rdi)
incl %r8d
movl %r8d, 0x20(%rdi)
xorl %edx, %edx
jmp 0x161c9
movl $0x0, 0x1c(%rdi)
movl 0x20(%rdi), %r8d
leal 0x1(%r8), %esi
movl %esi, 0x20(%rdi)
xorl %edx, %edx
cmpl $0x0, 0x10(%rdi)
je 0x161cc
addl $0x2, %r8d
movl %r8d, 0x20(%rdi)
movl %r8d, %esi
imull %esi, %eax
addl %edx, %eax
movl %eax, 0x24(%rdi)
movslq %eax, %rdx
imulq $0xb0, %rdx, %rsi
addq 0xdb8(%rdi), %rsi
xorl %eax, %eax
cmpl 0x88348(%rcx), %edx
cmovlq %rsi, %rax
movq %rax, 0x28(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::decode(ymn::h264::slice_header const&, ymn::h264::slice_data const&)
void picture_cabac::decode(const h264::slice_header& sh, const h264::slice_data& sd)
{
    mb* curr_mb;

    int slice_qp = std::clamp(
        m_context_variables.QPy - 6 * static_cast<int>(m_decoder.m_active_sps->bit_depth_luma_minus8), 0, 51);

    m_cabac_decoder.init_context_variables(sh, slice_qp);
    m_cabac_decoder.init_decoding_engine(sd);

    for (curr_mb = m_context_variables.curr_mb; curr_mb != nullptr; curr_mb = advance_mb_pos()) {

        curr_mb->x = m_context_variables.mb_x;
        curr_mb->y = m_context_variables.mb_y;
        curr_mb->pos = m_context_variables.mb_pos;
        curr_mb->slice_num = 0;

        calculate_neighbours_part1();

        if ((sh.slice_type != h264::slice_type_e::I) && (sh.slice_type != h264::slice_type_e::SI)) {
            bool is_skipped = true; /* TODO: check for skipped macroblocks */
            if (is_skipped)
                continue;
        }

        if ((m_context_variables.mb_aff_frame) && ((m_context_variables.mb_y & 1) == 0))
            m_context_variables.mb_field_decoding_flag = decode_mb_field_decoding_flag();

        calculate_neighbours_part2();

        decode_mb(sh); /* macroblock_layer */

        //std::cout << mb->to_string();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movl 0x34(%rdi), %eax
movq 0x8(%rdi), %rcx
movq 0x88358(%rcx), %rcx
movl 0x18(%rcx), %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cmpl $0x33, %eax
movl $0x33, %ecx
cmovll %eax, %ecx
xorl %edx, %edx
testl %ecx, %ecx
cmovgl %ecx, %edx
leaq 0xdc0(%rdi), %r12
movq %r12, %rdi
callq 0x7b88
movq %r12, %rdi
movq %r15, %rsi
callq 0x7c20
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x16769
movl $0xcccccccd, %r15d      # imm = 0xCCCCCCCD
movq 0x1c(%r14), %rcx
movq %rcx, (%rax)
movl 0x24(%r14), %ecx
movl %ecx, 0x8(%rax)
movl $0x0, 0xc(%rax)
movq %r14, %rdi
callq 0x161f6
movl 0x18(%rbx), %eax
movq %rax, %rcx
imulq %r15, %rcx
shrq $0x22, %rcx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cmpl $0x4, %eax
je 0x1672c
cmpl $0x2, %eax
jne 0x1675c
cmpb $0x1, 0x18(%r14)
jne 0x16749
testb $0x1, 0x20(%r14)
jne 0x16749
movq %r14, %rdi
callq 0x16776
testl %eax, %eax
setne 0x19(%r14)
movq %r14, %rdi
callq 0x163c6
movq %r14, %rdi
movq %rbx, %rsi
callq 0x167ba
movq %r14, %rdi
callq 0x16136
testq %rax, %rax
jne 0x166f2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::decode_mb_field_decoding_flag()
int picture_cabac::decode_mb_field_decoding_flag()
{
    const int ctxIdxOffset = 70;
    int ctxIdxInc = 0;
    mb* curr_mb = m_context_variables.curr_mb;

    ctxIdxInc += (curr_mb->A != nullptr) && (curr_mb->A->type & MB_TYPE_INTERLACED);
    ctxIdxInc += (curr_mb->B != nullptr) && (curr_mb->B->type & MB_TYPE_INTERLACED);

    return m_cabac_decoder.decode_decision(ctxIdxOffset + ctxIdxInc);
}

// Assembly:
movq 0x28(%rdi), %rax
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0x16791
movl 0x10(%rcx), %esi
shrl $0x8, %esi
andl $0x1, %esi
orl $0x46, %esi
jmp 0x16796
movl $0x46, %esi
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x167aa
movl 0x10(%rax), %eax
shrl $0x8, %eax
andl $0x1, %eax
jmp 0x167ac
xorl %eax, %eax
addl %eax, %esi
addq $0xdc0, %rdi            # imm = 0xDC0
jmp 0x7ac8
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::get_intra4x4_pred_mode(int)
int picture_cabac::get_intra4x4_pred_mode(int pred_mode)
{
    if (decode_prev_intra4x4_pred_mode_flag())
        return pred_mode;

    int mode = decode_rem_intra4x4_pred_mode();

    return mode + (mode >= pred_mode);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
addq $0xdc0, %rdi            # imm = 0xDC0
movl $0x44, %esi
callq 0x7ac8
testl %eax, %eax
jne 0x16ce3
movq %r14, %rdi
callq 0x16d00
xorl %ecx, %ecx
cmpl %ebx, %eax
setge %cl
addl %eax, %ecx
movl %ecx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::decode_rem_intra4x4_pred_mode()
int picture_cabac::decode_rem_intra4x4_pred_mode()
{
    const int ctxIdxOffset = 69;
    int mode = 0;
    int ctxIdxInc = 0;

    mode += 1 * m_cabac_decoder.decode_decision(ctxIdxOffset + ctxIdxInc);
    mode += 2 * m_cabac_decoder.decode_decision(ctxIdxOffset + ctxIdxInc);
    mode += 4 * m_cabac_decoder.decode_decision(ctxIdxOffset + ctxIdxInc);

    return mode;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
addq $0xdc0, %rbx            # imm = 0xDC0
movq %rbx, %rdi
movl $0x45, %esi
callq 0x7ac8
movl %eax, %r14d
movq %rbx, %rdi
movl $0x45, %esi
callq 0x7ac8
leal (%r14,%rax,2), %r14d
movq %rbx, %rdi
movl $0x45, %esi
callq 0x7ac8
leal (%r14,%rax,4), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::get_intra8x8_pred_mode(int)
int picture_cabac::get_intra8x8_pred_mode(int pred_mode)
{
    if (decode_prev_intra8x8_pred_mode_flag())
        return pred_mode;

    int mode = decode_rem_intra8x8_pred_mode();

    return mode + (mode >= pred_mode);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
addq $0xdc0, %rdi            # imm = 0xDC0
movl $0x44, %esi
callq 0x7ac8
testl %eax, %eax
jne 0x16d79
movq %r14, %rdi
callq 0x16d96
xorl %ecx, %ecx
cmpl %ebx, %eax
setge %cl
addl %eax, %ecx
movl %ecx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::non_zero_count_save()
void picture_cabac::non_zero_count_save()
{
    mb* curr_mb = m_context_variables.curr_mb;
    uint8_t* nzc = curr_mb->non_zero_count;

    const mb_cache& nzc_cache_y  = m_context_variables.non_zero_count_cache[CC_Y];
    const mb_cache& nzc_cache_cb = m_context_variables.non_zero_count_cache[CC_Cb];
    const mb_cache& nzc_cache_cr = m_context_variables.non_zero_count_cache[CC_Cr];

    nzc[MB_NZC_DC_BLOCK_IDX(CC_Y)] = nzc_cache_y[0];

    std::memcpy(&nzc[0 * 4], &nzc_cache_y[1 * 8 + 4], 4);
    std::memcpy(&nzc[1 * 4], &nzc_cache_y[2 * 8 + 4], 4);
    std::memcpy(&nzc[2 * 4], &nzc_cache_y[3 * 8 + 4], 4);
    std::memcpy(&nzc[3 * 4], &nzc_cache_y[4 * 8 + 4], 4);

    if (m_context_variables.chroma_array_type == 0)
        return;

    nzc[MB_NZC_DC_BLOCK_IDX(CC_Cb)] = nzc_cache_cb[0];
    nzc[MB_NZC_DC_BLOCK_IDX(CC_Cr)] = nzc_cache_cr[0];

    std::memcpy(&nzc[4 * 4], &nzc_cache_cb[1 * 8 + 4], 4);
    std::memcpy(&nzc[5 * 4], &nzc_cache_cb[2 * 8 + 4], 4);
    std::memcpy(&nzc[8 * 4], &nzc_cache_cr[1 * 8 + 4], 4);
    std::memcpy(&nzc[9 * 4], &nzc_cache_cr[2 * 8 + 4], 4);

    if (m_context_variables.chroma_array_type < 3)
        return;

    std::memcpy(&nzc[ 6 * 4], &nzc_cache_cb[3 * 8 + 4], 4);
    std::memcpy(&nzc[ 7 * 4], &nzc_cache_cb[4 * 8 + 4], 4);
    std::memcpy(&nzc[10 * 4], &nzc_cache_cr[3 * 8 + 4], 4);
    std::memcpy(&nzc[11 * 4], &nzc_cache_cr[4 * 8 + 4], 4);
}

// Assembly:
movq 0x28(%rdi), %rax
movb 0x80(%rdi), %cl
movb %cl, 0xa8(%rax)
movl 0x8c(%rdi), %ecx
movl %ecx, 0x78(%rax)
movl 0x94(%rdi), %ecx
movl %ecx, 0x7c(%rax)
movl 0x9c(%rdi), %ecx
movl %ecx, 0x80(%rax)
movl 0xa4(%rdi), %ecx
movl %ecx, 0x84(%rax)
cmpl $0x0, 0x40(%rdi)
je 0x170ee
movb 0xa8(%rdi), %cl
movb %cl, 0xa9(%rax)
movb 0xd0(%rdi), %cl
movb %cl, 0xaa(%rax)
movl 0xb4(%rdi), %ecx
movl %ecx, 0x88(%rax)
movl 0xbc(%rdi), %ecx
movl %ecx, 0x8c(%rax)
movl 0xdc(%rdi), %ecx
movl %ecx, 0x98(%rax)
movl 0xe4(%rdi), %ecx
movl %ecx, 0x9c(%rax)
cmpl $0x3, 0x40(%rdi)
jl 0x170ee
movl 0xc4(%rdi), %ecx
movl %ecx, 0x90(%rax)
movl 0xcc(%rdi), %ecx
movl %ecx, 0x94(%rax)
movl 0xec(%rdi), %ecx
movl %ecx, 0xa0(%rax)
movl 0xf4(%rdi), %ecx
movl %ecx, 0xa4(%rax)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::decode_mb_type_si_slice()
int picture_cabac::decode_mb_type_si_slice()
{
    const int ctxIdxOffset = 0;
    int ctxIdxInc = 0;
    mb* curr_mb = m_context_variables.curr_mb;

    ctxIdxInc += ((curr_mb->left != nullptr) && ((curr_mb->left->type & MB_TYPE_SWITCHING) == 0));
    ctxIdxInc += ((curr_mb->top != nullptr) && ((curr_mb->top->type & MB_TYPE_SWITCHING) == 0));

    if (m_cabac_decoder.decode_decision(ctxIdxOffset + ctxIdxInc) == 0)
        return 0; /* SI 4x4 */

    return 1 + decode_mb_type_i_slice();
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x28(%rdi), %rcx
movq 0x38(%rcx), %rdx
xorl %esi, %esi
movl $0x0, %eax
testq %rdx, %rdx
je 0x17111
xorl %eax, %eax
testb $0x10, 0x12(%rdx)
sete %al
movq 0x50(%rcx), %rcx
testq %rcx, %rcx
je 0x17124
xorl %esi, %esi
testb $0x10, 0x12(%rcx)
sete %sil
addl %eax, %esi
leaq 0xdc0(%rbx), %rdi
callq 0x7ac8
testl %eax, %eax
je 0x17142
movq %rbx, %rdi
callq 0x17146
incl %eax
jmp 0x17144
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/lukasz-wiecaszek[P]h264iframedecoder/picture_cabac.cpp
// Function: ymn::h264::picture_cabac::decode_mb_type_i_slice()
int picture_cabac::decode_mb_type_i_slice()
{
    const int ctxIdxOffset = 3;
    int ctxIdxInc = 0;
    mb* curr_mb = m_context_variables.curr_mb;

    ctxIdxInc += ((curr_mb->left != nullptr) && ((curr_mb->left->type & MB_TYPE_INTRA_NxN) == 0));
    ctxIdxInc += ((curr_mb->top != nullptr) && ((curr_mb->top->type & MB_TYPE_INTRA_NxN) == 0));

    if (m_cabac_decoder.decode_decision(ctxIdxOffset + ctxIdxInc) == 0)
        return 0; /* I 4x4 */

    if (m_cabac_decoder.decode_terminate() == 1)
        return 25; /* PCM */

    int mb_type = 1; /* I16x16 */

    mb_type += 12 * m_cabac_decoder.decode_decision(ctxIdxOffset + 3); /* cbp_luma */
    if (m_cabac_decoder.decode_decision(ctxIdxOffset + 4)) /* cbp_chroma */
        mb_type += 4 + 4 * m_cabac_decoder.decode_decision(ctxIdxOffset + 5);

    mb_type += 2 * m_cabac_decoder.decode_decision(ctxIdxOffset + 6);
    mb_type += 1 * m_cabac_decoder.decode_decision(ctxIdxOffset + 7);

    return mb_type;

}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x28(%rdi), %rax
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x1716a
movb 0x10(%rcx), %cl
andb $0x3, %cl
xorl %esi, %esi
cmpb $0x1, %cl
adcl $0x3, %esi
jmp 0x1716f
movl $0x3, %esi
movq 0x50(%rax), %rcx
xorl %ebp, %ebp
movl $0x0, %eax
testq %rcx, %rcx
je 0x17188
xorl %eax, %eax
testb $0x3, 0x10(%rcx)
sete %al
addl %eax, %esi
addq $0xdc0, %rbx            # imm = 0xDC0
movq %rbx, %rdi
callq 0x7ac8
testl %eax, %eax
je 0x17219
movq %rbx, %rdi
callq 0x7a60
movl $0x19, %ebp
cmpl $0x1, %eax
je 0x17219
movq %rbx, %rdi
movl $0x6, %esi
callq 0x7ac8
movl %eax, %r14d
shll $0x2, %r14d
movq %rbx, %rdi
movl $0x7, %esi
callq 0x7ac8
testl %eax, %eax
je 0x171ef
leal (%r14,%r14,2), %r14d
movq %rbx, %rdi
movl $0x8, %esi
callq 0x7ac8
leal (%r14,%rax,4), %r14d
addl $0x5, %r14d
jmp 0x171f6
leal (%r14,%r14,2), %r14d
incl %r14d
movq %rbx, %rdi
movl $0x9, %esi
callq 0x7ac8
leal (%r14,%rax,2), %r14d
movq %rbx, %rdi
movl $0xa, %esi
callq 0x7ac8
movl %eax, %ebp
addl %r14d, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq