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

    int i_max;
    int predict_mode[9];

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

    p_dst = mb->context->p_fdec[0]; i_dst = mb->context->i_fdec[0];
    p_src = mb->context->p_img[0];  i_src = mb->context->i_img[0];

    /*---------------- Try all mode and calculate their score ---------------*/

    /* 16x16 prediction selection */
    mb->i_type = I_16x16;
    res->i_sad_i16x16 = -1;
    predict_16x16_mode_available( mb, predict_mode, &i_max );
    for( i = 0; i < i_max; i++ )
    {
        int i_sad;
        int i_mode;

        i_mode = predict_mode[i];

        /* we do the prediction */
        h->predict_16x16[i_mode]( p_dst, i_dst );

        /* we calculate the diff and get the square sum of the diff */
        i_sad = h->pixf.satd[PIXEL_16x16]( p_dst, i_dst, p_src, i_src ) +
                res->i_lambda * bs_size_ue( x264_mb_pred_mode16x16_fix[i_mode] );
        /* if i_score is lower it is better */
        if( res->i_sad_i16x16 == -1 || res->i_sad_i16x16 > i_sad )
        {
            res->i_predict16x16 = i_mode;
            res->i_sad_i16x16     = i_sad;
        }
    }

    /* 4x4 prediction selection */
    mb->i_type = I_4x4;
    res->i_sad_i4x4 = 0;
    for( idx = 0; idx < 16; idx++ )
    {
        uint8_t *p_src_by;
        uint8_t *p_dst_by;
        int     i_best;
        int x, y;
        int i_pred_mode;

        i_pred_mode= x264_mb_predict_intra4x4_mode( h, mb, idx );
        x = block_idx_x[idx];
        y = block_idx_y[idx];

        p_src_by = p_src + 4 * x + 4 * y * i_src;
        p_dst_by = p_dst + 4 * x + 4 * y * i_dst;

        i_best = -1;
        predict_4x4_mode_available( mb, idx, predict_mode, &i_max );
        for( i = 0; i < i_max; i++ )
        {
            int i_sad;
            int i_mode;

            i_mode = predict_mode[i];

            /* we do the prediction */
            h->predict_4x4[i_mode]( p_dst_by, i_dst );

            /* we calculate diff and get the square sum of the diff */
            i_sad = h->pixf.satd[PIXEL_4x4]( p_dst_by, i_dst, p_src_by, i_src );

            i_sad += res->i_lambda * (i_pred_mode == x264_mb_pred_mode4x4_fix[i_mode] ? 1 : 4);

            /* if i_score is lower it is better */
            if( i_best == -1 || i_best > i_sad )
            {
                res->i_predict4x4[x][y] = i_mode;
                i_best = i_sad;
            }
        }
        res->i_sad_i4x4 += i_best;

        /* we need to encode this mb now (for next ones) */
        mb->block[idx].i_intra4x4_pred_mode = res->i_predict4x4[x][y];
        h->predict_4x4[res->i_predict4x4[x][y]]( p_dst_by, i_dst );
        x264_mb_encode_i4x4( h, mb, idx, res->i_qp );
    }
    res->i_sad_i4x4 += res->i_lambda * 24;    /* from JVT (SATD0) */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x58(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x16e10
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x15d71
movslq -0x1c(%rbp), %rax
movl -0x50(%rbp,%rax,4), %eax
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq 0x10f1d8(%rax,%rcx,8), %rax
movq -0x58(%rbp), %rdi
movl -0x64(%rbp), %esi
callq *%rax
movq -0x8(%rbp), %rax
movq 0x10f2e0(%rax), %rax
movq -0x58(%rbp), %rdi
movl -0x64(%rbp), %esi
movq -0x60(%rbp), %rdx
movl -0x68(%rbp), %ecx
callq *%rax
movl %eax, -0x9c(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xa0(%rbp)
movslq -0x70(%rbp), %rcx
leaq 0x167b7(%rip), %rax     # 0x2c4d0
movl (%rax,%rcx,4), %edi
callq 0x16f40
movl -0xa0(%rbp), %ecx
movl %eax, %edx
movl -0x9c(%rbp), %eax
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x6c(%rbp)
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x15d4d
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x6c(%rbp), %eax
jle 0x15d61
movl -0x70(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x6c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
jmp 0x15d63
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x15cb1
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
movl $0x0, -0x20(%rbp)
cmpl $0x10, -0x20(%rbp)
jge 0x15fe1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x7400
movl %eax, -0x90(%rbp)
movslq -0x20(%rbp), %rcx
leaq 0x166a7(%rip), %rax     # 0x2c460
movzbl (%rax,%rcx), %eax
movl %eax, -0x88(%rbp)
movslq -0x20(%rbp), %rcx
leaq 0x166a2(%rip), %rax     # 0x2c470
movzbl (%rax,%rcx), %eax
movl %eax, -0x8c(%rbp)
movq -0x60(%rbp), %rax
movl -0x88(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl -0x8c(%rbp), %ecx
shll $0x2, %ecx
imull -0x68(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rax
movl -0x88(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl -0x8c(%rbp), %ecx
shll $0x2, %ecx
imull -0x64(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
leaq -0x50(%rbp), %rdx
leaq -0x24(%rbp), %rcx
callq 0x16ff0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x15f3c
movslq -0x1c(%rbp), %rax
movl -0x50(%rbp,%rax,4), %eax
movl %eax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movslq -0x98(%rbp), %rcx
movq 0x10f248(%rax,%rcx,8), %rax
movq -0x80(%rbp), %rdi
movl -0x64(%rbp), %esi
callq *%rax
movq -0x8(%rbp), %rax
movq 0x10f310(%rax), %rax
movq -0x80(%rbp), %rdi
movl -0x64(%rbp), %esi
movq -0x78(%rbp), %rdx
movl -0x68(%rbp), %ecx
callq *%rax
movl %eax, -0x94(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl -0x90(%rbp), %esi
movslq -0x98(%rbp), %rdx
leaq 0x1662e(%rip), %rcx     # 0x2c4f0
movl (%rcx,%rdx,4), %edi
movl $0x4, %ecx
movl $0x1, %edx
cmpl %edi, %esi
cmovel %edx, %ecx
imull %ecx, %eax
addl -0x94(%rbp), %eax
movl %eax, -0x94(%rbp)
cmpl $-0x1, -0x84(%rbp)
je 0x15efa
movl -0x84(%rbp), %eax
cmpl -0x94(%rbp), %eax
jle 0x15f2c
movl -0x98(%rbp), %edx
movq -0x18(%rbp), %rax
addq $0x14, %rax
movslq -0x88(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x8c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x94(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x15f2e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x15e51
movl -0x84(%rbp), %ecx
movq -0x18(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
addq $0x14, %rax
movslq -0x88(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x8c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x10(%rbp), %rax
addq $0x324, %rax            # imm = 0x324
movslq -0x20(%rbp), %rdx
imulq $0x84, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
addq $0x14, %rcx
movslq -0x88(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movslq -0x8c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq 0x10f248(%rax,%rcx,8), %rax
movq -0x80(%rbp), %rdi
movl -0x64(%rbp), %esi
callq *%rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x20(%rbp), %edx
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
callq 0x1ae30
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x15d8e
movq -0x18(%rbp), %rax
imull $0x18, (%rax), %ecx
movq -0x18(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)