// File: /workspace/github_c_makefile_star2_O1/akumrao[P]videoAnalyzer/decoder/macroblock.c
// Function: x264_macroblock_decode(x264_t*, x264_macroblock_t*)
int x264_macroblock_decode(x264_t *h, x264_macroblock_t *mb) {LOG_CALL;
    x264_mb_context_t *ctx = mb->context;

    int i_qscale;
    int ch;
    int i;

    if (!IS_INTRA(mb->i_type))
    {
        /* Motion compensation */
        x264_mb_mc(h, mb);
    }

    /* luma */
    i_qscale = mb->i_qp;
    if (mb->i_type == I_16x16)
    {
        int i_mode = x264_mb_pred_mode16x16_valid(mb, mb->i_intra16x16_pred_mode);
        int16_t luma[16][4][4];
        int16_t dct4x4[16 + 1][4][4];


        /* do the right prediction */
        h->predict_16x16[i_mode](ctx->p_fdec[0], ctx->i_fdec[0]);

        /* get dc coeffs */
        unscan_zigzag_4x4full(dct4x4[0], mb->luma16x16_dc);
        h->dctf.idct4x4dc(dct4x4[0], dct4x4[0]);
        x264_mb_dequant_4x4_dc(dct4x4[0], i_qscale);

        /* decode the 16x16 macroblock */
        for (i = 0; i < 16; i++)
        {
            unscan_zigzag_4x4(dct4x4[1 + i], mb->block[i].residual_ac);
            x264_mb_dequant_4x4(dct4x4[1 + i], i_qscale);

            /* copy dc coeff */
            dct4x4[1 + i][0][0] = dct4x4[0][block_idx_y[i]][block_idx_x[i]];

            h->dctf.idct4x4(luma[i], dct4x4[i + 1]);
        }
        /* put pixels to fdec */
        h->pixf.add16x16(ctx->p_fdec[0], ctx->i_fdec[0], luma);
        dumpByte(ctx->p_fdec[0], 16,16);
       // printLong(ctx->p_fdec[0], 16,16);
    } else if (mb->i_type == I_4x4)
    {
        for (i = 0; i < 16; i++)
        {
            int16_t luma[4][4];
            int16_t dct4x4[4][4];

            uint8_t *p_dst_by;
            int i_mode;
            int b_emu;

            /* Do the right prediction */
            p_dst_by = ctx->p_fdec[0] + 4 * block_idx_x[i] + 4 * block_idx_y[i] * ctx->i_fdec[0];
            i_mode = x264_mb_pred_mode4x4_valid(mb, i, mb->block[i].i_intra4x4_pred_mode, &b_emu);
            if (b_emu)
            {
                fprintf(stderr, "mmmh b_emu\n");
                memset(&p_dst_by[4], p_dst_by[3], 4);
            }
            h->predict_4x4[i_mode](p_dst_by, ctx->i_fdec[0]);

            if (mb->block[i].i_non_zero_count > 0)
            {
                /* decode one 4x4 block */
                unscan_zigzag_4x4full(dct4x4, mb->block[i].luma4x4);

                x264_mb_dequant_4x4(dct4x4, i_qscale);

                h->dctf.idct4x4(luma, dct4x4);

                h->pixf.add4x4(p_dst_by, ctx->i_fdec[0], luma);
            }
        }
    } else /* Inter mb */
    {
        for (i = 0; i < 16; i++)
        {
            uint8_t *p_dst_by;
            int16_t luma[4][4];
            int16_t dct4x4[4][4];

            if (mb->block[i].i_non_zero_count > 0)
            {
                unscan_zigzag_4x4full(dct4x4, mb->block[i].luma4x4);
                x264_mb_dequant_4x4(dct4x4, i_qscale);

                h->dctf.idct4x4(luma, dct4x4);

                p_dst_by = ctx->p_fdec[0] + 4 * block_idx_x[i] + 4 * block_idx_y[i] * ctx->i_fdec[0];
                h->pixf.add4x4(p_dst_by, ctx->i_fdec[0], luma);
            }
        }
    }

    /* chroma */
    i_qscale = i_chroma_qp_table[x264_clip3(i_qscale + h->pps->i_chroma_qp_index_offset, 0, 51)];
    if (IS_INTRA(mb->i_type))
    {
        int i_mode = x264_mb_pred_mode8x8_valid(mb, mb->i_chroma_pred_mode);
        /* do the right prediction */
        h->predict_8x8[i_mode](ctx->p_fdec[1], ctx->i_fdec[1]);
        h->predict_8x8[i_mode](ctx->p_fdec[2], ctx->i_fdec[2]);
    }

    if (mb->i_cbp_chroma != 0)
    {
        for (ch = 0; ch < 2; ch++)
        {
            int16_t chroma[4][4][4];
            int16_t dct2x2[2][2];
            int16_t dct4x4[4][4][4];

            /* get dc chroma */
            unscan_zigzag_2x2_dc(dct2x2, mb->chroma_dc[ch]);
            h->dctf.idct2x2dc(dct2x2, dct2x2);
            x264_mb_dequant_2x2_dc(dct2x2, i_qscale);

            for (i = 0; i < 4; i++)
            {
                unscan_zigzag_4x4(dct4x4[i], mb->block[16 + i + ch * 4].residual_ac);
                x264_mb_dequant_4x4(dct4x4[i], i_qscale);

                /* copy dc coeff */
                dct4x4[i][0][0] = dct2x2[block_idx_y[i]][block_idx_x[i]];

                h->dctf.idct4x4(chroma[i], dct4x4[i]);
            }
            h->pixf.add8x8(ctx->p_fdec[1 + ch], ctx->i_fdec[1 + ch], chroma);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %rsi, %r12
movq %rdi, %r14
leaq 0x15718(%rip), %rdi     # 0x251b4
leaq 0x187b9(%rip), %rsi     # 0x2825c
leaq 0x18904(%rip), %rdx     # 0x283ae
xorl %eax, %eax
callq 0x4c22
movq 0x10(%r12), %rax
movq %rax, -0x50(%rbp)
cmpl $0x2, 0x18(%r12)
jb 0xfacd
movq %r14, %rdi
movq %r12, %rsi
callq 0x7415
movl 0x2b0(%r12), %eax
movl %eax, -0x34(%rbp)
movl 0x18(%r12), %eax
cmpl $0x1, %eax
movq %r14, -0x48(%rbp)
movq %r12, -0x58(%rbp)
je 0xfd2c
testl %eax, %eax
jne 0xfef0
leaq 0x324(%r12), %rax
movq %rax, -0x68(%rbp)
leaq 0x368(%r12), %r15
leaq 0x185df(%rip), %r13     # 0x280f0
xorl %r12d, %r12d
leaq 0x181d5(%rip), %rax     # 0x27cf0
movzbl (%r12,%rax), %ecx
shlq $0x2, %rcx
movq -0x50(%rbp), %rax
addq 0x40(%rax), %rcx
movq %rcx, -0x30(%rbp)
leaq 0x181a9(%rip), %rcx     # 0x27ce0
movzbl (%r12,%rcx), %r14d
movslq 0x58(%rax), %rax
movq %rax, -0x40(%rbp)
movq %r12, %rax
shlq $0x7, %rax
leaq (%rax,%r12,4), %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x70(%rbp)
movl (%rax,%rcx), %ebx
leaq 0x15653(%rip), %rdi     # 0x251b4
leaq 0x186f4(%rip), %rsi     # 0x2825c
leaq 0x18987(%rip), %rdx     # 0x284f6
xorl %eax, %eax
callq 0x4c22
movq -0x58(%rbp), %rax
movl 0x8(%rax), %eax
notl %eax
leaq 0x185aa(%rip), %rcx     # 0x28130
andl (%rcx,%r12,4), %eax
movl %eax, %ecx
andl $0x2, %ecx
sete %sil
testb $0x14, %al
sete %dl
cmpl $0x2, %ebx
jne 0xfbbb
movb $0x1, %r8b
testb $0x3, %al
je 0xfbf2
cmpl $0x1, %ecx
movl $0xa, %ebx
sbbl $-0x1, %ebx
testb $0x1, %al
movl $0x9, %eax
cmovel %eax, %ebx
jmp 0xfc01
movl %eax, %edi
andl $0x1, %edi
movl %ebx, %r8d
xorl $0x1, %r8d
orl %edi, %r8d
movb $0x1, %r8b
je 0xfc01
movl %ecx, %edi
orl %ebx, %edi
je 0xfc01
orb %dl, %sil
movl %ebx, %edi
andl $-0x5, %edi
cmpl $0x3, %edi
sete %dil
testb %sil, %dil
je 0xfbf9
shrl %ecx
orb %dl, %cl
movl %ecx, %r8d
jmp 0xfc01
movl $0x2, %ebx
jmp 0xfc01
testb $0x3, %al
jne 0xfcf8
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
shll $0x2, %r14d
imulq %rax, %r14
addq %r14, %rdi
testb %r8b, %r8b
movq %rdi, -0x30(%rbp)
je 0xfcea
movq -0x70(%rbp), %r14
addq -0x68(%rbp), %r14
movslq %ebx, %rax
movq -0x50(%rbp), %rcx
movl 0x58(%rcx), %esi
movq -0x48(%rbp), %rcx
callq *0x10f248(%rcx,%rax,8)
cmpl $0x0, 0x4(%r14)
jle 0xfcd1
leaq 0x15564(%rip), %rdi     # 0x251b4
leaq 0x18605(%rip), %rsi     # 0x2825c
leaq 0x18870(%rip), %rdx     # 0x284ce
xorl %eax, %eax
callq 0x4c22
xorl %eax, %eax
leaq 0x18442(%rip), %rdi     # 0x280b0
movzwl (%r15,%rax), %ecx
movslq (%rax,%rdi), %rdx
movslq (%rax,%r13), %rsi
leaq -0x490(,%rdx,8), %rdx
addq %rbp, %rdx
movw %cx, (%rdx,%rsi,2)
addq $0x4, %rax
cmpq $0x40, %rax
jne 0xfc6e
leaq -0x490(%rbp), %rbx
movq %rbx, %rdi
movl -0x34(%rbp), %esi
callq 0x6a50
leaq -0x290(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq -0x48(%rbp), %rbx
callq *0x10f3a8(%rbx)
movq -0x50(%rbp), %rax
movl 0x58(%rax), %esi
movq -0x30(%rbp), %rdi
movq %r14, %rdx
callq *0x10f368(%rbx)
incq %r12
addq $0x84, %r15
cmpq $0x10, %r12
jne 0xfb14
jmp 0xffee
callq 0x2a0e
movq -0x30(%rbp), %rdi
jmp 0xfc21
movq 0x222d1(%rip), %rax     # 0x31fd0
movq (%rax), %rdi
movq -0x58(%rbp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %r8d
leaq 0x187fe(%rip), %rsi     # 0x28511
movl %ebx, %edx
movl %r12d, %r9d
xorl %eax, %eax
callq 0x2180
movb $0x1, %r8b
movl $0x6, %ebx
jmp 0xfc01
movl 0x2bc(%r12), %ebx
leaq 0x15479(%rip), %rdi     # 0x251b4
leaq 0x1851a(%rip), %rsi     # 0x2825c
leaq 0x1874e(%rip), %rdx     # 0x28497
xorl %eax, %eax
callq 0x4c22
movl 0x8(%r12), %ecx
movl %ecx, %eax
notl %eax
testb $0x3, %al
jne 0x10275
movl %ebx, %eax
cltq
movq -0x50(%rbp), %rcx
movq 0x40(%rcx), %rdi
movl 0x58(%rcx), %esi
callq *0x10f1d8(%r14,%rax,8)
leaq 0x15435(%rip), %rdi     # 0x251b4
leaq 0x184d6(%rip), %rsi     # 0x2825c
leaq 0x18741(%rip), %rdx     # 0x284ce
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x4c22
leaq 0x18312(%rip), %r14     # 0x280b0
leaq 0x1834b(%rip), %rbx     # 0x280f0
movzwl 0x2c4(%r12,%r15), %eax
movslq (%r15,%r14), %rcx
movslq (%r15,%rbx), %rdx
leaq -0x290(,%rcx,8), %rcx
addq %rbp, %rcx
movw %ax, (%rcx,%rdx,2)
addq $0x4, %r15
cmpq $0x40, %r15
jne 0xfda5
leaq -0x290(%rbp), %r15
movq %r15, %rdi
movq %r15, %rsi
movq -0x48(%rbp), %rax
callq *0x10f3b0(%rax)
movq %r15, %rdi
movl -0x34(%rbp), %esi
callq 0x6957
addq $0x32c, %r12            # imm = 0x32C
xorl %r13d, %r13d
leaq 0x1(%r13), %rax
movq %rax, -0x30(%rbp)
shlq $0x5, %rax
leaq (%rax,%rbp), %r15
addq $-0x290, %r15           # imm = 0xFD70
leaq 0x1539b(%rip), %rdi     # 0x251b4
leaq 0x1843c(%rip), %rsi     # 0x2825c
leaq 0x186bd(%rip), %rdx     # 0x284e4
xorl %eax, %eax
callq 0x4c22
xorl %eax, %eax
movzwl (%r12,%rax,4), %ecx
movslq 0x4(%r14,%rax,4), %rdx
movslq 0x4(%rbx,%rax,4), %rsi
leaq (%r15,%rdx,8), %rdx
movw %cx, (%rdx,%rsi,2)
incq %rax
cmpq $0xf, %rax
jne 0xfe30
movq %r15, %rdi
movl -0x34(%rbp), %esi
callq 0x6a50
leaq 0x17e7e(%rip), %rax     # 0x27ce0
movzbl (%r13,%rax), %eax
leaq 0x17e81(%rip), %rcx     # 0x27cf0
movzbl (%r13,%rcx), %ecx
leaq -0x290(,%rax,8), %rax
addq %rbp, %rax
movzwl (%rax,%rcx,2), %eax
movw %ax, (%r15)
shlq $0x5, %r13
leaq -0x490(,%r13), %rdi
addq %rbp, %rdi
movq %r15, %rsi
movq -0x48(%rbp), %rax
callq *0x10f3a8(%rax)
addq $0x84, %r12
movq -0x30(%rbp), %rax
movq %rax, %r13
cmpq $0x10, %rax
jne 0xfdfb
movq -0x50(%rbp), %rbx
movq 0x40(%rbx), %rdi
movl 0x58(%rbx), %esi
leaq -0x490(%rbp), %rdx
movq -0x48(%rbp), %rax
callq *0x10f378(%rax)
movq 0x40(%rbx), %rdi
movl $0x10, %esi
movl $0x10, %edx
callq 0x4dc1
jmp 0xffee
leaq 0x324(%r12), %rax
movq %rax, -0x30(%rbp)
leaq 0x368(%r12), %r15
leaq 0x181a5(%rip), %r13     # 0x280b0
leaq 0x181de(%rip), %rbx     # 0x280f0
xorl %r12d, %r12d
movq %r12, %rax
shlq $0x7, %rax
leaq (%rax,%r12,4), %rax
movq -0x30(%rbp), %rcx
cmpl $0x0, 0x4(%rcx,%rax)
jle 0xffda
leaq 0x1527e(%rip), %rdi     # 0x251b4
leaq 0x1831f(%rip), %rsi     # 0x2825c
leaq 0x1858a(%rip), %rdx     # 0x284ce
xorl %eax, %eax
callq 0x4c22
xorl %eax, %eax
movzwl (%r15,%rax), %ecx
movslq (%rax,%r13), %rdx
movslq (%rax,%rbx), %rsi
leaq -0x490(,%rdx,8), %rdx
addq %rbp, %rdx
movw %cx, (%rdx,%rsi,2)
addq $0x4, %rax
cmpq $0x40, %rax
jne 0xff4d
leaq -0x490(%rbp), %r14
movq %r14, %rdi
movl -0x34(%rbp), %esi
callq 0x6a50
leaq -0x290(%rbp), %rdi
movq %r14, %rsi
movq -0x48(%rbp), %r14
callq *0x10f3a8(%r14)
leaq 0x17d4f(%rip), %rax     # 0x27cf0
movzbl (%r12,%rax), %eax
shlq $0x2, %rax
movq -0x50(%rbp), %rcx
addq 0x40(%rcx), %rax
leaq 0x17d27(%rip), %rdx     # 0x27ce0
movzbl (%r12,%rdx), %edi
shll $0x2, %edi
movslq 0x58(%rcx), %rsi
imulq %rsi, %rdi
addq %rax, %rdi
leaq -0x290(%rbp), %rdx
callq *0x10f368(%r14)
incq %r12
addq $0x84, %r15
cmpq $0x10, %r12
jne 0xff15
movq -0x48(%rbp), %r15
movq 0x10dae0(%r15), %rax
movl -0x34(%rbp), %ecx
addl 0x103c(%rax), %ecx
cmpl $0x33, %ecx
movl $0x33, %eax
cmovll %ecx, %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
leaq 0x17ee5(%rip), %rax     # 0x27f00
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x58(%rbp), %r13
cmpl $0x1, 0x18(%r13)
ja 0x10088
movl 0x2c0(%r13), %ebx
leaq 0x1517a(%rip), %rdi     # 0x251b4
leaq 0x1821b(%rip), %rsi     # 0x2825c
leaq 0x184f7(%rip), %rdx     # 0x2853f
xorl %eax, %eax
callq 0x4c22
movl 0x8(%r13), %ecx
movl %ecx, %eax
notl %eax
testb $0x3, %al
jne 0x1023b
movl %ebx, %eax
movslq %eax, %rbx
movq -0x50(%rbp), %r14
movq 0x48(%r14), %rdi
movl 0x5c(%r14), %esi
callq *0x10f210(%r15,%rbx,8)
movq 0x50(%r14), %rdi
movl 0x60(%r14), %esi
callq *0x10f210(%r15,%rbx,8)
cmpl $0x0, 0x2b4(%r13)
je 0x10227
leaq 0x304(%r13), %rax
movq %rax, -0x40(%rbp)
addq $0xb6c, %r13            # imm = 0xB6C
leaq 0x18001(%rip), %r12     # 0x280b0
leaq 0x1803a(%rip), %rbx     # 0x280f0
xorl %r14d, %r14d
movq %r14, -0x68(%rbp)
shlq $0x4, %r14
leaq 0x150ec(%rip), %rdi     # 0x251b4
leaq 0x1818d(%rip), %rsi     # 0x2825c
leaq 0x1849c(%rip), %rdx     # 0x28572
xorl %eax, %eax
callq 0x4c22
movq -0x40(%rbp), %rcx
movzwl (%rcx,%r14), %eax
movw %ax, -0x60(%rbp)
movzwl 0x4(%rcx,%r14), %eax
movw %ax, -0x5e(%rbp)
movzwl 0x8(%rcx,%r14), %eax
movw %ax, -0x5c(%rbp)
movzwl 0xc(%rcx,%r14), %eax
movw %ax, -0x5a(%rbp)
leaq -0x60(%rbp), %r14
movq %r14, %rdi
movq %r14, %rsi
callq *0x10f3c0(%r15)
movq %r14, %rdi
movl -0x34(%rbp), %esi
callq 0x6868
movq %r13, -0x58(%rbp)
xorl %r15d, %r15d
movq %r15, %rax
shlq $0x5, %rax
movq %rax, -0x30(%rbp)
leaq (%rax,%rbp), %r14
addq $-0x490, %r14           # imm = 0xFB70
leaq 0x1506c(%rip), %rdi     # 0x251b4
leaq 0x1810d(%rip), %rsi     # 0x2825c
leaq 0x1838e(%rip), %rdx     # 0x284e4
xorl %eax, %eax
callq 0x4c22
xorl %eax, %eax
movzwl (%r13,%rax,4), %ecx
movslq 0x4(%r12,%rax,4), %rdx
movslq 0x4(%rbx,%rax,4), %rsi
leaq (%r14,%rdx,8), %rdx
movw %cx, (%rdx,%rsi,2)
incq %rax
cmpq $0xf, %rax
jne 0x1015f
movq %r14, %rdi
movl -0x34(%rbp), %esi
callq 0x6a50
leaq 0x17b4e(%rip), %rax     # 0x27ce0
movzbl (%r15,%rax), %eax
leaq 0x17b52(%rip), %rcx     # 0x27cf0
movzbl (%r15,%rcx), %ecx
leaq -0x60(%rbp,%rax,4), %rax
movzwl (%rax,%rcx,2), %eax
movw %ax, (%r14)
movq -0x30(%rbp), %rax
leaq (%rax,%rbp), %rdi
addq $-0x290, %rdi           # imm = 0xFD70
movq %r14, %rsi
movq -0x48(%rbp), %rax
callq *0x10f3a8(%rax)
incq %r15
addq $0x84, %r13
cmpq $0x4, %r15
jne 0x1012b
movq -0x68(%rbp), %r15
leaq 0x1(%r15), %rax
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rax
movq 0x48(%rax,%r15,8), %rdi
movl 0x5c(%rax,%r15,4), %esi
leaq -0x290(%rbp), %rdx
movq -0x48(%rbp), %r14
callq *0x10f370(%r14)
movq -0x58(%rbp), %r13
addq $0x210, %r13            # imm = 0x210
testq %r15, %r15
movq %r14, %r15
movq -0x30(%rbp), %r14
je 0x100b9
xorl %eax, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, %cl
jne 0x102af
movl $0x6, %eax
testb $0x2, %cl
je 0x10061
movl $0x5, %eax
testl %ebx, %ebx
je 0x10061
movl %ebx, %eax
cmpl $0x2, %ebx
je 0x10061
callq 0x2ac7
movl $0x5, %eax
jmp 0x10061
testb $0x1, %cl
jne 0x102d6
movl $0x6, %eax
testb $0x2, %cl
je 0xfd63
movl $0x5, %eax
cmpl $0x2, %ebx
je 0xfd63
movl %ebx, %eax
testl %ebx, %ebx
je 0xfd63
callq 0x2a76
movl $0x5, %eax
jmp 0xfd63
movl $0x4, %eax
testl %ebx, %ebx
je 0x10061
movl %ebx, %eax
cmpl $0x1, %ebx
je 0x10061
callq 0x2aa5
movl $0x4, %eax
jmp 0x10061
movl $0x4, %eax
cmpl $0x2, %ebx
je 0xfd63
movl %ebx, %eax
cmpl $0x1, %ebx
je 0xfd63
callq 0x2a47
movl $0x4, %eax
jmp 0xfd63