// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/encoder/macroblock.c
// Function: x264_mb_encode_8x8(x264_t*, x264_macroblock_t*, int, int)
static void x264_mb_encode_8x8(x264_t *h, x264_macroblock_t *mb, int b_inter, int i_qscale) {LOG_CALL;
    x264_mb_context_t *ctx = mb->context;

    uint8_t *p_src, *p_dst;
    int i_src, i_dst;

    int i, ch;
    int i_decimate_score = 0;

    for (ch = 0; ch < 2; ch++)
    {
        int16_t chroma[4][4][4];
        int16_t dct2x2[2][2];
        int16_t dct4x4[4][4][4];

        p_src = ctx->p_img[1 + ch];
        i_src = ctx->i_img[1 + ch];
        p_dst = ctx->p_fdec[1 + ch];
        i_dst = ctx->i_fdec[1 + ch];

        /* calculate the diff */
        h->pixf.sub8x8(chroma, p_src, i_src, p_dst, i_dst);

        /* calculate dct coeffs */
        for (i = 0; i < 4; i++)
        {
            h->dctf.dct4x4(dct4x4[i], chroma[i]);

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

            quant_4x4(dct4x4[i], i_qscale, b_inter ? 0 : 1);
            scan_zigzag_4x4(mb->block[16 + i + ch * 4].residual_ac, dct4x4[i]);

            i_decimate_score += x264_mb_decimate_score(mb->block[16 + i + ch * 4].residual_ac, 15);
        }

        h->dctf.dct2x2dc(dct2x2, dct2x2);
        quant_2x2_dc(dct2x2, i_qscale, b_inter ? 0 : 1);
        scan_zigzag_2x2_dc(mb->chroma_dc[ch], dct2x2);

        if (i_decimate_score < 7 && b_inter)
        {
            /* Near null chroma 8x8 block so make it null (bits saving) */
            for (i = 0; i < 4; i++)
            {
                int x, y;
                for (x = 0; x < 15; x++)
                {
                    mb->block[16 + i + ch * 4].residual_ac[x] = 0;
                }
                for (x = 0; x < 4; x++)
                {
                    for (y = 0; y < 4; y++)
                    {
                        dct4x4[i][x][y] = 0;
                    }
                }
            }
        }

        /* output samples to fdec */
        h->dctf.idct2x2dc(dct2x2, dct2x2);
        x264_mb_dequant_2x2_dc(dct2x2, i_qscale); /* XXX not inversed */

        /* calculate dct coeffs */
        for (i = 0; i < 4; i++)
        {
            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(p_dst, i_dst, chroma);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
leaq 0xcd20(%rip), %rdi      # 0x28eb0
leaq 0x1393d(%rip), %rsi     # 0x2fad4
leaq 0x13d20(%rip), %rdx     # 0x2febe
movb $0x0, %al
callq 0x4d20
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x2, -0x40(%rbp)
jge 0x1c5e0
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl 0x30(%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq 0x40(%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl 0x58(%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x10f358(%rax), %rax
leaq -0xd0(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x30(%rbp), %rcx
movl -0x38(%rbp), %r8d
callq *%rax
movl $0x0, -0x3c(%rbp)
cmpl $0x4, -0x3c(%rbp)
jge 0x1c37a
movq -0x8(%rbp), %rax
movq 0x10f398(%rax), %rax
movslq -0x3c(%rbp), %rcx
leaq -0x160(%rbp), %rdi
shlq $0x5, %rcx
addq %rcx, %rdi
movslq -0x3c(%rbp), %rcx
leaq -0xd0(%rbp), %rsi
shlq $0x5, %rcx
addq %rcx, %rsi
callq *%rax
movslq -0x3c(%rbp), %rcx
leaq -0x160(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movw (%rax), %dx
movslq -0x3c(%rbp), %rcx
leaq 0x113ce(%rip), %rax     # 0x2d670
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq -0xd8(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movslq -0x3c(%rbp), %rsi
leaq 0x1139f(%rip), %rcx     # 0x2d660
movzbl (%rcx,%rsi), %ecx
movw %dx, (%rax,%rcx,2)
movslq -0x3c(%rbp), %rax
leaq -0x160(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
movl -0x18(%rbp), %esi
movl -0x14(%rbp), %ecx
movl $0x1, %edx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0x1afc0
movq -0x10(%rbp), %rdi
addq $0x324, %rdi            # imm = 0x324
movl -0x3c(%rbp), %eax
addl $0x10, %eax
movl -0x40(%rbp), %ecx
shll $0x2, %ecx
addl %ecx, %eax
cltq
imulq $0x84, %rax, %rax
addq %rax, %rdi
addq $0x8, %rdi
movslq -0x3c(%rbp), %rax
leaq -0x160(%rbp), %rsi
shlq $0x5, %rax
addq %rax, %rsi
callq 0x203f0
movq -0x10(%rbp), %rdi
addq $0x324, %rdi            # imm = 0x324
movl -0x3c(%rbp), %eax
addl $0x10, %eax
movl -0x40(%rbp), %ecx
shll $0x2, %ecx
addl %ecx, %eax
cltq
imulq $0x84, %rax, %rax
addq %rax, %rdi
addq $0x8, %rdi
movl $0xf, %esi
callq 0x1c020
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1c247
movq -0x8(%rbp), %rax
movq 0x10f3b8(%rax), %rax
leaq -0xd8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq *%rax
leaq -0xd8(%rbp), %rdi
movl -0x18(%rbp), %esi
movl -0x14(%rbp), %ecx
movl $0x1, %edx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0x205f0
movq -0x10(%rbp), %rdi
addq $0x304, %rdi            # imm = 0x304
movslq -0x40(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
leaq -0xd8(%rbp), %rsi
callq 0x20770
cmpl $0x7, -0x44(%rbp)
jge 0x1c4dc
cmpl $0x0, -0x14(%rbp)
je 0x1c4dc
movl $0x0, -0x3c(%rbp)
cmpl $0x4, -0x3c(%rbp)
jge 0x1c4da
movl $0x0, -0x164(%rbp)
cmpl $0xf, -0x164(%rbp)
jge 0x1c453
movq -0x10(%rbp), %rax
addq $0x324, %rax            # imm = 0x324
movl -0x3c(%rbp), %ecx
addl $0x10, %ecx
movl -0x40(%rbp), %edx
shll $0x2, %edx
addl %edx, %ecx
movslq %ecx, %rcx
imulq $0x84, %rcx, %rcx
addq %rcx, %rax
movslq -0x164(%rbp), %rcx
movl $0x0, 0x8(%rax,%rcx,4)
movl -0x164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
jmp 0x1c405
movl $0x0, -0x164(%rbp)
cmpl $0x4, -0x164(%rbp)
jge 0x1c4ca
movl $0x0, -0x168(%rbp)
cmpl $0x4, -0x168(%rbp)
jge 0x1c4b7
movslq -0x3c(%rbp), %rcx
leaq -0x160(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x164(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x168(%rbp), %rcx
movw $0x0, (%rax,%rcx,2)
movl -0x168(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x168(%rbp)
jmp 0x1c470
jmp 0x1c4b9
movl -0x164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
jmp 0x1c45d
jmp 0x1c4cc
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1c3f1
jmp 0x1c4dc
movq -0x8(%rbp), %rax
movq 0x10f3c0(%rax), %rax
leaq -0xd8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq *%rax
leaq -0xd8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x7610
movl $0x0, -0x3c(%rbp)
cmpl $0x4, -0x3c(%rbp)
jge 0x1c5b7
movslq -0x3c(%rbp), %rax
leaq -0x160(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x7900
movslq -0x3c(%rbp), %rcx
leaq 0x11134(%rip), %rax     # 0x2d670
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq -0xd8(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movslq -0x3c(%rbp), %rdx
leaq 0x11105(%rip), %rcx     # 0x2d660
movzbl (%rcx,%rdx), %ecx
movw (%rax,%rcx,2), %cx
movslq -0x3c(%rbp), %rdx
leaq -0x160(%rbp), %rax
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, (%rax)
movq -0x8(%rbp), %rax
movq 0x10f3a8(%rax), %rax
movslq -0x3c(%rbp), %rcx
leaq -0xd0(%rbp), %rdi
shlq $0x5, %rcx
addq %rcx, %rdi
movslq -0x3c(%rbp), %rcx
leaq -0x160(%rbp), %rsi
shlq $0x5, %rcx
addq %rcx, %rsi
callq *%rax
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1c50d
movq -0x8(%rbp), %rax
movq 0x10f370(%rax), %rax
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
leaq -0xd0(%rbp), %rdx
callq *%rax
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1c1bf
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax)