// File: /workspace/github_c_makefile_star2_O2/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
subq $0x28, %rsp
movl %ecx, %r15d
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, -0x40(%rbp)
leaq 0x7af2(%rip), %rdi      # 0x1b1b4
leaq 0xe29f(%rip), %rsi      # 0x21968
leaq 0xe83f(%rip), %rdx      # 0x21f0f
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x39ba
leaq -0x34(%rbp), %r8
movq %r14, %rdi
xorl %esi, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x103a0
leaq -0x44(%rbp), %r13
leaq -0x2c(%rbp), %r8
movq %r14, %rdi
movl %r12d, %esi
movl %r15d, %edx
movq %r13, %rcx
callq 0x104ec
movslq (%r13), %rax
testq %rax, %rax
jle 0x13717
leal -0x1(%rax), %edx
movq %r14, %rcx
jmp 0x13721
leal 0x3(%rax), %edx
movq 0x10(%r14), %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x1376e
movl 0x18(%rcx), %esi
cmpl $0x11, %esi
ja 0x1373e
movl $0x20023, %edi          # imm = 0x20023
btl %esi, %edi
movl $0x0, %r15d
jb 0x13771
movslq %edx, %rdx
imulq $0xa0, %rdx, %rdx
addq %rdx, %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x28, %rdx, %rdx
movl 0x48(%rdx,%rcx), %esi
movl 0x4c(%rdx,%rcx), %ecx
movl %esi, %ebx
negl %ebx
cmovsl %esi, %ebx
movl %ecx, %r15d
negl %r15d
cmovsl %ecx, %r15d
jmp 0x13771
xorl %r15d, %r15d
movl -0x2c(%rbp), %ecx
testl %ecx, %ecx
jle 0x1377c
decl %ecx
jmp 0x13787
addl $0x3, %ecx
movq 0x10(%r14), %rdx
movq 0x8(%rdx), %r14
testq %r14, %r14
je 0x1379f
movl 0x18(%r14), %edx
cmpl $0x11, %edx
ja 0x137f7
movl $0x20023, %esi          # imm = 0x20023
btl %edx, %esi
jae 0x137f7
cmpl $0x21, %ebx
pushq $0x1
popq %r14
movl %r14d, %edx
sbbl $-0x1, %edx
xorl %r12d, %r12d
cmpl $0x3, %ebx
cmovbl %r12d, %edx
movl -0x34(%rbp), %ecx
pushq $0x28
popq %rsi
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x13ca4
cmpl $0x21, %r15d
sbbl $-0x1, %r14d
cmpl $0x3, %r15d
cmovbl %r12d, %r14d
movl -0x30(%rbp), %ecx
pushq $0x2f
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x13ca4
imulq $0xa0, %rax, %rax
addq %rax, %r14
movslq %ecx, %rax
imulq $0x28, %rax, %rax
movl 0x48(%rax,%r14), %ecx
movl 0x4c(%rax,%r14), %eax
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
addl %edx, %ebx
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
addl %ecx, %r15d
jmp 0x1379f