// File: /workspace/github_c_makefile_star2_O2/tvlabs[P]edge264/./edge264_mvpred.c
// Function: decode_inter_16x16
static inline void decode_inter_16x16(Edge264Context *ctx, i16x8 mvd, int lx)
{
	// compare neighbouring indices and compute mvp
	int refIdx = mb->refIdx[lx * 4];
	int refIdxA = mbA->refIdx[lx * 4 + 1];
	int refIdxB = mbB->refIdx[lx * 4 + 2];
	int eqA = refIdx == refIdxA;
	int refIdxC;
	i16x8 mvp;
	if (__builtin_expect(ctx->unavail4x4[5] & 4, 0)) {
		refIdxC = mbD->refIdx[lx * 4 + 3];
		mvp = (i32x4){mbD->mvs_s[lx * 16 + 15]};
		eqA |= ctx->unavail4x4[0] == 14;
	} else {
		refIdxC = mbC->refIdx[lx * 4 + 2];
		mvp = (i32x4){mbC->mvs_s[lx * 16 + 10]};
	}
	int eq = eqA + (refIdx==refIdxB) * 2 + (refIdx==refIdxC) * 4;
	if (__builtin_expect(0xe9 >> eq & 1, 1)) {
		i16x8 mvA = (i32x4){mbA->mvs_s[lx * 16 + 5]};
		i16x8 mvB = (i32x4){mbB->mvs_s[lx * 16 + 10]};
		mvp = median16(mvA, mvB, mvp);
	} else if (eq == 1) {
		mvp = (i32x4){mbA->mvs_s[lx * 16 + 5]};
	} else if (eq == 2) {
		mvp = (i32x4){mbB->mvs_s[lx * 16 + 10]};
	}
	
	// sum mvp and mvd, broadcast everything to memory and tail-jump to decoding
	i16x8 mv = mvp + mvd;
	i16x8 mvs = broadcast32(mv, 0);
	mb->absMvd_v[lx * 2] = mb->absMvd_v[lx * 2 + 1] = pack_absMvd(mvd);
	mb->mvs_v[lx * 4] = mb->mvs_v[lx * 4 + 1] = mb->mvs_v[lx * 4 + 2] = mb->mvs_v[lx * 4 + 3] = mvs;
	decode_inter(ctx, lx * 16, 16, 16);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x680(%rdi), %r9
movq 0x688(%rdi), %r10
movl %esi, %ecx
movb 0x10(%r9,%rcx,4), %al
shlq $0x2, %rcx
movl %ecx, %edx
movb 0x11(%r10,%rdx), %r14b
movq 0x690(%rdi), %r11
leaq 0x2(%rdx), %r8
movb 0x12(%r11,%rdx), %bl
cmpb %r14b, %al
sete %bpl
testb $0x4, 0x6d5(%rdi)
jne 0xc4a8
movq 0x698(%rdi), %r15
leaq (%r15,%r8), %r14
addq $0x10, %r14
movl %esi, %r12d
shll $0x4, %r12d
vmovd 0xd8(%r15,%r12,4), %xmm1
incq %rdx
movzbl %bpl, %r15d
xorl %r12d, %r12d
cmpb %bl, %al
sete %r12b
leal (%r15,%r12,2), %ebx
xorl %r15d, %r15d
cmpb (%r14), %al
sete %r15b
leal (%rbx,%r15,4), %eax
movl $0xe9, %ebx
btl %eax, %ebx
jae 0xc4e4
movl %esi, %eax
shll $0x4, %eax
vmovd 0xc4(%r10,%rax,4), %xmm2
vmovd 0xd8(%r11,%rax,4), %xmm3
vpmaxsw %xmm3, %xmm2, %xmm4
vpminsw %xmm1, %xmm4, %xmm1
vpminsw %xmm3, %xmm2, %xmm2
vpmaxsw %xmm2, %xmm1, %xmm1
vpaddw %xmm0, %xmm1, %xmm1
vpbroadcastd %xmm1, %xmm1
vpbroadcastd %xmm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpabsb %xmm0, %xmm0
movl %esi, %r10d
leal 0x1(,%rsi,2), %esi
shlq $0x4, %rsi
vmovdqa %xmm0, 0x70(%r9,%rsi)
addl %r10d, %r10d
movq 0x680(%rdi), %rsi
shlq $0x4, %r10
vmovdqa %xmm0, 0x70(%rsi,%r10)
movq 0x680(%rdi), %rsi
movl %ecx, %r9d
orl $0x3, %r9d
shlq $0x4, %r9
vmovdqa %xmm1, 0xb0(%rsi,%r9)
movq 0x680(%rdi), %rsi
shlq $0x4, %r8
vmovdqa %xmm1, 0xb0(%rsi,%r8)
movq 0x680(%rdi), %rsi
shlq $0x4, %rdx
vmovdqa %xmm1, 0xb0(%rsi,%rdx)
movq 0x680(%rdi), %rdx
shlq $0x4, %rcx
vmovdqa %xmm1, 0xb0(%rdx,%rcx)
movl $0x10, %ecx
movl %eax, %esi
movl %ecx, %edx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcabd
cmpb %r14b, %al
sete %r15b
movq 0x6a0(%rdi), %r12
movl %ecx, %r14d
addq %r12, %r14
addq $0x13, %r14
movl %esi, %r13d
shll $0x4, %r13d
vmovd 0xec(%r12,%r13,4), %xmm1
cmpb $0xe, 0x6d0(%rdi)
sete %bpl
orb %r15b, %bpl
jmp 0xc39d
cmpl $0x1, %eax
je 0xc502
cmpl $0x2, %eax
jne 0xc516
movl %esi, %eax
shll $0x4, %eax
vmovd 0xd8(%r11,%rax,4), %xmm1
jmp 0xc3f6
movl %esi, %eax
shll $0x4, %eax
vmovd 0xc4(%r10,%rax,4), %xmm1
jmp 0xc3f6
movl %esi, %eax
shll $0x4, %eax
jmp 0xc3f6