// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/./edge264_mvpred.c
// Function: decode_inter_8x16_right
static inline void decode_inter_8x16_right(Edge264Context *ctx, i16x8 mvd, int lx)
{
	// compare neighbouring indices and compute mvp
	i16x8 mvp, mvC;
	int refIdx = mb->refIdx[lx * 4 + 1];
	int refIdxC;
	if (__builtin_expect(ctx->unavail4x4[5] & 4, 0)) {
		refIdxC = mbB->refIdx[lx * 4 + 2];
		mvC = (i32x4){mbB->mvs_s[lx * 16 + 11]};
	} else {
		refIdxC = mbC->refIdx[lx * 4 + 2];
		mvC = (i32x4){mbC->mvs_s[lx * 16 + 10]};
	}
	if (refIdx == refIdxC) {
		mvp = mvC;
	} else {
		int refIdxA = mb->refIdx[lx * 4];
		int refIdxB = mbB->refIdx[lx * 4 + 3];
		if (refIdx == refIdxB) {
			mvp = (i32x4){mbB->mvs_s[lx * 16 + 14]};
			if (refIdx == refIdxA) {
				i16x8 mvA = (i32x4){mb->mvs_s[lx * 16]};
				mvp = median16(mvA, mvp, mvC);
			}
		} else { // refIdx != B/C
			mvp = (i32x4){mb->mvs_s[lx * 16]};
			if (refIdx != refIdxA && ctx->unavail4x4[5] != 14) {
				i16x8 mvB = (i32x4){mbB->mvs_s[lx * 16 + 14]};
				mvp = median16(mvp, mvB, mvC);
			}
		}
	}
	
	// sum mvp and mvd, broadcast everything to memory and call decoding
	i16x8 mv = mvp + mvd;
	i16x8 mvs = broadcast32(mv, 0);
	mb->absMvd_l[lx * 4 + 1] = mb->absMvd_l[lx * 4 + 3] = ((i64x2)pack_absMvd(mvd))[0];
	mb->mvs_v[lx * 4 + 1] = mb->mvs_v[lx * 4 + 3] = mvs;
	decode_inter(ctx, lx * 16 + 4, 8, 16);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x1b8(%rbp)
vmovdqa %xmm0, -0x1d0(%rbp)
movl %esi, -0x1d4(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x204(%rbp)
movq -0x1b8(%rbp), %rax
movsbl 0x6d5(%rax), %eax
andl $0x4, %eax
cltq
cmpq $0x0, %rax
je 0x20203
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsbl 0x12(%rax,%rcx), %eax
movl %eax, -0x208(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xdc(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x220(%rbp)
vmovdqa -0x220(%rbp), %xmm0
vmovdqa %xmm0, -0x200(%rbp)
jmp 0x20263
movq -0x1b8(%rbp), %rax
movq 0x698(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsbl 0x12(%rax,%rcx), %eax
movl %eax, -0x208(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x698(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xd8(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x230(%rbp)
vmovdqa -0x230(%rbp), %xmm0
vmovdqa %xmm0, -0x200(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x208(%rbp), %eax
jne 0x20286
vmovdqa -0x200(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
jmp 0x205e3
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x234(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x238(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x238(%rbp), %eax
jne 0x20462
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xe8(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x250(%rbp)
vmovdqa -0x250(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x234(%rbp), %eax
jne 0x2045d
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xb0(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x270(%rbp)
vmovdqa -0x270(%rbp), %xmm0
vmovdqa %xmm0, -0x260(%rbp)
vmovdqa -0x260(%rbp), %xmm2
vmovdqa -0x1f0(%rbp), %xmm1
vmovdqa -0x200(%rbp), %xmm0
vmovdqa %xmm2, -0x160(%rbp)
vmovdqa %xmm1, -0x170(%rbp)
vmovdqa %xmm0, -0x180(%rbp)
vmovdqa -0x160(%rbp), %xmm1
vmovdqa -0x170(%rbp), %xmm0
vmovdqa %xmm1, -0x120(%rbp)
vmovdqa %xmm0, -0x130(%rbp)
vmovdqa -0x120(%rbp), %xmm0
vmovdqa -0x130(%rbp), %xmm1
vpmaxsw %xmm1, %xmm0, %xmm1
vmovdqa -0x180(%rbp), %xmm0
vmovdqa %xmm1, -0xa0(%rbp)
vmovdqa %xmm0, -0xb0(%rbp)
vmovdqa -0xa0(%rbp), %xmm0
vmovdqa -0xb0(%rbp), %xmm1
vpminsw %xmm1, %xmm0, %xmm1
vmovdqa -0x160(%rbp), %xmm2
vmovdqa -0x170(%rbp), %xmm0
vmovdqa %xmm2, -0xc0(%rbp)
vmovdqa %xmm0, -0xd0(%rbp)
vmovdqa -0xc0(%rbp), %xmm0
vmovdqa -0xd0(%rbp), %xmm2
vpminsw %xmm2, %xmm0, %xmm0
vmovdqa %xmm1, -0x140(%rbp)
vmovdqa %xmm0, -0x150(%rbp)
vmovdqa -0x140(%rbp), %xmm0
vmovdqa -0x150(%rbp), %xmm1
vpmaxsw %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
jmp 0x205e1
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xb0(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x280(%rbp)
vmovdqa -0x280(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x234(%rbp), %eax
je 0x205df
movq -0x1b8(%rbp), %rax
movsbl 0x6d5(%rax), %eax
cmpl $0xe, %eax
je 0x205df
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xe8(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x2a0(%rbp)
vmovdqa -0x2a0(%rbp), %xmm0
vmovdqa %xmm0, -0x290(%rbp)
vmovdqa -0x1f0(%rbp), %xmm2
vmovdqa -0x290(%rbp), %xmm1
vmovdqa -0x200(%rbp), %xmm0
vmovdqa %xmm2, -0x190(%rbp)
vmovdqa %xmm1, -0x1a0(%rbp)
vmovdqa %xmm0, -0x1b0(%rbp)
vmovdqa -0x190(%rbp), %xmm1
vmovdqa -0x1a0(%rbp), %xmm0
vmovdqa %xmm1, -0xe0(%rbp)
vmovdqa %xmm0, -0xf0(%rbp)
vmovdqa -0xe0(%rbp), %xmm0
vmovdqa -0xf0(%rbp), %xmm1
vpmaxsw %xmm1, %xmm0, %xmm1
vmovdqa -0x1b0(%rbp), %xmm0
vmovdqa %xmm1, -0x60(%rbp)
vmovdqa %xmm0, -0x70(%rbp)
vmovdqa -0x60(%rbp), %xmm0
vmovdqa -0x70(%rbp), %xmm1
vpminsw %xmm1, %xmm0, %xmm1
vmovdqa -0x190(%rbp), %xmm2
vmovdqa -0x1a0(%rbp), %xmm0
vmovdqa %xmm2, -0x80(%rbp)
vmovdqa %xmm0, -0x90(%rbp)
vmovdqa -0x80(%rbp), %xmm0
vmovdqa -0x90(%rbp), %xmm2
vpminsw %xmm2, %xmm0, %xmm0
vmovdqa %xmm1, -0x100(%rbp)
vmovdqa %xmm0, -0x110(%rbp)
vmovdqa -0x100(%rbp), %xmm0
vmovdqa -0x110(%rbp), %xmm1
vpmaxsw %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
jmp 0x205e1
jmp 0x205e3
vmovdqa -0x1f0(%rbp), %xmm0
vmovdqa -0x1d0(%rbp), %xmm1
vpaddw %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x2b0(%rbp)
vpbroadcastd -0x2b0(%rbp), %xmm0
vmovdqa %xmm0, -0x2c0(%rbp)
vmovdqa -0x1d0(%rbp), %xmm0
vmovdqa %xmm0, -0x40(%rbp)
vpbroadcastd -0x40(%rbp), %xmm0
vmovdqa %xmm0, -0x50(%rbp)
vmovdqa -0x50(%rbp), %xmm0
vmovdqa %xmm0, -0x20(%rbp)
vmovdqa %xmm0, -0x30(%rbp)
vmovdqa -0x20(%rbp), %xmm0
vmovdqa -0x30(%rbp), %xmm1
vpacksswb %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x10(%rbp)
vpabsb -0x10(%rbp), %xmm0
vmovq %xmm0, %rdx
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movq %rdx, 0x70(%rax,%rcx,8)
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, 0x70(%rax,%rcx,8)
vmovdqa -0x2c0(%rbp), %xmm0
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
addq $0xb0, %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vmovdqa %xmm0, (%rax)
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
addq $0xb0, %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vmovdqa %xmm0, (%rax)
movq -0x1b8(%rbp), %rdi
movl -0x1d4(%rbp), %esi
shll $0x4, %esi
addl $0x4, %esi
movl $0x8, %edx
movl $0x10, %ecx
callq 0x21380
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
nopl (%rax,%rax)