// File: /workspace/github_c_makefile_star2_O2/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 $0x458, %rsp            # imm = 0x458
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xf78d(%rip), %rdi      # 0x1b1b4
leaq 0x1273e(%rip), %rsi     # 0x1e16c
leaq 0x12889(%rip), %rdx     # 0x1e2be
xorl %eax, %eax
callq 0x39ba
movq 0x10(%r15), %rax
movq %rax, -0x40(%rbp)
movl 0x18(%r15), %eax
cmpl $0x2, %eax
jb 0xba5c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6011
movl 0x18(%r15), %eax
movl 0x2b0(%r15), %ecx
movl %ecx, -0x38(%rbp)
cmpl $0x1, %eax
movq %rbx, -0x30(%rbp)
movq %r15, -0x48(%rbp)
je 0xbc4d
testl %eax, %eax
jne 0xbc99
leaq 0x368(%r15), %rbx
pushq $-0x10
popq %r12
leaq 0x125af(%rip), %r14     # 0x1e040
testq %r12, %r12
je 0xbe5e
leaq 0x12a0f(%rip), %rax     # 0x1e4b0
movzbl 0x10(%r12,%rax), %eax
shlq $0x2, %rax
movq -0x40(%rbp), %rdx
addq 0x40(%rdx), %rax
leaq 0x129e6(%rip), %rcx     # 0x1e4a0
movzbl 0x10(%r12,%rcx), %ecx
shll $0x2, %ecx
movslq 0x58(%rdx), %r13
imulq %rcx, %r13
addq %rax, %r13
movl -0x44(%rbx), %r15d
leaq 0xf6db(%rip), %rdi      # 0x1b1b4
leaq 0x1268c(%rip), %rsi     # 0x1e16c
leaq 0x1291f(%rip), %rdx     # 0x1e406
xorl %eax, %eax
callq 0x39ba
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
notl %eax
movq %r14, -0x58(%rbp)
andl (%r14), %eax
movl %eax, %ecx
andl $0x2, %ecx
sete %sil
testb $0x14, %al
sete %dl
cmpl $0x2, %r15d
jne 0xbb34
pushq $0x2
popq %r15
testb $0x3, %al
movq -0x30(%rbp), %r14
je 0xbb9c
cmpl $0x1, %ecx
pushq $0xa
popq %r15
sbbl $-0x1, %r15d
testb $0x1, %al
pushq $0x9
popq %rax
cmovel %eax, %r15d
jmp 0xbb9c
movl %eax, %edi
andl $0x1, %edi
movl %r15d, %r8d
xorl $0x1, %r8d
orl %edi, %r8d
movq -0x30(%rbp), %r14
je 0xbb9c
movl %ecx, %edi
orl %r15d, %edi
je 0xbb9c
orb %dl, %sil
movl %r15d, %edi
andl $-0x5, %edi
cmpl $0x3, %edi
sete %dil
testb %sil, %dil
je 0xbb98
shrl %ecx
orb %dl, %cl
jne 0xbb9c
movq 0x1c45e(%rip), %rax     # 0x27fd0
movq (%rax), %rcx
leaq 0x12759(%rip), %rdi     # 0x1e2d5
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
callq 0x21e0
movzbl 0x3(%r13), %eax
imull $0x1010101, %eax, %eax  # imm = 0x1010101
movl %eax, 0x4(%r13)
jmp 0xbb9c
testb $0x3, %al
jne 0xbc1a
movslq %r15d, %rax
movq -0x40(%rbp), %r15
movl 0x58(%r15), %esi
movq %r13, %rdi
callq *0x10f248(%r14,%rax,8)
cmpl $0x0, -0x40(%rbx)
jle 0xbc03
movq %r12, -0x60(%rbp)
leaq -0x480(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0xc09d
movq %r12, %rdi
movl -0x38(%rbp), %esi
callq 0x5735
leaq -0x280(%rbp), %rdi
movq %r12, %rsi
movq -0x60(%rbp), %r12
callq *0x10f3a8(%r14)
movl 0x58(%r15), %esi
movq %r13, %rdi
leaq -0x280(%rbp), %rdx
callq *0x10f368(%r14)
incq %r12
movq -0x58(%rbp), %r14
addq $0x4, %r14
addq $0x84, %rbx
jmp 0xba91
movq 0x1c3af(%rip), %rax     # 0x27fd0
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %r8d
leal 0x10(%r12), %r9d
leaq 0x127e7(%rip), %rsi     # 0x1e421
movl %r15d, %edx
xorl %eax, %eax
callq 0x2170
pushq $0x6
popq %r15
jmp 0xbb9c
movl 0x2bc(%r15), %ebx
leaq 0xf559(%rip), %rdi      # 0x1b1b4
leaq 0x1250a(%rip), %rsi     # 0x1e16c
leaq 0x1273e(%rip), %rdx     # 0x1e3a7
xorl %eax, %eax
callq 0x39ba
movl 0x8(%r15), %eax
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
je 0xbd6a
testb $0x1, %al
jne 0xbd2e
testb $0x2, %al
jne 0xbd3e
pushq $0x6
popq %rbx
jmp 0xbd6a
addq $0x368, %r15            # imm = 0x368
xorl %ebx, %ebx
leaq -0x480(%rbp), %r12
leaq -0x280(%rbp), %r13
movq -0x30(%rbp), %r14
cmpq $0x10, %rbx
je 0xbe5e
cmpl $0x0, -0x40(%r15)
jle 0xbd22
movq %r12, %rdi
movq %r15, %rsi
callq 0xc09d
movq %r12, %rdi
movl -0x38(%rbp), %esi
callq 0x5735
movq %r13, %rdi
movq %r12, %rsi
callq *0x10f3a8(%r14)
leaq 0x127c1(%rip), %rax     # 0x1e4b0
movzbl (%rbx,%rax), %eax
shlq $0x2, %rax
movq -0x40(%rbp), %rcx
addq 0x40(%rcx), %rax
leaq 0x1279a(%rip), %rdx     # 0x1e4a0
movzbl (%rbx,%rdx), %edi
shll $0x2, %edi
movslq 0x58(%rcx), %rsi
imulq %rsi, %rdi
addq %rax, %rdi
movq %r13, %rdx
callq *0x10f368(%r14)
incq %rbx
addq $0x84, %r15
jmp 0xbcb4
pushq $0x4
popq %r14
cmpl $0x2, %ebx
je 0xbd67
cmpl $0x1, %ebx
je 0xbd6a
jmp 0xbd4b
pushq $0x5
popq %r14
cmpl $0x2, %ebx
je 0xbd67
testl %ebx, %ebx
je 0xbd6a
movq 0x1c27e(%rip), %rax     # 0x27fd0
movq (%rax), %rcx
leaq 0x12668(%rip), %rdi     # 0x1e3c4
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x21e0
movl %r14d, %ebx
movslq %ebx, %rax
movq -0x40(%rbp), %rcx
movq 0x40(%rcx), %rdi
movl 0x58(%rcx), %esi
movq -0x30(%rbp), %r14
callq *0x10f1d8(%r14,%rax,8)
leaq 0x2c4(%r15), %rsi
leaq -0x280(%rbp), %rbx
movq %rbx, %rdi
callq 0xc09d
movq %rbx, %rdi
movq %rbx, %rsi
callq *0x10f3b0(%r14)
movq %rbx, %rdi
movl -0x38(%rbp), %esi
callq 0x5663
addq $0x32c, %r15            # imm = 0x32C
leaq -0x480(%rbp), %r12
leaq -0x260(%rbp), %r13
xorl %ebx, %ebx
cmpq $0x10, %rbx
je 0xbe34
leaq 0x1(%rbx), %r14
movq %r13, %rdi
movq %r15, %rsi
callq 0xc106
movq %r13, %rdi
movl -0x38(%rbp), %esi
callq 0x5735
leaq 0x126b0(%rip), %rax     # 0x1e4a0
movzbl (%rbx,%rax), %eax
leaq 0x126b5(%rip), %rcx     # 0x1e4b0
movzbl (%rbx,%rcx), %ecx
leaq -0x280(%rbp,%rax,8), %rax
movzwl (%rax,%rcx,2), %eax
movw %ax, (%r13)
movq %r12, %rdi
movq %r13, %rsi
movq -0x30(%rbp), %rax
callq *0x10f3a8(%rax)
addq $0x20, %r12
addq $0x84, %r15
addq $0x20, %r13
movq %r14, %rbx
jmp 0xbdc9
movq -0x40(%rbp), %rbx
movq 0x40(%rbx), %rdi
movl 0x58(%rbx), %esi
leaq -0x480(%rbp), %rdx
movq -0x30(%rbp), %rax
callq *0x10f378(%rax)
movq 0x40(%rbx), %rdi
pushq $0x10
popq %rdx
movl %edx, %esi
callq 0x3b3d
movq -0x30(%rbp), %r14
movq 0x10dae0(%r14), %rax
movl -0x38(%rbp), %edx
addl 0x103c(%rax), %edx
cmpl $0x33, %edx
pushq $0x33
popq %rax
cmovbl %edx, %eax
xorl %ecx, %ecx
testl %edx, %edx
cmovnsl %eax, %ecx
leaq 0x11f87(%rip), %rax     # 0x1de10
movl (%rax,%rcx,4), %r15d
movq -0x48(%rbp), %r13
cmpl $0x1, 0x18(%r13)
ja 0xbf43
movl 0x2c0(%r13), %ebx
leaq 0xf30a(%rip), %rdi      # 0x1b1b4
leaq 0x122bb(%rip), %rsi     # 0x1e16c
leaq 0x12597(%rip), %rdx     # 0x1e44f
xorl %eax, %eax
callq 0x39ba
movl 0x8(%r13), %eax
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
je 0xbf14
testb $0x1, %al
jne 0xbed9
testb $0x2, %al
jne 0xbee8
pushq $0x6
popq %rbx
jmp 0xbf14
pushq $0x4
popq %r14
testl %ebx, %ebx
je 0xbf11
cmpl $0x1, %ebx
je 0xbf14
jmp 0xbef5
pushq $0x5
popq %r14
testl %ebx, %ebx
je 0xbf11
cmpl $0x2, %ebx
je 0xbf14
movq 0x1c0d4(%rip), %rax     # 0x27fd0
movq (%rax), %rcx
leaq 0x12564(%rip), %rdi     # 0x1e46a
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x21e0
movl %r14d, %ebx
movslq %ebx, %rbx
movq -0x40(%rbp), %r12
movq 0x48(%r12), %rdi
movl 0x5c(%r12), %esi
movq -0x30(%rbp), %r14
callq *0x10f210(%r14,%rbx,8)
movq 0x50(%r12), %rdi
movl 0x60(%r12), %esi
callq *0x10f210(%r14,%rbx,8)
cmpl $0x0, 0x2b4(%r13)
je 0xc089
leaq 0x304(%r13), %rax
movq %rax, -0x58(%rbp)
addq $0xb6c, %r13            # imm = 0xB6C
leaq -0x280(%rbp), %r12
xorl %ebx, %ebx
cmpq $0x2, %rbx
je 0xc089
movq %rbx, -0x38(%rbp)
shlq $0x4, %rbx
leaq 0xf22f(%rip), %rdi      # 0x1b1b4
leaq 0x121e0(%rip), %rsi     # 0x1e16c
leaq 0x124ef(%rip), %rdx     # 0x1e482
xorl %eax, %eax
callq 0x39ba
movq -0x58(%rbp), %rcx
movzwl (%rcx,%rbx), %eax
movw %ax, -0x50(%rbp)
movzwl 0x4(%rcx,%rbx), %eax
movw %ax, -0x4e(%rbp)
movzwl 0x8(%rcx,%rbx), %eax
movw %ax, -0x4c(%rbp)
movzwl 0xc(%rcx,%rbx), %eax
movw %ax, -0x4a(%rbp)
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
callq *0x10f3c0(%r14)
movq %rbx, %rdi
movl %r15d, %esi
callq 0x55a0
leaq -0x480(%rbp), %rbx
movq %r13, -0x48(%rbp)
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0xc04f
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc106
movq %rbx, %rdi
movl %r15d, %esi
callq 0x5735
leaq 0x12492(%rip), %rax     # 0x1e4a0
movzbl (%r14,%rax), %eax
leaq 0x12496(%rip), %rcx     # 0x1e4b0
movzbl (%r14,%rcx), %ecx
leaq -0x50(%rbp,%rax,4), %rax
movzwl (%rax,%rcx,2), %eax
movw %ax, (%rbx)
movq %r12, %rdi
movq %rbx, %rsi
movq -0x30(%rbp), %rax
callq *0x10f3a8(%rax)
incq %r14
addq $0x84, %r13
addq $0x20, %r12
addq $0x20, %rbx
jmp 0xbfeb
movq -0x38(%rbp), %rcx
leaq 0x1(%rcx), %rbx
movq -0x40(%rbp), %rax
movq 0x48(%rax,%rcx,8), %rdi
movl 0x5c(%rax,%rcx,4), %esi
leaq -0x280(%rbp), %r12
movq %r12, %rdx
movq -0x30(%rbp), %r14
callq *0x10f370(%r14)
movq -0x48(%rbp), %r13
addq $0x210, %r13            # imm = 0x210
jmp 0xbf6c
xorl %eax, %eax
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq