// File: /workspace/github_c_makefile_star2_O0/akumrao[P]videoAnalyzer/core/macroblock.c
// Function: x264_mb_predict_mv(x264_macroblock_t*, int, int, int, int*)
void x264_mb_predict_mv(x264_macroblock_t *mb, int i_list, int i_part, int i_subpart, int mv[2]) {LOG_CALL;
    int x, y, xn, yn;
    int w, h;
    int i_ref;

    int i_refa = -1;
    int i_refb = -1;
    int i_refc = -1;

    int mvxa = 0, mvxb = 0, mvxc = 0;
    int mvya = 0, mvyb = 0, mvyc = 0;

    x264_macroblock_t *mbn;


    x264_mb_partition_getxy(mb, i_part, i_subpart, &x, &y);
    x264_mb_partition_size(mb, i_part, i_subpart, &w, &h);
    i_ref = mb->partition[x][y].i_ref[i_list];

    /* Left  pixel (-1,0)*/
    xn = x - 1;
    mbn = mb;
    if (xn < 0)
    {
        xn += 4;
        mbn = mb->context->mba;
    }
    if (mbn)
    {
        i_refa = -2;
        if (!IS_INTRA(mbn->i_type) && mbn->partition[xn][y].i_ref[i_list] != -1)
        {
            i_refa = mbn->partition[xn][y].i_ref[i_list];
            mvxa = mbn->partition[xn][y].mv[i_list][0];
            mvya = mbn->partition[xn][y].mv[i_list][1];
        }
    }

    /* Up ( pixel(0,-1)*/
    yn = y - 1;
    mbn = mb;
    if (yn < 0)
    {
        yn += 4;
        mbn = mb->context->mbb;
    }
    if (mbn)
    {
        i_refb = -2;
        if (!IS_INTRA(mbn->i_type) && mbn->partition[x][yn].i_ref[i_list] != -1)
        {
            i_refb = mbn->partition[x][yn].i_ref[i_list];
            mvxb = mbn->partition[x][yn].mv[i_list][0];
            mvyb = mbn->partition[x][yn].mv[i_list][1];
        }
    }

    /* Up right pixel(width,-1)*/
    xn = x + w;
    yn = y - 1;

    mbn = mb;
    if (yn < 0 && xn >= 4)
    {
        if (mb->context->mbc)
        {
            xn -= 4;
            yn += 4;
            mbn = mb->context->mbc;
        } else
        {
            mbn = NULL;
        }
    } else if (yn < 0)
    {
        yn += 4;
        mbn = mb->context->mbb;
    } else if (xn >= 4 || (xn == 2 && (yn == 0 || yn == 2)))
    {
        mbn = NULL; /* not yet decoded */
    }

    if (mbn == NULL)
    {
        /* load top left pixel(-1,-1) */
        xn = x - 1;
        yn = y - 1;

        mbn = mb;
        if (yn < 0 && xn < 0)
        {
            if (mb->context->mba && mb->context->mbb)
            {
                xn += 4;
                yn += 4;
                mbn = mb->context->mbb - 1;
            } else
            {
                mbn = NULL;
            }
        } else if (yn < 0)
        {
            yn += 4;
            mbn = mb->context->mbb;
        } else if (xn < 0)
        {
            xn += 4;
            mbn = mb->context->mba;
        }
    }

    if (mbn)
    {
        i_refc = -2;
        if (!IS_INTRA(mbn->i_type) && mbn->partition[xn][yn].i_ref[i_list] != -1)
        {
            i_refc = mbn->partition[xn][yn].i_ref[i_list];
            mvxc = mbn->partition[xn][yn].mv[i_list][0];
            mvyc = mbn->partition[xn][yn].mv[i_list][1];
        }
    }

    if (mb->i_partition == D_16x8 && i_part == 0 && i_refb == i_ref)
    {
        mv[0] = mvxb;
        mv[1] = mvyb;
    } else if (mb->i_partition == D_16x8 && i_part == 1 && i_refa == i_ref)
    {
        mv[0] = mvxa;
        mv[1] = mvya;
    } else if (mb->i_partition == D_8x16 && i_part == 0 && i_refa == i_ref)
    {
        mv[0] = mvxa;
        mv[1] = mvya;
    } else if (mb->i_partition == D_8x16 && i_part == 1 && i_refc == i_ref)
    {
        mv[0] = mvxc;
        mv[1] = mvyc;
    } else
    {
        int i_count;

        i_count = 0;
        if (i_refa == i_ref) i_count++;
        if (i_refb == i_ref) i_count++;
        if (i_refc == i_ref) i_count++;

        if (i_count > 1)
        {
            mv[0] = x264_median(mvxa, mvxb, mvxc);
            mv[1] = x264_median(mvya, mvyb, mvyc);
        } else if (i_count == 1)
        {
            if (i_refa == i_ref)
            {
                mv[0] = mvxa;
                mv[1] = mvya;
            } else if (i_refb == i_ref)
            {
                mv[0] = mvxb;
                mv[1] = mvyb;
            } else
            {
                mv[0] = mvxc;
                mv[1] = mvyc;
            }
        } else if (i_refb == -1 && i_refc == -1 && i_refa != -1)
        {
            mv[0] = mvxa;
            mv[1] = mvya;
        } else
        {
            mv[0] = x264_median(mvxa, mvxb, mvxc);
            mv[1] = x264_median(mvya, mvyb, mvyc);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
leaq 0x20ea0(%rip), %rdi     # 0x28eb0
leaq 0x214ca(%rip), %rsi     # 0x294e1
leaq 0x21594(%rip), %rdx     # 0x295b2
movb $0x0, %al
callq 0x4d20
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
leaq -0x24(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x7be0
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
leaq -0x34(%rbp), %rcx
leaq -0x38(%rbp), %r8
callq 0x7d70
movq -0x8(%rbp), %rax
addq $0x30, %rax
movslq -0x24(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x80ec
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x81ce
movl $0xfffffffe, -0x40(%rbp) # imm = 0xFFFFFFFE
movq -0x68(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x81cc
movq -0x68(%rbp), %rax
cmpl $0x1, 0x18(%rax)
je 0x81cc
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
je 0x81cc
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl 0x8(%rax,%rcx,8), %eax
movl %eax, -0x4c(%rbp)
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl 0xc(%rax,%rcx,8), %eax
movl %eax, -0x58(%rbp)
jmp 0x81ce
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x81fe
movl -0x30(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x82e0
movl $0xfffffffe, -0x44(%rbp) # imm = 0xFFFFFFFE
movq -0x68(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x82de
movq -0x68(%rbp), %rax
cmpl $0x1, 0x18(%rax)
je 0x82de
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x24(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
je 0x82de
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x24(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x24(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl 0x8(%rax,%rcx,8), %eax
movl %eax, -0x50(%rbp)
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x24(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl 0xc(%rax,%rcx,8), %eax
movl %eax, -0x5c(%rbp)
jmp 0x82e0
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x8343
cmpl $0x4, -0x2c(%rbp)
jl 0x8343
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x8339
movl -0x2c(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x8341
movq $0x0, -0x68(%rbp)
jmp 0x8388
cmpl $0x0, -0x30(%rbp)
jge 0x8364
movl -0x30(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x8386
cmpl $0x4, -0x2c(%rbp)
jge 0x837c
cmpl $0x2, -0x2c(%rbp)
jne 0x8384
cmpl $0x0, -0x30(%rbp)
je 0x837c
cmpl $0x2, -0x30(%rbp)
jne 0x8384
movq $0x0, -0x68(%rbp)
jmp 0x8386
jmp 0x8388
cmpq $0x0, -0x68(%rbp)
jne 0x844f
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x840a
cmpl $0x0, -0x2c(%rbp)
jge 0x840a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, (%rax)
je 0x8400
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x8400
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
addq $-0xf88, %rax           # imm = 0xF078
movq %rax, -0x68(%rbp)
jmp 0x8408
movq $0x0, -0x68(%rbp)
jmp 0x844d
cmpl $0x0, -0x30(%rbp)
jge 0x842b
movl -0x30(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x844b
cmpl $0x0, -0x2c(%rbp)
jge 0x8449
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x844b
jmp 0x844d
jmp 0x844f
cmpq $0x0, -0x68(%rbp)
je 0x8531
movl $0xfffffffe, -0x48(%rbp) # imm = 0xFFFFFFFE
movq -0x68(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x852f
movq -0x68(%rbp), %rax
cmpl $0x1, 0x18(%rax)
je 0x852f
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
je 0x852f
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl 0x8(%rax,%rcx,8), %eax
movl %eax, -0x54(%rbp)
movq -0x68(%rbp), %rax
addq $0x30, %rax
movslq -0x2c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movl 0xc(%rax,%rcx,8), %eax
movl %eax, -0x60(%rbp)
jmp 0x8531
movq -0x8(%rbp), %rax
cmpl $0xe, 0x1c(%rax)
jne 0x8561
cmpl $0x0, -0x10(%rbp)
jne 0x8561
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x8561
movl -0x50(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x5c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x871a
movq -0x8(%rbp), %rax
cmpl $0xe, 0x1c(%rax)
jne 0x8591
cmpl $0x1, -0x10(%rbp)
jne 0x8591
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x8591
movl -0x4c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x58(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x8718
movq -0x8(%rbp), %rax
cmpl $0xf, 0x1c(%rax)
jne 0x85c1
cmpl $0x0, -0x10(%rbp)
jne 0x85c1
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x85c1
movl -0x4c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x58(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x8716
movq -0x8(%rbp), %rax
cmpl $0xf, 0x1c(%rax)
jne 0x85f1
cmpl $0x1, -0x10(%rbp)
jne 0x85f1
movl -0x48(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x85f1
movl -0x54(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x60(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x8714
movl $0x0, -0x6c(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x8609
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x861a
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x862b
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
cmpl $0x1, -0x6c(%rbp)
jle 0x8663
movl -0x4c(%rbp), %edi
movl -0x50(%rbp), %esi
movl -0x54(%rbp), %edx
callq 0x8720
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x58(%rbp), %edi
movl -0x5c(%rbp), %esi
movl -0x60(%rbp), %edx
callq 0x8720
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x8712
cmpl $0x1, -0x6c(%rbp)
jne 0x86ba
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x8686
movl -0x4c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x58(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x86b8
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x86a3
movl -0x50(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x5c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x86b6
movl -0x54(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x60(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x86b8
jmp 0x8710
cmpl $-0x1, -0x44(%rbp)
jne 0x86e1
cmpl $-0x1, -0x48(%rbp)
jne 0x86e1
cmpl $-0x1, -0x40(%rbp)
je 0x86e1
movl -0x4c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x58(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x870e
movl -0x4c(%rbp), %edi
movl -0x50(%rbp), %esi
movl -0x54(%rbp), %edx
callq 0x8720
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x58(%rbp), %edi
movl -0x5c(%rbp), %esi
movl -0x60(%rbp), %edx
callq 0x8720
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x8710
jmp 0x8712
jmp 0x8714
jmp 0x8716
jmp 0x8718
jmp 0x871a
addq $0x70, %rsp
popq %rbp
retq