// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/encoder/analyse.c
// Function: x264_macroblock_analyse(x264_t*, x264_macroblock_t*)
void x264_macroblock_analyse( x264_t *h, x264_macroblock_t *mb )
{
    x264_mb_analysis_t analysis;
    int i;

    /* qp TODO */
    mb->i_qp = x264_clip3( h->pps->i_pic_init_qp + h->sh.i_qp_delta + 0, 0, 51 );

    /* init analysis */
    analysis.i_qp = mb->i_qp;
    analysis.i_lambda = i_qp0_cost_table[analysis.i_qp];

    /*--------------------------- Do the analysis ---------------------------*/
    x264_mb_analyse_intra( h, mb, &analysis );
    if( h->sh.i_type == SLICE_TYPE_P )
    {
        x264_mb_analyse_inter_p( h, mb, &analysis );
    }
    else if( h->sh.i_type == SLICE_TYPE_B )
    {
        x264_mb_analyse_inter_b( h, mb, &analysis );
    }

    /*-------------------- Chose the macroblock mode ------------------------*/
#define BEST_TYPE( type, partition, satd ) \
        if( satd != -1 && satd < i_satd ) \
        {   \
            i_satd = satd;  \
            mb->i_type = type; \
            mb->i_partition = partition; \
        }
    if( h->sh.i_type == SLICE_TYPE_I )
    {
        mb->i_type = analysis.i_sad_i4x4 < analysis.i_sad_i16x16 ? I_4x4 : I_16x16;
    }
    else if( h->sh.i_type == SLICE_TYPE_P )
    {
        int i_satd = analysis.i_sad_i4x4;
        mb->i_type = I_4x4;

        BEST_TYPE( I_16x16, -1,    analysis.i_sad_i16x16 );
        BEST_TYPE( P_L0,  D_16x16, analysis.i_sad_p16x16 );
        BEST_TYPE( P_L0,  D_16x8 , analysis.i_sad_p16x8  );
        BEST_TYPE( P_L0,  D_8x16 , analysis.i_sad_p8x16  );
        BEST_TYPE( P_8x8, D_8x8  , analysis.i_sad_p8x8   );
    }
    else    /* B */
    {
        int i_satd = analysis.i_sad_i4x4;
        mb->i_type = I_4x4;

        BEST_TYPE( I_16x16, -1,      analysis.i_sad_i16x16 );
        BEST_TYPE( B_L0_L0, D_16x16, analysis.i_sad_b16x16_l0 );
        BEST_TYPE( B_L1_L1, D_16x16, analysis.i_sad_b16x16_l1 );
        BEST_TYPE( B_BI_BI, D_16x16, analysis.i_sad_b16x16_bi );
    }
#undef BEST_TYPE

    if( IS_INTRA( mb->i_type ) )
    {
        x264_mb_analyse_intra_chroma( h, mb, &analysis );
    }

    /*-------------------- Update MB from the analysis ----------------------*/
    switch( mb->i_type )
    {
        case I_4x4:
            for( i = 0; i < 16; i++ )
            {
                mb->block[i].i_intra4x4_pred_mode = analysis.i_predict4x4[block_idx_x[i]][block_idx_y[i]];
            }
            mb->i_chroma_pred_mode = analysis.i_predict8x8;
            break;
        case I_16x16:
            mb->i_intra16x16_pred_mode = analysis.i_predict16x16;
            mb->i_chroma_pred_mode = analysis.i_predict8x8;
            break;
        case P_L0:
            switch( mb->i_partition )
            {
                case D_16x16:
                    x264_mb_partition_set( mb, 0, 0, 0, analysis.i_ref_p16x16, analysis.i_mv_p16x16[0], analysis.i_mv_p16x16[1] );
                    break;
                case D_16x8:
                    x264_mb_partition_set( mb, 0, 0, 0, analysis.i_ref_p16x8, analysis.i_mv_p16x8[0][0], analysis.i_mv_p16x8[0][1] );
                    x264_mb_partition_set( mb, 0, 1, 0, analysis.i_ref_p16x8, analysis.i_mv_p16x8[1][0], analysis.i_mv_p16x8[1][1] );
                    break;
                case D_8x16:
                    x264_mb_partition_set( mb, 0, 0, 0, analysis.i_ref_p8x16, analysis.i_mv_p8x16[0][0], analysis.i_mv_p8x16[0][1] );
                    x264_mb_partition_set( mb, 0, 1, 0, analysis.i_ref_p8x16, analysis.i_mv_p8x16[1][0], analysis.i_mv_p8x16[1][1] );
                    break;
                default:
                    fprintf( stderr, "internal error\n" );
                    break;
            }
            break;

        case P_8x8:
            for( i = 0; i < 4; i++ )
            {
                int i_sub;

                mb->i_sub_partition[i] = analysis.i_sub_partition_p8x8[i];
                for( i_sub = 0; i_sub < x264_mb_partition_count_table[mb->i_sub_partition[i]]; i_sub++ )
                {
                    x264_mb_partition_set( mb, 0, i, i_sub,
                                                   analysis.i_ref_p8x8,
                                                   analysis.i_mv_p8x8[i][i_sub][0],
                                                   analysis.i_mv_p8x8[i][i_sub][1] );
                }
            }
            break;
        case B_L0_L0:
            switch( mb->i_partition )
            {
                case D_16x16:
                    x264_mb_partition_set( mb, 0, 0, 0, analysis.i_ref_b16x16_l0, analysis.i_mv_b16x16_l0[0], analysis.i_mv_b16x16_l0[1] );
                    /* l1 not used/avaiable */
                    x264_mb_partition_set( mb, 1, 0, 0, -1, 0, 0 );
                    break;
                default:
                    fprintf( stderr, "internal error\n" );
                    break;
            }
            break;
        case B_L1_L1:
            switch( mb->i_partition )
            {
                case D_16x16:
                    /* l0 not used/avaiable */
                    x264_mb_partition_set( mb, 0, 0, 0, -1, 0, 0 );
                    x264_mb_partition_set( mb, 1, 0, 0, analysis.i_ref_b16x16_l1, analysis.i_mv_b16x16_l1[0], analysis.i_mv_b16x16_l1[1] );
                    break;

                default:
                    fprintf( stderr, "internal error\n" );
                    break;
            }
            break;
        case B_BI_BI:
            switch( mb->i_partition )
            {
                case D_16x16:
                    x264_mb_partition_set( mb, 0, 0, 0, analysis.i_ref_b16x16_l0, analysis.i_mv_b16x16_l0[0], analysis.i_mv_b16x16_l0[1] );
                    x264_mb_partition_set( mb, 1, 0, 0, analysis.i_ref_b16x16_l1, analysis.i_mv_b16x16_l1[0], analysis.i_mv_b16x16_l1[1] );
                    break;

                default:
                    fprintf( stderr, "internal error\n" );
                    break;
            }
            break;

        default:
            fprintf( stderr, "internal error\n" );
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x10dae0(%rax), %rax
movl 0x1034(%rax), %edi
movq -0x8(%rbp), %rax
addl 0x10db44(%rax), %edi
addl $0x0, %edi
xorl %esi, %esi
movl $0x33, %edx
callq 0x15bf0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2b0(%rax)
movq -0x10(%rbp), %rax
movl 0x2b0(%rax), %eax
movl %eax, -0x184(%rbp)
movslq -0x184(%rbp), %rcx
leaq 0x16ef9(%rip), %rax     # 0x2c390
movl (%rax,%rcx,4), %eax
movl %eax, -0x188(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x15c30
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10db00(%rax)
jne 0x154d7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x16000
jmp 0x154fa
movq -0x8(%rbp), %rax
cmpl $0x1, 0x10db00(%rax)
jne 0x154f8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x16600
jmp 0x154fa
movq -0x8(%rbp), %rax
cmpl $0x2, 0x10db00(%rax)
jne 0x1552b
movl -0x178(%rbp), %edx
movl -0x180(%rbp), %esi
movl $0x1, %ecx
xorl %eax, %eax
cmpl %esi, %edx
cmovll %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x15759
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10db00(%rax)
jne 0x15675
movl -0x178(%rbp), %eax
movl %eax, -0x190(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
cmpl $-0x1, -0x180(%rbp)
je 0x1558c
movl -0x180(%rbp), %eax
cmpl -0x190(%rbp), %eax
jge 0x1558c
movl -0x180(%rbp), %eax
movl %eax, -0x190(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
cmpl $-0x1, -0x12c(%rbp)
je 0x155c5
movl -0x12c(%rbp), %eax
cmpl -0x190(%rbp), %eax
jge 0x155c5
movl -0x12c(%rbp), %eax
movl %eax, -0x190(%rbp)
movq -0x10(%rbp), %rax
movl $0x3, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x10, 0x1c(%rax)
cmpl $-0x1, -0x11c(%rbp)
je 0x155fe
movl -0x11c(%rbp), %eax
cmpl -0x190(%rbp), %eax
jge 0x155fe
movl -0x11c(%rbp), %eax
movl %eax, -0x190(%rbp)
movq -0x10(%rbp), %rax
movl $0x3, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0xe, 0x1c(%rax)
cmpl $-0x1, -0x104(%rbp)
je 0x15637
movl -0x104(%rbp), %eax
cmpl -0x190(%rbp), %eax
jge 0x15637
movl -0x104(%rbp), %eax
movl %eax, -0x190(%rbp)
movq -0x10(%rbp), %rax
movl $0x3, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0xf, 0x1c(%rax)
cmpl $-0x1, -0xec(%rbp)
je 0x15670
movl -0xec(%rbp), %eax
cmpl -0x190(%rbp), %eax
jge 0x15670
movl -0xec(%rbp), %eax
movl %eax, -0x190(%rbp)
movq -0x10(%rbp), %rax
movl $0x4, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0xd, 0x1c(%rax)
jmp 0x15757
movl -0x178(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
cmpl $-0x1, -0x180(%rbp)
je 0x156c5
movl -0x180(%rbp), %eax
cmpl -0x194(%rbp), %eax
jge 0x156c5
movl -0x180(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
cmpl $-0x1, -0x54(%rbp)
je 0x156f5
movl -0x54(%rbp), %eax
cmpl -0x194(%rbp), %eax
jge 0x156f5
movl -0x54(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0x10(%rbp), %rax
movl $0x7, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x10, 0x1c(%rax)
cmpl $-0x1, -0x44(%rbp)
je 0x15725
movl -0x44(%rbp), %eax
cmpl -0x194(%rbp), %eax
jge 0x15725
movl -0x44(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0x10(%rbp), %rax
movl $0xb, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x10, 0x1c(%rax)
cmpl $-0x1, -0x34(%rbp)
je 0x15755
movl -0x34(%rbp), %eax
cmpl -0x194(%rbp), %eax
jge 0x15755
movl -0x34(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0x10(%rbp), %rax
movl $0xf, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x10, 0x1c(%rax)
jmp 0x15757
jmp 0x15759
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x1576d
movq -0x10(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x15781
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x16c40
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq %rax, -0x1a0(%rbp)
subq $0xf, %rax
ja 0x15bc5
movq -0x1a0(%rbp), %rax
leaq 0x16b99(%rip), %rcx     # 0x2c340
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x18c(%rbp)
cmpl $0x10, -0x18c(%rbp)
jge 0x1582a
leaq -0x188(%rbp), %rax
addq $0x14, %rax
movslq -0x18c(%rbp), %rdx
leaq 0x16c84(%rip), %rcx     # 0x2c460
movzbl (%rcx,%rdx), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x18c(%rbp), %rdx
leaq 0x16c7b(%rip), %rcx     # 0x2c470
movzbl (%rcx,%rdx), %ecx
movl (%rax,%rcx,4), %ecx
movq -0x10(%rbp), %rax
addq $0x324, %rax            # imm = 0x324
movslq -0x18c(%rbp), %rdx
imulq $0x84, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x18c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18c(%rbp)
jmp 0x157ba
movl -0x130(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c0(%rax)
jmp 0x15bdd
movl -0x17c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2bc(%rax)
movl -0x130(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c0(%rax)
jmp 0x15bdd
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x1a4(%rbp)
subl $0xe, %eax
je 0x158c5
jmp 0x15878
movl -0x1a4(%rbp), %eax
subl $0xf, %eax
je 0x15916
jmp 0x15889
movl -0x1a4(%rbp), %eax
subl $0x10, %eax
jne 0x15967
jmp 0x1589a
movq -0x10(%rbp), %rdi
movl -0x128(%rbp), %r8d
movl -0x124(%rbp), %r9d
movl -0x120(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
jmp 0x1597f
movq -0x10(%rbp), %rdi
movl -0x118(%rbp), %r8d
movl -0x114(%rbp), %r9d
movl -0x110(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
movq -0x10(%rbp), %rdi
movl -0x118(%rbp), %r8d
movl -0x10c(%rbp), %r9d
movl -0x108(%rbp), %eax
xorl %ecx, %ecx
movl $0x1, %edx
movl %ecx, %esi
movl %eax, (%rsp)
callq 0x7a80
jmp 0x1597f
movq -0x10(%rbp), %rdi
movl -0x100(%rbp), %r8d
movl -0xfc(%rbp), %r9d
movl -0xf8(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
movq -0x10(%rbp), %rdi
movl -0x100(%rbp), %r8d
movl -0xf4(%rbp), %r9d
movl -0xf0(%rbp), %eax
xorl %ecx, %ecx
movl $0x1, %edx
movl %ecx, %esi
movl %eax, (%rsp)
callq 0x7a80
jmp 0x1597f
movq 0x20662(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x170a4(%rip), %rsi     # 0x2ca1c
movb $0x0, %al
callq 0x2160
jmp 0x15bdd
movl $0x0, -0x18c(%rbp)
cmpl $0x4, -0x18c(%rbp)
jge 0x15a7f
movslq -0x18c(%rbp), %rax
movl -0xe4(%rbp,%rax,4), %edx
movq -0x10(%rbp), %rax
movslq -0x18c(%rbp), %rcx
movl %edx, 0x20(%rax,%rcx,4)
movl $0x0, -0x198(%rbp)
movl -0x198(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x18c(%rbp), %rdx
movslq 0x20(%rcx,%rdx,4), %rdx
leaq 0x16aa1(%rip), %rcx     # 0x2c480
cmpl (%rcx,%rdx,4), %eax
jge 0x15a69
movq -0x10(%rbp), %rdi
movl -0x18c(%rbp), %edx
movl -0x198(%rbp), %ecx
movl -0xe8(%rbp), %r8d
leaq -0x188(%rbp), %rax
addq $0xb4, %rax
movslq -0x18c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movslq -0x198(%rbp), %rsi
movl (%rax,%rsi,8), %r9d
leaq -0x188(%rbp), %rax
addq $0xb4, %rax
movslq -0x18c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movslq -0x198(%rbp), %rsi
movl 0x4(%rax,%rsi,8), %eax
xorl %esi, %esi
movl %eax, (%rsp)
callq 0x7a80
movl -0x198(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x198(%rbp)
jmp 0x159c2
jmp 0x15a6b
movl -0x18c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18c(%rbp)
jmp 0x1598e
jmp 0x15bdd
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
subl $0x10, %eax
jne 0x15ad5
jmp 0x15a92
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %r8d
movl -0x4c(%rbp), %r9d
movl -0x48(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %r9d, %r9d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl %r9d, %edx
movl %r9d, %ecx
movl $0x0, (%rsp)
callq 0x7a80
jmp 0x15aed
movq 0x204f4(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x16f36(%rip), %rsi     # 0x2ca1c
movb $0x0, %al
callq 0x2160
jmp 0x15bdd
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
subl $0x10, %eax
jne 0x15b44
jmp 0x15b00
movq -0x10(%rbp), %rdi
xorl %r9d, %r9d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl $0x0, (%rsp)
callq 0x7a80
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %r8d
movl -0x3c(%rbp), %r9d
movl -0x38(%rbp), %eax
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
jmp 0x15b5c
movq 0x20485(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x16ec7(%rip), %rsi     # 0x2ca1c
movb $0x0, %al
callq 0x2160
jmp 0x15bdd
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
subl $0x10, %eax
jne 0x15bab
jmp 0x15b6c
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %r8d
movl -0x4c(%rbp), %r9d
movl -0x48(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %r8d
movl -0x3c(%rbp), %r9d
movl -0x38(%rbp), %eax
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
movl %eax, (%rsp)
callq 0x7a80
jmp 0x15bc3
movq 0x2041e(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x16e60(%rip), %rsi     # 0x2ca1c
movb $0x0, %al
callq 0x2160
jmp 0x15bdd
movq 0x20404(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
leaq 0x16e46(%rip), %rsi     # 0x2ca1c
movb $0x0, %al
callq 0x2160
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw %cs:(%rax,%rax)