// File: /workspace/github_c_makefile_star2_O3/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, %r13
leaq 0x178ef(%rip), %rdi     # 0x271b4
leaq 0x1a784(%rip), %rsi     # 0x2a050
leaq 0x1a8cf(%rip), %rdx     # 0x2a1a2
xorl %eax, %eax
callq 0x4a56
movq 0x10(%r12), %rax
movq %rax, -0x40(%rbp)
movl 0x18(%r12), %eax
cmpl $0x2, %eax
jb 0xf8fd
movq %r13, %rdi
movq %r12, %rsi
callq 0x71f5
movl 0x18(%r12), %eax
movl 0x2b0(%r12), %ecx
movl %ecx, -0x2c(%rbp)
cmpl $0x1, %eax
movq %r12, -0x50(%rbp)
movq %r13, -0x48(%rbp)
je 0xfb32
testl %eax, %eax
jne 0xfcf3
leaq 0x324(%r12), %rax
movq %rax, -0x60(%rbp)
leaq 0x368(%r12), %r15
leaq 0x1a664(%rip), %r13     # 0x29fa0
xorl %r12d, %r12d
leaq 0x1a6fa(%rip), %rax     # 0x2a040
movzbl (%r12,%rax), %eax
shlq $0x2, %rax
movq -0x40(%rbp), %rdx
addq 0x40(%rdx), %rax
leaq 0x1a6d2(%rip), %rcx     # 0x2a030
movzbl (%r12,%rcx), %ecx
shll $0x2, %ecx
movslq 0x58(%rdx), %rdx
imulq %rcx, %rdx
addq %rax, %rdx
movq %rdx, -0x38(%rbp)
movq %r12, %rax
shlq $0x7, %rax
leaq (%rax,%r12,4), %rcx
movq -0x60(%rbp), %rax
movq %rcx, -0x68(%rbp)
movl (%rax,%rcx), %ebx
leaq 0x17822(%rip), %rdi     # 0x271b4
leaq 0x1a6b7(%rip), %rsi     # 0x2a050
leaq 0x1a94a(%rip), %rdx     # 0x2a2ea
xorl %eax, %eax
callq 0x4a56
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
notl %eax
leaq 0x1a629(%rip), %rcx     # 0x29fe0
andl (%rcx,%r12,4), %eax
movl %eax, %ecx
andl $0x2, %ecx
sete %sil
testb $0x14, %al
sete %dl
cmpl $0x2, %ebx
jne 0xf9e9
testb $0x3, %al
je 0xfa25
cmpl $0x1, %ecx
movl $0xa, %ebx
sbbl $-0x1, %ebx
testb $0x1, %al
movl $0x9, %eax
cmovel %eax, %ebx
jmp 0xfa34
movl %eax, %edi
andl $0x1, %edi
movl %ebx, %r8d
xorl $0x1, %r8d
orl %edi, %r8d
je 0xfa34
movl %ecx, %edi
orl %ebx, %edi
je 0xfa34
orb %dl, %sil
movl %ebx, %edi
andl $-0x5, %edi
cmpl $0x3, %edi
sete %dil
testb %sil, %dil
je 0xfa2c
shrl %ecx
orb %dl, %cl
jne 0xfa34
movq -0x38(%rbp), %rdi
callq 0x28f1
jmp 0xfa34
movl $0x2, %ebx
jmp 0xfa34
testb $0x3, %al
jne 0xfb01
movq -0x68(%rbp), %r14
addq -0x60(%rbp), %r14
movslq %ebx, %rax
movq -0x40(%rbp), %rcx
movl 0x58(%rcx), %esi
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rcx
callq *0x10f248(%rcx,%rax,8)
cmpl $0x0, 0x4(%r14)
jle 0xfae8
leaq 0x1774d(%rip), %rdi     # 0x271b4
leaq 0x1a5e2(%rip), %rsi     # 0x2a050
leaq 0x1a84d(%rip), %rdx     # 0x2a2c2
xorl %eax, %eax
callq 0x4a56
xorl %eax, %eax
leaq 0x1a4db(%rip), %rdi     # 0x29f60
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 0xfa85
leaq -0x490(%rbp), %rbx
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0x6874
leaq -0x290(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq -0x48(%rbp), %rbx
callq *0x10f3a8(%rbx)
movq -0x40(%rbp), %rax
movl 0x58(%rax), %esi
movq -0x38(%rbp), %rdi
movq %r14, %rdx
callq *0x10f368(%rbx)
incq %r12
addq $0x84, %r15
cmpq $0x10, %r12
jne 0xf93f
jmp 0xfdf1
movq 0x234c8(%rip), %rax     # 0x32fd0
movq (%rax), %rdi
movq -0x50(%rbp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %r8d
leaq 0x1a7e9(%rip), %rsi     # 0x2a305
movl %ebx, %edx
movl %r12d, %r9d
xorl %eax, %eax
callq 0x2170
movl $0x6, %ebx
jmp 0xfa34
movl 0x2bc(%r12), %ebx
leaq 0x17673(%rip), %rdi     # 0x271b4
leaq 0x1a508(%rip), %rsi     # 0x2a050
leaq 0x1a73c(%rip), %rdx     # 0x2a28b
xorl %eax, %eax
callq 0x4a56
movl 0x8(%r12), %ecx
movl %ecx, %eax
notl %eax
testb $0x3, %al
jne 0x10083
movl %ebx, %eax
cltq
movq -0x40(%rbp), %rcx
movq 0x40(%rcx), %rdi
movl 0x58(%rcx), %esi
callq *0x10f1d8(%r13,%rax,8)
leaq 0x1762f(%rip), %rdi     # 0x271b4
leaq 0x1a4c4(%rip), %rsi     # 0x2a050
leaq 0x1a72f(%rip), %rdx     # 0x2a2c2
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x4a56
leaq 0x1a3bc(%rip), %r14     # 0x29f60
leaq 0x1a3f5(%rip), %rbx     # 0x29fa0
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 0xfbab
leaq -0x290(%rbp), %r15
movq %r15, %rdi
movq %r15, %rsi
callq *0x10f3b0(%r13)
movq %r15, %rdi
movl -0x2c(%rbp), %esi
callq 0x677b
addq $0x32c, %r12            # imm = 0x32C
xorl %r13d, %r13d
leaq 0x1(%r13), %rax
movq %rax, -0x38(%rbp)
shlq $0x5, %rax
leaq (%rax,%rbp), %r15
addq $-0x290, %r15           # imm = 0xFD70
leaq 0x17598(%rip), %rdi     # 0x271b4
leaq 0x1a42d(%rip), %rsi     # 0x2a050
leaq 0x1a6ae(%rip), %rdx     # 0x2a2d8
xorl %eax, %eax
callq 0x4a56
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 0xfc33
movq %r15, %rdi
movl -0x2c(%rbp), %esi
callq 0x6874
leaq 0x1a3cb(%rip), %rax     # 0x2a030
movzbl (%r13,%rax), %eax
leaq 0x1a3ce(%rip), %rcx     # 0x2a040
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 -0x38(%rbp), %rax
movq %rax, %r13
cmpq $0x10, %rax
jne 0xfbfe
movq -0x40(%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 0x4bf5
jmp 0xfdf1
leaq 0x324(%r12), %rax
movq %rax, -0x38(%rbp)
leaq 0x368(%r12), %r15
leaq 0x1a252(%rip), %r13     # 0x29f60
leaq 0x1a28b(%rip), %rbx     # 0x29fa0
xorl %r12d, %r12d
movq %r12, %rax
shlq $0x7, %rax
leaq (%rax,%r12,4), %rax
movq -0x38(%rbp), %rcx
cmpl $0x0, 0x4(%rcx,%rax)
jle 0xfddd
leaq 0x1747b(%rip), %rdi     # 0x271b4
leaq 0x1a310(%rip), %rsi     # 0x2a050
leaq 0x1a57b(%rip), %rdx     # 0x2a2c2
xorl %eax, %eax
callq 0x4a56
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 0xfd50
leaq -0x490(%rbp), %r14
movq %r14, %rdi
movl -0x2c(%rbp), %esi
callq 0x6874
leaq -0x290(%rbp), %rdi
movq %r14, %rsi
movq -0x48(%rbp), %r14
callq *0x10f3a8(%r14)
leaq 0x1a29c(%rip), %rax     # 0x2a040
movzbl (%r12,%rax), %eax
shlq $0x2, %rax
movq -0x40(%rbp), %rcx
addq 0x40(%rcx), %rax
leaq 0x1a274(%rip), %rdx     # 0x2a030
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 0xfd18
movq -0x48(%rbp), %r15
movq 0x10dae0(%r15), %rax
movl -0x2c(%rbp), %edx
addl 0x103c(%rax), %edx
cmpl $0x33, %edx
movl $0x33, %eax
cmovbl %edx, %eax
xorl %ecx, %ecx
testl %edx, %edx
cmovnsl %eax, %ecx
leaq 0x19f92(%rip), %rax     # 0x29db0
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %r14
cmpl $0x1, 0x18(%r14)
ja 0xfe8f
movl 0x2c0(%r14), %ebx
leaq 0x17377(%rip), %rdi     # 0x271b4
leaq 0x1a20c(%rip), %rsi     # 0x2a050
leaq 0x1a4e8(%rip), %rdx     # 0x2a333
xorl %eax, %eax
callq 0x4a56
movl 0x8(%r14), %ecx
movl %ecx, %eax
notl %eax
testb $0x3, %al
jne 0x10049
movl %ebx, %eax
movslq %eax, %rbx
movq -0x40(%rbp), %r12
movq 0x48(%r12), %rdi
movl 0x5c(%r12), %esi
callq *0x10f210(%r15,%rbx,8)
movq 0x50(%r12), %rdi
movl 0x60(%r12), %esi
callq *0x10f210(%r15,%rbx,8)
cmpl $0x0, 0x2b4(%r14)
je 0x10035
movq -0x50(%rbp), %rax
leaq 0x304(%rax), %rcx
movq %rcx, -0x70(%rbp)
addq $0xb6c, %rax            # imm = 0xB6C
movq %rax, -0x50(%rbp)
movb $0x1, %al
leaq 0x1a0a1(%rip), %r12     # 0x29f60
leaq 0x1a0da(%rip), %rbx     # 0x29fa0
xorl %r13d, %r13d
movl %eax, -0x60(%rbp)
movq %r13, %r14
shlq $0x4, %r14
leaq 0x172da(%rip), %rdi     # 0x271b4
leaq 0x1a16f(%rip), %rsi     # 0x2a050
leaq 0x1a47e(%rip), %rdx     # 0x2a366
xorl %eax, %eax
callq 0x4a56
movq -0x70(%rbp), %rcx
movzwl (%rcx,%r14), %eax
movw %ax, -0x58(%rbp)
movzwl 0x4(%rcx,%r14), %eax
movw %ax, -0x56(%rbp)
movzwl 0x8(%rcx,%r14), %eax
movw %ax, -0x54(%rbp)
movzwl 0xc(%rcx,%r14), %eax
movw %ax, -0x52(%rbp)
leaq -0x58(%rbp), %r14
movq %r14, %rdi
movq %r14, %rsi
callq *0x10f3c0(%r15)
movq %r14, %rdi
movl -0x2c(%rbp), %esi
callq 0x668c
movq %r13, -0x68(%rbp)
imulq $0x210, %r13, %r13      # imm = 0x210
addq -0x50(%rbp), %r13
xorl %r15d, %r15d
movq %r15, %rax
shlq $0x5, %rax
movq %rax, -0x38(%rbp)
leaq (%rax,%rbp), %r14
addq $-0x490, %r14           # imm = 0xFB70
leaq 0x1724f(%rip), %rdi     # 0x271b4
leaq 0x1a0e4(%rip), %rsi     # 0x2a050
leaq 0x1a365(%rip), %rdx     # 0x2a2d8
xorl %eax, %eax
callq 0x4a56
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 0xff7c
movq %r14, %rdi
movl -0x2c(%rbp), %esi
callq 0x6874
leaq 0x1a081(%rip), %rax     # 0x2a030
movzbl (%r15,%rax), %eax
leaq 0x1a085(%rip), %rcx     # 0x2a040
movzbl (%r15,%rcx), %ecx
leaq -0x58(%rbp,%rax,4), %rax
movzwl (%rax,%rcx,2), %eax
movw %ax, (%r14)
movq -0x38(%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 0xff48
movq -0x40(%rbp), %rax
movq -0x68(%rbp), %rcx
movq 0x48(%rax,%rcx,8), %rdi
movl 0x5c(%rax,%rcx,4), %esi
leaq -0x290(%rbp), %rdx
movq -0x48(%rbp), %r15
callq *0x10f370(%r15)
movl $0x1, %r13d
testb $0x1, -0x60(%rbp)
movl $0x0, %eax
jne 0xfec9
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 0x100bd
movl $0x6, %eax
testb $0x2, %cl
je 0xfe64
movl $0x5, %eax
testl %ebx, %ebx
je 0xfe64
movl %ebx, %eax
cmpl $0x2, %ebx
je 0xfe64
callq 0x29aa
movl $0x5, %eax
jmp 0xfe64
testb $0x1, %cl
jne 0x100e4
movl $0x6, %eax
testb $0x2, %cl
je 0xfb69
movl $0x5, %eax
cmpl $0x2, %ebx
je 0xfb69
movl %ebx, %eax
testl %ebx, %ebx
je 0xfb69
callq 0x2959
movl $0x5, %eax
jmp 0xfb69
movl $0x4, %eax
testl %ebx, %ebx
je 0xfe64
movl %ebx, %eax
cmpl $0x1, %ebx
je 0xfe64
callq 0x2988
movl $0x4, %eax
jmp 0xfe64
movl $0x4, %eax
cmpl $0x2, %ebx
je 0xfb69
movl %ebx, %eax
cmpl $0x1, %ebx
je 0xfb69
callq 0x292a
movl $0x4, %eax
jmp 0xfb69