// File: /workspace/github_c_makefile_star2_O1/akumrao[P]videoAnalyzer/encoder/macroblock.c
// Function: x264_cabac_mb_mv(x264_t*, x264_macroblock_t*, int, int, int)
static void x264_cabac_mb_mv(x264_t *h, x264_macroblock_t *mb, int i_list, int i_part, int i_sub) {LOG_CALL;
    x264_macroblock_t *mbn;

    int mvd[2];
    int x, y, xn, yn;
    int i_ctxIdxInc;

    int i_absmv0 = 0;
    int i_absmv1 = 0;

    /* get and update mvd */
    x264_mb_partition_mvd(mb, i_list, i_part, i_sub, mvd);

    /* get context */
    x264_mb_partition_getxy(mb, i_part, i_sub, &x, &y);

    /* FIXME not complete for B frame (B_DIRECT and B_DIRECT 8x8 sub */
    /* Left  pixel (-1,0)*/
    xn = x - 1;
    mbn = mb;
    if (xn < 0)
    {
        xn += 4;
        mbn = mb->context->mba;
    }
    if (mbn && !IS_INTRA(mbn->i_type) && !IS_SKIP(mbn->i_type))
    {
        i_absmv0 += abs(mbn->partition[xn][y].mvd[i_list][0]);
        i_absmv1 += abs(mbn->partition[xn][y].mvd[i_list][1]);
    }

    /* Up ( pixel(0,-1)*/
    yn = y - 1;
    mbn = mb;
    if (yn < 0)
    {
        yn += 4;
        mbn = mb->context->mbb;
    }
    if (mbn && !IS_INTRA(mbn->i_type) && !IS_SKIP(mbn->i_type))
    {
        i_absmv0 += abs(mbn->partition[x][yn].mvd[i_list][0]);
        i_absmv1 += abs(mbn->partition[x][yn].mvd[i_list][1]);
    }

    /* x component */
    if (i_absmv0 < 3)
    {
        i_ctxIdxInc = 0;
    } else if (i_absmv0 > 32)
    {
        i_ctxIdxInc = 2;
    } else
    {
        i_ctxIdxInc = 1;
    }

    x264_cabac_mb_mvd(h, 40, i_ctxIdxInc, mvd[0]);

    /* y component */
    if (i_absmv1 < 3)
    {
        i_ctxIdxInc = 0;
    } else if (i_absmv1 > 32)
    {
        i_ctxIdxInc = 2;
    } else
    {
        i_ctxIdxInc = 1;
    }
    x264_cabac_mb_mvd(h, 47, i_ctxIdxInc, mvd[1]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r12d
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xa565(%rip), %rdi      # 0x251b4
leaq 0x10dc2(%rip), %rsi     # 0x2ba18
leaq 0x11362(%rip), %rdx     # 0x2bfbf
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x4c22
leaq -0x30(%rbp), %r8
movq %r14, %rdi
xorl %esi, %esi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x16644
movl 0x1c(%r14), %eax
cmpl $0xd, %eax
je 0x1ac9e
cmpl $0xf, %eax
je 0x1ac99
cmpl $0xe, %eax
jne 0x1ac94
movl %r15d, %r13d
addl %r15d, %r13d
xorl %r15d, %r15d
jmp 0x1ad00
addl %r15d, %r15d
jmp 0x1ad00
movl %r15d, %r13d
shrl $0x1f, %r13d
addl %r15d, %r13d
andl $-0x2, %r13d
movslq %r15d, %rax
subl %r13d, %r15d
addl %r15d, %r15d
movl 0x20(%r14,%rax,4), %eax
cmpl $0xa, %eax
ja 0x1ad00
movl $0x111, %ecx            # imm = 0x111
btl %eax, %ecx
jb 0x1ace2
movl $0x222, %ecx            # imm = 0x222
btl %eax, %ecx
jb 0x1acfd
movl $0x444, %ecx            # imm = 0x444
btl %eax, %ecx
jae 0x1ad00
addl %r12d, %r15d
jmp 0x1ad00
movl %r12d, %eax
shrl $0x1f, %eax
addl %r12d, %eax
movl %eax, %ecx
andl $-0x2, %ecx
subl %ecx, %r12d
addl %r12d, %r15d
sarl %eax
addl %eax, %r13d
jmp 0x1ad00
addl %r12d, %r13d
testl %r15d, %r15d
jle 0x1ad0e
leal -0x1(%r15), %edx
movq %r14, %rcx
jmp 0x1ad19
leal 0x3(%r15), %edx
movq 0x10(%r14), %rax
movq (%rax), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x1ad68
movl 0x18(%rcx), %esi
cmpl $0x11, %esi
ja 0x1ad38
movl $0x20023, %edi          # imm = 0x20023
btl %esi, %edi
movl $0x0, %r12d
jb 0x1ad6b
movslq %edx, %rax
leaq (%rax,%rax,4), %rax
shlq $0x5, %rax
addq %rax, %rcx
movslq %r13d, %rax
leaq (%rax,%rax,4), %rax
movl 0x48(%rcx,%rax,8), %edx
movl 0x4c(%rcx,%rax,8), %ecx
movl %edx, %eax
negl %eax
cmovsl %edx, %eax
movl %ecx, %r12d
negl %r12d
cmovsl %ecx, %r12d
jmp 0x1ad6b
xorl %r12d, %r12d
testl %r13d, %r13d
jle 0x1ad75
decl %r13d
jmp 0x1ad81
addl $0x3, %r13d
movq 0x10(%r14), %rcx
movq 0x8(%rcx), %r14
testq %r14, %r14
je 0x1ad99
movl 0x18(%r14), %ecx
cmpl $0x11, %ecx
ja 0x1adee
movl $0x20023, %edx          # imm = 0x20023
btl %ecx, %edx
jae 0x1adee
xorl %edx, %edx
cmpl $0x21, %eax
setge %dl
incl %edx
xorl %r14d, %r14d
cmpl $0x3, %eax
cmovll %r14d, %edx
movl -0x30(%rbp), %ecx
movq %rbx, %rdi
movl $0x28, %esi
callq 0x1b16f
xorl %edx, %edx
cmpl $0x21, %r12d
setge %dl
incl %edx
cmpl $0x3, %r12d
cmovll %r14d, %edx
movl -0x2c(%rbp), %ecx
movq %rbx, %rdi
movl $0x2f, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1b16f
movslq %r15d, %rcx
leaq (%rcx,%rcx,4), %rcx
shlq $0x5, %rcx
addq %rcx, %r14
movslq %r13d, %rcx
leaq (%rcx,%rcx,4), %rcx
movl 0x48(%r14,%rcx,8), %edx
movl 0x4c(%r14,%rcx,8), %ecx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
addl %esi, %eax
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
addl %edx, %r12d
jmp 0x1ad99