// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/./edge264_mvpred.c
// Function: decode_inter_16x8_top
static inline void decode_inter_16x8_top(Edge264Context *ctx, i16x8 mvd, int lx)
{
	// compare neighbouring indices and compute mvp
	i16x8 mvp, mvC;
	int refIdx = mb->refIdx[lx * 4];
	int refIdxB = mbB->refIdx[lx * 4 + 2];
	if (refIdx == refIdxB) {
		mvp = (i32x4){mbB->mvs_s[lx * 16 + 10]};
	} else {
		int refIdxA = mbA->refIdx[lx * 4 + 1];
		int eqA = refIdx == refIdxA;
		int refIdxC;
		if (__builtin_expect(ctx->unavail4x4[5] & 4, 0)) {
			refIdxC = mbD->refIdx[lx * 4 + 3];
			mvC = (i32x4){mbD->mvs_s[lx * 16 + 15]};
			eqA |= ctx->unavail4x4[0] == 14;
		} else {
			refIdxC = mbC->refIdx[lx * 4 + 2];
			mvC = (i32x4){mbC->mvs_s[lx * 16 + 10]};
		}
		if (refIdx == refIdxC) {
			mvp = mvC;
			if (eqA) {
				i16x8 mvA = (i32x4){mbA->mvs_s[lx * 16 + 5]};
				i16x8 mvB = (i32x4){mbB->mvs_s[lx * 16 + 10]};
				mvp = median16(mvA, mvB, mvp);
			}
		} else { // refIdx != refIdxB/C
			mvp = (i32x4){mbA->mvs_s[lx * 16 + 5]};
			if (!eqA) {
				i16x8 mvB = (i32x4){mbB->mvs_s[lx * 16 + 10]};
				mvp = median16(mvp, mvB, mvC);
			}
		}
	}
	
	// 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] = pack_absMvd(mvd);
	mb->mvs_v[lx * 4 + 0] = mb->mvs_v[lx * 4 + 1] = mvs;
	decode_inter(ctx, lx * 16, 16, 8);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
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
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x204(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x208(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x208(%rbp), %eax
jne 0x207eb
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xd8(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x220(%rbp)
vmovdqa -0x220(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
jmp 0x20c30
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x224(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x224(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x228(%rbp)
movq -0x1b8(%rbp), %rax
movsbl 0x6d5(%rax), %eax
andl $0x4, %eax
cltq
cmpq $0x0, %rax
je 0x208d1
movq -0x1b8(%rbp), %rax
movq 0x6a0(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsbl 0x13(%rax,%rcx), %eax
movl %eax, -0x22c(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x6a0(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xec(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x240(%rbp)
vmovdqa -0x240(%rbp), %xmm0
vmovdqa %xmm0, -0x200(%rbp)
movq -0x1b8(%rbp), %rax
movsbl 0x6d0(%rax), %eax
cmpl $0xe, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
orl -0x228(%rbp), %eax
movl %eax, -0x228(%rbp)
jmp 0x20931
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, -0x22c(%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, -0x250(%rbp)
vmovdqa -0x250(%rbp), %xmm0
vmovdqa %xmm0, -0x200(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x22c(%rbp), %eax
jne 0x20acb
vmovdqa -0x200(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
cmpl $0x0, -0x228(%rbp)
je 0x20ac6
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xc4(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x270(%rbp)
vmovdqa -0x270(%rbp), %xmm0
vmovdqa %xmm0, -0x260(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xd8(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x290(%rbp)
vmovdqa -0x290(%rbp), %xmm0
vmovdqa %xmm0, -0x280(%rbp)
vmovdqa -0x260(%rbp), %xmm2
vmovdqa -0x280(%rbp), %xmm1
vmovdqa -0x1f0(%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 0x20c2e
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xc4(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x2a0(%rbp)
vmovdqa -0x2a0(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
cmpl $0x0, -0x228(%rbp)
jne 0x20c2c
movq -0x1b8(%rbp), %rax
movq 0x690(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xd8(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x2c0(%rbp)
vmovdqa -0x2c0(%rbp), %xmm0
vmovdqa %xmm0, -0x2b0(%rbp)
vmovdqa -0x1f0(%rbp), %xmm2
vmovdqa -0x2b0(%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 0x20c2e
jmp 0x20c30
vmovdqa -0x1f0(%rbp), %xmm0
vmovdqa -0x1d0(%rbp), %xmm1
vpaddw %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x2d0(%rbp)
vpbroadcastd -0x2d0(%rbp), %xmm0
vmovdqa %xmm0, -0x2e0(%rbp)
vmovdqa -0x1d0(%rbp), %xmm0
vmovdqa %xmm0, -0x40(%rbp)
vpbroadcastd -0x40(%rbp), %xmm0
vmovdqa %xmm0, -0x50(%rbp)
vmovdqa -0x50(%rbp), %xmm1
vmovdqa -0x50(%rbp), %xmm0
vmovdqa %xmm1, -0x20(%rbp)
vmovdqa %xmm0, -0x30(%rbp)
vmovdqa -0x20(%rbp), %xmm0
vmovdqa -0x30(%rbp), %xmm1
vpacksswb %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x10(%rbp)
vmovdqa -0x10(%rbp), %xmm0
vpabsb %xmm0, %xmm0
movq -0x1b8(%rbp), %rax
movq 0x680(%rax), %rax
addq $0x70, %rax
movl -0x1d4(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vmovdqa %xmm0, (%rax)
vmovdqa -0x2e0(%rbp), %xmm0
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), %rax
movq 0x680(%rax), %rax
addq $0xb0, %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
vmovdqa %xmm0, (%rax)
movq -0x1b8(%rbp), %rdi
movl -0x1d4(%rbp), %esi
shll $0x4, %esi
movl $0x10, %edx
movl $0x8, %ecx
callq 0x21380
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
nopw (%rax,%rax)