// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/encoder/analyse.c
// Function: predict_4x4_mode_available(x264_macroblock_t*, int, int*, int*)
static void predict_4x4_mode_available( x264_macroblock_t *mb, int idx, int *mode, int *pi_count )
{
    int b_a, b_b, b_c;
    static const int needmb[16] =
    {
        MB_LEFT|MB_TOP, MB_TOP,
        MB_LEFT,        MB_PRIVATE,
        MB_TOP,         MB_TOP|MB_TOPRIGHT,
        0,              MB_PRIVATE,
        MB_LEFT,        0,
        MB_LEFT,        MB_PRIVATE,
        0,              MB_PRIVATE,
        0,              MB_PRIVATE
    };

    /* FIXME even when b_c == 0 there is some case where missing pixels
     * are emulated and thus more mode are available TODO
     * analysis and encode should be fixed too */
    b_a = (needmb[idx]&mb->i_neighbour&MB_LEFT) == (needmb[idx]&MB_LEFT);
    b_b = (needmb[idx]&mb->i_neighbour&MB_TOP) == (needmb[idx]&MB_TOP);
    b_c = (needmb[idx]&mb->i_neighbour&(MB_TOPRIGHT|MB_PRIVATE)) == (needmb[idx]&(MB_TOPRIGHT|MB_PRIVATE));

    if( b_a && b_b )
    {
        *mode++ = I_PRED_4x4_DC;
        *mode++ = I_PRED_4x4_H;
        *mode++ = I_PRED_4x4_V;
        *mode++ = I_PRED_4x4_DDR;
        *mode++ = I_PRED_4x4_VR;
        *mode++ = I_PRED_4x4_HD;
        *mode++ = I_PRED_4x4_HU;

        *pi_count = 7;

        if( b_c )
        {
            *mode++ = I_PRED_4x4_DDL;
            *mode++ = I_PRED_4x4_VL;
            (*pi_count) += 2;
        }
    }
    else if( b_a && !b_b )
    {
        *mode++ = I_PRED_4x4_DC_LEFT;
        *mode++ = I_PRED_4x4_H;
        *pi_count = 2;
    }
    else if( !b_a && b_b )
    {
        *mode++ = I_PRED_4x4_DC_TOP;
        *mode++ = I_PRED_4x4_V;
        *pi_count = 2;
    }
    else
    {
        *mode++ = I_PRED_4x4_DC_128;
        *pi_count = 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x15912(%rip), %rax     # 0x2c920
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
andl 0x8(%rcx), %eax
andl $0x1, %eax
movslq -0xc(%rbp), %rdx
leaq 0x158fa(%rip), %rcx     # 0x2c920
movl (%rcx,%rdx,4), %ecx
andl $0x1, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x158dc(%rip), %rax     # 0x2c920
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
andl 0x8(%rcx), %eax
andl $0x2, %eax
movslq -0xc(%rbp), %rdx
leaq 0x158c4(%rip), %rcx     # 0x2c920
movl (%rcx,%rdx,4), %ecx
andl $0x2, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x158a6(%rip), %rax     # 0x2c920
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
andl 0x8(%rcx), %eax
andl $0x14, %eax
movslq -0xc(%rbp), %rdx
leaq 0x1588e(%rip), %rcx     # 0x2c920
movl (%rcx,%rdx,4), %ecx
andl $0x14, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x17196
cmpl $0x0, -0x28(%rbp)
je 0x17196
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x2, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x1, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x4, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x5, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x6, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x8, (%rax)
movq -0x20(%rbp), %rax
movl $0x7, (%rax)
cmpl $0x0, -0x2c(%rbp)
je 0x17191
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x3, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x7, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x2, %ecx
movl %ecx, (%rax)
jmp 0x1723d
cmpl $0x0, -0x24(%rbp)
je 0x171d8
cmpl $0x0, -0x28(%rbp)
jne 0x171d8
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x9, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x1, (%rax)
movq -0x20(%rbp), %rax
movl $0x2, (%rax)
jmp 0x1723b
cmpl $0x0, -0x24(%rbp)
jne 0x1721a
cmpl $0x0, -0x28(%rbp)
je 0x1721a
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0xa, (%rax)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x2, (%rax)
jmp 0x17239
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x18(%rbp)
movl $0xb, (%rax)
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x1723b
jmp 0x1723d
popq %rbp
retq
nop