// File: /workspace/github_c_makefile_star2_O3/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, %r15d
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xb844(%rip), %rdi      # 0x271b4
leaq 0x11ded(%rip), %rsi     # 0x2d764
leaq 0x1238d(%rip), %rdx     # 0x2dd0b
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x4a56
leaq -0x30(%rbp), %r8
movq %r14, %rdi
xorl %esi, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x16c28
movl 0x1c(%r14), %eax
cmpl $0xd, %eax
je 0x1b9c1
cmpl $0xf, %eax
je 0x1b9b7
cmpl $0xe, %eax
jne 0x1ba06
addl %r12d, %r12d
movl %r12d, %eax
jmp 0x1ba35
addl %r12d, %r12d
xorl %eax, %eax
movl %r12d, %r13d
jmp 0x1ba27
movl %r12d, %eax
shrl $0x1f, %eax
addl %r12d, %eax
andl $-0x2, %eax
movslq %r12d, %rcx
subl %eax, %r12d
movl %r12d, %r13d
addl %r13d, %r13d
movl 0x20(%r14,%rcx,4), %ecx
cmpl $0xa, %ecx
ja 0x1ba27
movl $0x111, %edx            # imm = 0x111
btl %ecx, %edx
jb 0x1ba0a
movl $0x222, %edx            # imm = 0x222
btl %ecx, %edx
jb 0x1ba24
movl $0x444, %edx            # imm = 0x444
btl %ecx, %edx
jae 0x1ba27
addl %r15d, %r13d
jmp 0x1ba27
xorl %eax, %eax
jmp 0x1ba35
movl %r15d, %ecx
shrl $0x1f, %ecx
addl %r15d, %ecx
movl %ecx, %edx
andl $-0x2, %edx
subl %edx, %r15d
addl %r15d, %r13d
sarl %ecx
addl %ecx, %eax
jmp 0x1ba27
addl %r15d, %eax
testl %r13d, %r13d
jle 0x1ba35
leal -0x1(%r13), %edx
movq %r14, %rcx
jmp 0x1ba45
movq 0x10(%r14), %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x1ba5f
leal 0x3(%r13), %edx
movl 0x18(%rcx), %esi
cmpl $0x11, %esi
ja 0x1bb21
movl $0x20023, %edi          # imm = 0x20023
btl %esi, %edi
jae 0x1bb21
xorl %ecx, %ecx
xorl %r15d, %r15d
testl %eax, %eax
jle 0x1ba6c
decl %eax
jmp 0x1ba7c
movq 0x10(%r14), %rdx
movq 0x8(%rdx), %r14
testq %r14, %r14
je 0x1ba8f
addl $0x3, %eax
movl 0x18(%r14), %edx
cmpl $0x11, %edx
ja 0x1baeb
movl $0x20023, %esi          # imm = 0x20023
btl %edx, %esi
jae 0x1baeb
cmpl $0x21, %ecx
movl $0x1, %r14d
movl $0x1, %edx
sbbl $-0x1, %edx
xorl %r12d, %r12d
cmpl $0x3, %ecx
cmovbl %r12d, %edx
movl -0x30(%rbp), %ecx
movq %rbx, %rdi
movl $0x28, %esi
callq 0x1be79
cmpl $0x21, %r15d
sbbl $-0x1, %r14d
cmpl $0x3, %r15d
cmovbl %r12d, %r14d
movl -0x2c(%rbp), %ecx
movq %rbx, %rdi
movl $0x2f, %esi
movl %r14d, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1be79
movslq %r13d, %rdx
leaq (%rdx,%rdx,4), %rdx
shlq $0x5, %rdx
addq %rdx, %r14
cltq
leaq (%rax,%rax,4), %rax
movl 0x48(%r14,%rax,8), %edx
movl 0x4c(%r14,%rax,8), %eax
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
addl %esi, %ecx
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
addl %edx, %r15d
jmp 0x1ba8f
movslq %edx, %rdx
leaq (%rdx,%rdx,4), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq %eax, %rdx
leaq (%rdx,%rdx,4), %rdx
movl 0x48(%rcx,%rdx,8), %esi
movl 0x4c(%rcx,%rdx,8), %edx
movl %esi, %ecx
negl %ecx
cmovsl %esi, %ecx
movl %edx, %r15d
negl %r15d
cmovsl %edx, %r15d
jmp 0x1ba64