// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/encoder/analyse.c
// Function: x264_mb_analyse_inter_b(x264_t*, x264_macroblock_t*, x264_mb_analysis_t*)
static void x264_mb_analyse_inter_b( x264_t *h, x264_macroblock_t *mb, x264_mb_analysis_t *res )
{
    x264_mb_context_t *ctx = mb->context;
    uint8_t pix1[16*16], pix2[16*16];

    int i_ref;
    /* int i_ref0, i_ref1; */

    int mvp[2];

    res->i_sad_b16x16_l0 = -1;
    res->i_sad_b16x16_l1 = -1;
    res->i_sad_b16x16_bi = -1;

    /* 16x16 L0 Search on all ref frame */
    mb->i_type = B_L0_L0;  /* beurk fix that */
    mb->i_partition = D_16x16;
    for( i_ref = 0; i_ref < h->i_ref0; i_ref++ )
    {
        int i_sad;
        int mvx, mvy;

        /* Get the predicted MV */
        x264_mb_partition_set( mb, 0, 0, 0, i_ref, 0, 0 );
        x264_mb_predict_mv( mb, 0, 0, 0, mvp );

        mvx = mvp[0]; mvy = mvp[1];
        i_sad = h->me( h, ctx->p_fref0[i_ref][0], ctx->i_fref0[i_ref][0],
                          ctx->p_img[0],         ctx->i_img[0],
                          PIXEL_16x16, res->i_lambda, &mvx, &mvy );
        i_sad += res->i_lambda * bs_size_te( h->sh.i_num_ref_idx_l0_active - 1, i_ref );

        if( res->i_sad_b16x16_l0 == -1 || i_sad < res->i_sad_b16x16_l0 )
        {
            res->i_sad_b16x16_l0   = i_sad;
            res->i_ref_b16x16_l0   = i_ref;
            res->i_mv_b16x16_l0[0] = mvx;
            res->i_mv_b16x16_l0[1] = mvy;
        }
    }

    /* 16x16 L1 Search on all ref frame */
    mb->i_type = B_L1_L1;  /* beurk fix that */
    mb->i_partition = D_16x16;
    for( i_ref = 0; i_ref < h->i_ref1; i_ref++ )
    {
        int i_sad;
        int mvx, mvy;

        /* Get the predicted MV */
        x264_mb_partition_set( mb, 1, 0, 0, i_ref, 0, 0 );
        x264_mb_predict_mv( mb, 1, 0, 0, mvp );

        mvx = mvp[0]; mvy = mvp[1];
        i_sad = h->me( h, ctx->p_fref1[i_ref][0], ctx->i_fref1[i_ref][0],
                          ctx->p_img[0],         ctx->i_img[0],
                          PIXEL_16x16, res->i_lambda, &mvx, &mvy );
        i_sad += res->i_lambda * bs_size_te( h->sh.i_num_ref_idx_l1_active - 1, i_ref );

        if( res->i_sad_b16x16_l1 == -1 || i_sad < res->i_sad_b16x16_l1 )
        {
            res->i_sad_b16x16_l1   = i_sad;
            res->i_ref_b16x16_l1   = i_ref;
            res->i_mv_b16x16_l1[0] = mvx;
            res->i_mv_b16x16_l1[1] = mvy;
        }
    }

    /* calculate i_sad_b16x16_bi */
    h->mc[MC_LUMA]( ctx->p_fref0[res->i_ref_b16x16_l0][0], ctx->i_fref0[res->i_ref_b16x16_l0][0],
                    pix1, 16,
                    res->i_mv_b16x16_l0[0],
                    res->i_mv_b16x16_l0[1],
                    16, 16 );
    h->mc[MC_LUMA]( ctx->p_fref1[res->i_ref_b16x16_l1][0], ctx->i_fref1[res->i_ref_b16x16_l1][0],
                    pix2, 16,
                    res->i_mv_b16x16_l1[0],
                    res->i_mv_b16x16_l1[1],
                    16, 16 );
    h->pixf.avg[PIXEL_16x16]( pix1, 16, pix2, 16 );

    res->i_sad_b16x16_bi = h->pixf.sad[PIXEL_16x16]( ctx->p_img[0], ctx->i_img[0], pix1, 16 );
    x264_mb_partition_set( mb, 0, 0, 0, res->i_ref_b16x16_l0, res->i_mv_b16x16_l0[0], res->i_mv_b16x16_l0[1] );
    x264_mb_partition_set( mb, 1, 0, 0, res->i_ref_b16x16_l1, res->i_mv_b16x16_l1[0], res->i_mv_b16x16_l1[1] );

    x264_mb_predict_mv( mb, 0, 0, 0, mvp );
    res->i_sad_b16x16_bi += res->i_lambda * bs_size_te( h->sh.i_num_ref_idx_l0_active - 1, res->i_ref_b16x16_l0 );

    x264_mb_predict_mv( mb, 1, 0, 0, mvp );
    res->i_sad_b16x16_bi += res->i_lambda * bs_size_te( h->sh.i_num_ref_idx_l1_active - 1, res->i_ref_b16x16_l1 );

#if 0
    /* Now do the rafinement (using the ref found in 16x16 mode) */
    i_ref0 = res->i_ref_b16x16_l0;
    i_ref1 = res->i_ref_b16x16_l1;
    x264_mb_partition_set( mb, 0, 0, 0, i_ref0, 0, 0 );
    x264_mb_partition_set( mb, 1, 0, 0, i_ref1, 0, 0 );

    /* now do 16x8 */
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl $0xffffffff, 0x134(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl $0xffffffff, 0x144(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl $0xffffffff, 0x154(%rax) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movl $0x7, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0x10, 0x1c(%rax)
movl $0x0, -0x234(%rbp)
movl -0x234(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10f078(%rcx), %eax
jge 0x16805
movq -0x18(%rbp), %rdi
movl -0x234(%rbp), %r8d
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl $0x0, (%rsp)
callq 0x7a80
movq -0x18(%rbp), %rdi
leaq -0x23c(%rbp), %r8
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x7ff0
movl -0x23c(%rbp), %eax
movl %eax, -0x244(%rbp)
movl -0x238(%rbp), %eax
movl %eax, -0x248(%rbp)
movq -0x10(%rbp), %rax
movq 0x10f390(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movslq -0x234(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rsi
movq -0x28(%rbp), %rcx
addq $0x1e8, %rcx            # imm = 0x1E8
movslq -0x234(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %edx
movq -0x28(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x28(%rbp), %r8
movl 0x30(%r8), %r8d
movq -0x20(%rbp), %r9
movl (%r9), %ebx
xorl %r9d, %r9d
leaq -0x244(%rbp), %r11
leaq -0x248(%rbp), %r10
movl %ebx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
callq *%rax
movl %eax, -0x240(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x258(%rbp)
movq -0x10(%rbp), %rax
movl 0x10db38(%rax), %edi
subl $0x1, %edi
movl -0x234(%rbp), %esi
callq 0x17240
movl %eax, %ecx
movl -0x258(%rbp), %eax
imull %ecx, %eax
addl -0x240(%rbp), %eax
movl %eax, -0x240(%rbp)
movq -0x20(%rbp), %rax
cmpl $-0x1, 0x134(%rax)
je 0x167af
movl -0x240(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x134(%rcx), %eax
jge 0x167ef
movl -0x240(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x134(%rax)
movl -0x234(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x138(%rax)
movl -0x244(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x13c(%rax)
movl -0x248(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x140(%rax)
jmp 0x167f1
movl -0x234(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x1666e
movq -0x18(%rbp), %rax
movl $0xb, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0x10, 0x1c(%rax)
movl $0x0, -0x234(%rbp)
movl -0x234(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10f100(%rcx), %eax
jge 0x169c4
movq -0x18(%rbp), %rdi
movl -0x234(%rbp), %r8d
movl $0x1, %esi
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl $0x0, (%rsp)
callq 0x7a80
movq -0x18(%rbp), %rdi
leaq -0x23c(%rbp), %r8
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x7ff0
movl -0x23c(%rbp), %eax
movl %eax, -0x250(%rbp)
movl -0x238(%rbp), %eax
movl %eax, -0x254(%rbp)
movq -0x10(%rbp), %rax
movq 0x10f390(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rcx
addq $0x2a8, %rcx            # imm = 0x2A8
movslq -0x234(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rsi
movq -0x28(%rbp), %rcx
addq $0x428, %rcx            # imm = 0x428
movslq -0x234(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %edx
movq -0x28(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x28(%rbp), %r8
movl 0x30(%r8), %r8d
movq -0x20(%rbp), %r9
movl (%r9), %ebx
xorl %r9d, %r9d
leaq -0x250(%rbp), %r11
leaq -0x254(%rbp), %r10
movl %ebx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
callq *%rax
movl %eax, -0x24c(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x25c(%rbp)
movq -0x10(%rbp), %rax
movl 0x10db3c(%rax), %edi
subl $0x1, %edi
movl -0x234(%rbp), %esi
callq 0x17240
movl %eax, %ecx
movl -0x25c(%rbp), %eax
imull %ecx, %eax
addl -0x24c(%rbp), %eax
movl %eax, -0x24c(%rbp)
movq -0x20(%rbp), %rax
cmpl $-0x1, 0x144(%rax)
je 0x1696e
movl -0x24c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x144(%rcx), %eax
jge 0x169ae
movl -0x24c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x144(%rax)
movl -0x234(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x148(%rax)
movl -0x250(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14c(%rax)
movl -0x254(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x150(%rax)
jmp 0x169b0
movl -0x234(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x16825
movq -0x10(%rbp), %rax
movq 0x10f380(%rax), %rax
movq -0x28(%rbp), %rcx
addq $0x68, %rcx
movq -0x20(%rbp), %rdx
movslq 0x138(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdi
movq -0x28(%rbp), %rcx
addq $0x1e8, %rcx            # imm = 0x1E8
movq -0x20(%rbp), %rdx
movslq 0x138(%rdx), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %esi
leaq -0x130(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl 0x13c(%rcx), %r8d
movq -0x20(%rbp), %rcx
movl 0x140(%rcx), %r9d
movl $0x10, %ecx
movl $0x10, (%rsp)
movl $0x10, 0x8(%rsp)
callq *%rax
movq -0x10(%rbp), %rax
movq 0x10f380(%rax), %rax
movq -0x28(%rbp), %rcx
addq $0x2a8, %rcx            # imm = 0x2A8
movq -0x20(%rbp), %rdx
movslq 0x148(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdi
movq -0x28(%rbp), %rcx
addq $0x428, %rcx            # imm = 0x428
movq -0x20(%rbp), %rdx
movslq 0x148(%rdx), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %esi
leaq -0x230(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl 0x14c(%rcx), %r8d
movq -0x20(%rbp), %rcx
movl 0x150(%rcx), %r9d
movl $0x10, %ecx
movl $0x10, (%rsp)
movl $0x10, 0x8(%rsp)
callq *%rax
movq -0x10(%rbp), %rax
movq 0x10f318(%rax), %rax
leaq -0x130(%rbp), %rdi
leaq -0x230(%rbp), %rdx
movl $0x10, %ecx
movl %ecx, %esi
callq *%rax
movq -0x10(%rbp), %rax
movq 0x10f2a8(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x18(%rcx), %rdi
movq -0x28(%rbp), %rcx
movl 0x30(%rcx), %esi
leaq -0x130(%rbp), %rdx
movl $0x10, %ecx
callq *%rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x154(%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x138(%rax), %r8d
movq -0x20(%rbp), %rax
movl 0x13c(%rax), %r9d
movq -0x20(%rbp), %rax
movl 0x140(%rax), %eax
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x148(%rax), %r8d
movq -0x20(%rbp), %rax
movl 0x14c(%rax), %r9d
movq -0x20(%rbp), %rax
movl 0x150(%rax), %eax
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
movq -0x18(%rbp), %rdi
leaq -0x23c(%rbp), %r8
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x7ff0
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x264(%rbp)
movq -0x10(%rbp), %rax
movl 0x10db38(%rax), %edi
subl $0x1, %edi
movq -0x20(%rbp), %rax
movl 0x138(%rax), %esi
callq 0x17240
movl -0x264(%rbp), %ecx
imull %eax, %ecx
movq -0x20(%rbp), %rax
addl 0x154(%rax), %ecx
movl %ecx, 0x154(%rax)
movq -0x18(%rbp), %rdi
leaq -0x23c(%rbp), %r8
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x7ff0
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x260(%rbp)
movq -0x10(%rbp), %rax
movl 0x10db3c(%rax), %edi
subl $0x1, %edi
movq -0x20(%rbp), %rax
movl 0x148(%rax), %esi
callq 0x17240
movl -0x260(%rbp), %ecx
imull %eax, %ecx
movq -0x20(%rbp), %rax
addl 0x154(%rax), %ecx
movl %ecx, 0x154(%rax)
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)