// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/encoder/analyse.c
// Function: x264_mb_analyse_inter_p_p8x8(x264_t*, x264_macroblock_t*, x264_mb_analysis_t*)
static void x264_mb_analyse_inter_p_p8x8( x264_t *h, x264_macroblock_t *mb, x264_mb_analysis_t *res )
{
    x264_mb_context_t *ctx = mb->context;
    int i_ref = res->i_ref_p16x16;

    uint8_t *p_fref = ctx->p_fref0[i_ref][0];
    int      i_fref = ctx->i_fref0[i_ref][0];
    uint8_t *p_img  = ctx->p_img[0];
    int      i_img  = ctx->i_img[0];

    int i;

    res->i_ref_p8x8 = i_ref;
    res->i_sad_p8x8 = 0;
    mb->i_partition = D_8x8;

    for( i = 0; i < 4; i++ )
    {
        static const int test8x8_mode[4] = { D_L0_8x8, D_L0_8x4, D_L0_4x8, D_L0_4x4 };
        static const int test8x8_pix[4]  = { PIXEL_8x8, PIXEL_8x4, PIXEL_4x8, PIXEL_4x4 };
        static const int test8x8_pos_x[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 4, 0, 0 }, { 0, 4, 0, 4 } };
        static const int test8x8_pos_y[4][4] = { { 0, 0, 0, 0 }, { 0, 4, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 4, 4 } };
        int i_test;
        int mvp[4][2];
        int mv[4][2];

        int x, y;
        int i_sub;
        int i_b_satd;

        y = 8 * (i / 2);
        x = 8 * (i % 2);
        i_b_satd = -1;

        i_test = 0;
        /* FIXME as it's tooooooo slow test only 8x8 */
        //for( i_test = 0; i_test < 4; i_test++ )
        {
            int i_satd;

            i_satd = 0;

            mb->i_sub_partition[i] = test8x8_mode[i_test];

            for( i_sub = 0; i_sub < x264_mb_partition_count_table[test8x8_mode[i_test]]; i_sub++ )
            {
                x264_mb_predict_mv( mb, 0, i, i_sub, mvp[i_sub] );
                mv[i_sub][0] = mvp[i_sub][0];
                mv[i_sub][1] = mvp[i_sub][1];

                i_satd += h->me( h,
                                 &p_fref[(y+test8x8_pos_y[i_test][i_sub])*i_fref +x+test8x8_pos_x[i_test][i_sub]], i_fref,
                                 &p_img[(y+test8x8_pos_y[i_test][i_sub])*i_img +x+test8x8_pos_x[i_test][i_sub]], i_img,
                                 test8x8_pix[i_test],
                                 res->i_lambda,
                                 &mv[i_sub][0], &mv[i_sub][1] );
            }

            switch( test8x8_mode[i_test] )
            {
                case D_L0_8x8:
                    i_satd += res->i_lambda * bs_size_ue( 0 );
                    break;
                case D_L0_8x4:
                    i_satd += res->i_lambda * bs_size_ue( 1 );
                    break;
                case D_L0_4x8:
                    i_satd += res->i_lambda * bs_size_ue( 2 );
                    break;
                case D_L0_4x4:
                    i_satd += res->i_lambda * bs_size_ue( 3 );
                    break;
                default:
                    fprintf( stderr, "internal error (invalid sub type)\n" );
                    break;
            }

            if( i_b_satd == -1 || i_b_satd > i_satd )
            {
                i_b_satd = i_satd;
                res->i_sub_partition_p8x8[i] = test8x8_mode[i_test];;
                for( i_sub = 0; i_sub < x264_mb_partition_count_table[test8x8_mode[i_test]]; i_sub++ )
                {
                    res->i_mv_p8x8[i][i_sub][0] = mv[i_sub][0];
                    res->i_mv_p8x8[i][i_sub][1] = mv[i_sub][1];
                }
            }
        }

        res->i_sad_p8x8 += i_b_satd;
        /* needed for the next block */
        mb->i_sub_partition[i] = res->i_sub_partition_p8x8[i];
        for( i_sub = 0; i_sub < x264_mb_partition_count_table[res->i_sub_partition_p8x8[i]]; i_sub++ )
        {
            x264_mb_partition_set( mb, 0, i, i_sub,
                                           res->i_ref_p8x8,
                                           res->i_mv_p8x8[i][i_sub][0],
                                           res->i_mv_p8x8[i][i_sub][1] );
        }
    }

    res->i_sad_p8x8 += 4*res->i_lambda * bs_size_te( h->sh.i_num_ref_idx_l0_active - 1, i_ref );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xe0, %rsp
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl 0x60(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq $0x1e8, %rax            # imm = 0x1E8
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x34(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x9c(%rax)
movq -0x20(%rbp), %rax
movl $0xd, 0x1c(%rax)
movl $0x0, -0x58(%rbp)
cmpl $0x4, -0x58(%rbp)
jge 0x17836
movl -0x58(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
shll $0x3, %eax
movl %eax, -0xa8(%rbp)
movl -0x58(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
shll $0x3, %edx
movl %edx, -0xa4(%rbp)
movl $0xffffffff, -0xb0(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x5c(%rbp)
movl $0x0, -0xb4(%rbp)
movslq -0x5c(%rbp), %rcx
leaq 0x155c1(%rip), %rax     # 0x2c960
movl (%rax,%rcx,4), %edx
movq -0x20(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl %edx, 0x20(%rax,%rcx,4)
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
movslq -0x5c(%rbp), %rdx
leaq 0x15597(%rip), %rcx     # 0x2c960
movslq (%rcx,%rdx,4), %rdx
leaq 0x150ac(%rip), %rcx     # 0x2c480
cmpl (%rcx,%rdx,4), %eax
jge 0x17569
movq -0x20(%rbp), %rdi
movl -0x58(%rbp), %edx
movl -0xac(%rbp), %ecx
movslq -0xac(%rbp), %rax
leaq -0x80(%rbp), %r8
shlq $0x3, %rax
addq %rax, %r8
xorl %esi, %esi
callq 0x7ff0
movslq -0xac(%rbp), %rax
movl -0x80(%rbp,%rax,8), %ecx
movslq -0xac(%rbp), %rax
movl %ecx, -0xa0(%rbp,%rax,8)
movslq -0xac(%rbp), %rax
movl -0x7c(%rbp,%rax,8), %ecx
movslq -0xac(%rbp), %rax
movl %ecx, -0x9c(%rbp,%rax,8)
movq -0x18(%rbp), %rax
movq 0x10f390(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0xa8(%rbp), %ecx
movslq -0x5c(%rbp), %r8
leaq 0x15567(%rip), %rdx     # 0x2c9c0
shlq $0x4, %r8
addq %r8, %rdx
movslq -0xac(%rbp), %r8
addl (%rdx,%r8,4), %ecx
imull -0x44(%rbp), %ecx
addl -0xa4(%rbp), %ecx
movslq -0x5c(%rbp), %r8
leaq 0x15500(%rip), %rdx     # 0x2c980
shlq $0x4, %r8
addq %r8, %rdx
movslq -0xac(%rbp), %r8
addl (%rdx,%r8,4), %ecx
movslq %ecx, %rcx
addq %rcx, %rsi
movl -0x44(%rbp), %edx
movq -0x50(%rbp), %rcx
movl -0xa8(%rbp), %r8d
movslq -0x5c(%rbp), %r10
leaq 0x1550f(%rip), %r9      # 0x2c9c0
shlq $0x4, %r10
addq %r10, %r9
movslq -0xac(%rbp), %r10
addl (%r9,%r10,4), %r8d
imull -0x54(%rbp), %r8d
addl -0xa4(%rbp), %r8d
movslq -0x5c(%rbp), %r10
leaq 0x154a6(%rip), %r9      # 0x2c980
shlq $0x4, %r10
addq %r10, %r9
movslq -0xac(%rbp), %r10
addl (%r9,%r10,4), %r8d
movslq %r8d, %r8
addq %r8, %rcx
movl -0x54(%rbp), %r8d
movslq -0x5c(%rbp), %r10
leaq 0x1546f(%rip), %r9      # 0x2c970
movl (%r9,%r10,4), %r9d
movq -0x28(%rbp), %r10
movl (%r10), %ebx
movslq -0xac(%rbp), %r10
leaq -0xa0(%rbp), %r11
shlq $0x3, %r10
addq %r10, %r11
movslq -0xac(%rbp), %r14
leaq -0xa0(%rbp), %r10
shlq $0x3, %r14
addq %r14, %r10
addq $0x4, %r10
movl %ebx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
callq *%rax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x173b8
movslq -0x5c(%rbp), %rcx
leaq 0x153ec(%rip), %rax     # 0x2c960
movl (%rax,%rcx,4), %eax
movq %rax, -0xc0(%rbp)
subq $0x3, %rax
ja 0x1765b
movq -0xc0(%rbp), %rax
leaq 0x14dea(%rip), %rcx     # 0x2c380
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
xorl %edi, %edi
callq 0x16f40
movl %eax, %ecx
movl -0xc4(%rbp), %eax
imull %ecx, %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x17673
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc8(%rbp)
movl $0x1, %edi
callq 0x16f40
movl %eax, %ecx
movl -0xc8(%rbp), %eax
imull %ecx, %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x17673
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xcc(%rbp)
movl $0x2, %edi
callq 0x16f40
movl %eax, %ecx
movl -0xcc(%rbp), %eax
imull %ecx, %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x17673
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xd0(%rbp)
movl $0x3, %edi
callq 0x16f40
movl %eax, %ecx
movl -0xd0(%rbp), %eax
imull %ecx, %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x17673
movq 0x1e96e(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x153eb(%rip), %rsi     # 0x2ca57
movb $0x0, %al
callq 0x2160
cmpl $-0x1, -0xb0(%rbp)
je 0x1768e
movl -0xb0(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jle 0x17753
movl -0xb4(%rbp), %eax
movl %eax, -0xb0(%rbp)
movslq -0x5c(%rbp), %rcx
leaq 0x152bb(%rip), %rax     # 0x2c960
movl (%rax,%rcx,4), %edx
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl %edx, 0xa4(%rax,%rcx,4)
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
movslq -0x5c(%rbp), %rdx
leaq 0x1528e(%rip), %rcx     # 0x2c960
movslq (%rcx,%rdx,4), %rdx
leaq 0x14da3(%rip), %rcx     # 0x2c480
cmpl (%rcx,%rdx,4), %eax
jge 0x17751
movslq -0xac(%rbp), %rax
movl -0xa0(%rbp,%rax,8), %edx
movq -0x28(%rbp), %rax
addq $0xb4, %rax
movslq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0xac(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
movslq -0xac(%rbp), %rax
movl -0x9c(%rbp,%rax,8), %edx
movq -0x28(%rbp), %rax
addq $0xb4, %rax
movslq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0xac(%rbp), %rcx
movl %edx, 0x4(%rax,%rcx,8)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x176c1
jmp 0x17753
movl -0xb0(%rbp), %ecx
movq -0x28(%rbp), %rax
addl 0x9c(%rax), %ecx
movl %ecx, 0x9c(%rax)
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl 0xa4(%rax,%rcx,4), %edx
movq -0x20(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl %edx, 0x20(%rax,%rcx,4)
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
movq -0x28(%rbp), %rcx
movslq -0x58(%rbp), %rdx
movslq 0xa4(%rcx,%rdx,4), %rdx
leaq 0x14cd5(%rip), %rcx     # 0x2c480
cmpl (%rcx,%rdx,4), %eax
jge 0x17826
movq -0x20(%rbp), %rdi
movl -0x58(%rbp), %edx
movl -0xac(%rbp), %ecx
movq -0x28(%rbp), %rax
movl 0xa0(%rax), %r8d
movq -0x28(%rbp), %rax
addq $0xb4, %rax
movslq -0x58(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movslq -0xac(%rbp), %rsi
movl (%rax,%rsi,8), %r9d
movq -0x28(%rbp), %rax
addq $0xb4, %rax
movslq -0x58(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movslq -0xac(%rbp), %rsi
movl 0x4(%rax,%rsi,8), %eax
xorl %esi, %esi
movl %eax, (%rsp)
callq 0x7a80
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x1778e
jmp 0x17828
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x17347
movq -0x28(%rbp), %rax
movl (%rax), %eax
shll $0x2, %eax
movl %eax, -0xd4(%rbp)
movq -0x18(%rbp), %rax
movl 0x10db38(%rax), %edi
subl $0x1, %edi
movl -0x34(%rbp), %esi
callq 0x17240
movl -0xd4(%rbp), %ecx
imull %eax, %ecx
movq -0x28(%rbp), %rax
addl 0x9c(%rax), %ecx
movl %ecx, 0x9c(%rax)
addq $0xe0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop