// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/./edge264_mvpred.c
// Function: decode_inter_16x8_bottom
static inline void decode_inter_16x8_bottom(Edge264Context *ctx, i16x8 mvd, int lx)
{
	// compare neighbouring indices and compute mvp
	i16x8 mvp;
	int refIdx = mb->refIdx[lx * 4 + 2];
	int refIdxA = mbA->refIdx[lx * 4 + 3];
	if (refIdx == refIdxA) {
		mvp = (i32x4){mbA->mvs_s[lx * 16 + 13]};
	} else {
		int refIdxB = mb->refIdx[lx * 4];
		int refIdxC = mbA->refIdx[lx * 4 + 1];
		if (refIdx == refIdxB) {
			mvp = (i32x4){mb->mvs_s[lx * 16]};
			if (refIdx == refIdxC) {
				i16x8 mvA = (i32x4){mbA->mvs_s[lx * 16 + 13]};
				i16x8 mvC = (i32x4){mbA->mvs_s[lx * 16 + 7]};
				mvp = median16(mvA, mvp, mvC);
			}
		} else {
			mvp = (i32x4){mbA->mvs_s[lx * 16 + 7]};
			if (refIdx != refIdxC) {
				i16x8 mvA = (i32x4){mbA->mvs_s[lx * 16 + 13]};
				i16x8 mvB = (i32x4){mb->mvs_s[lx * 16]};
				mvp = median16(mvA, mvB, mvp);
			}
		}
	}
	
	// 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 + 1] = pack_absMvd(mvd);
	mb->mvs_v[lx * 4 + 2] = mb->mvs_v[lx * 4 + 3] = mvs;
	decode_inter(ctx, lx * 16 + 8, 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
addl $0x2, %ecx
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x1f4(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movsbl 0x10(%rax,%rcx), %eax
movl %eax, -0x1f8(%rbp)
movl -0x1f4(%rbp), %eax
cmpl -0x1f8(%rbp), %eax
jne 0x20e1e
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xe4(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x210(%rbp)
vmovdqa -0x210(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
jmp 0x211da
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, -0x214(%rbp)
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, -0x218(%rbp)
movl -0x1f4(%rbp), %eax
cmpl -0x214(%rbp), %eax
jne 0x21035
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, -0x230(%rbp)
vmovdqa -0x230(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
movl -0x1f4(%rbp), %eax
cmpl -0x218(%rbp), %eax
jne 0x21030
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xe4(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x250(%rbp)
vmovdqa -0x250(%rbp), %xmm0
vmovdqa %xmm0, -0x240(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xcc(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x270(%rbp)
vmovdqa -0x270(%rbp), %xmm0
vmovdqa %xmm0, -0x260(%rbp)
vmovdqa -0x240(%rbp), %xmm2
vmovdqa -0x1f0(%rbp), %xmm1
vmovdqa -0x260(%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 0x211d8
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xcc(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x280(%rbp)
vmovdqa -0x280(%rbp), %xmm0
vmovdqa %xmm0, -0x1f0(%rbp)
movl -0x1f4(%rbp), %eax
cmpl -0x218(%rbp), %eax
je 0x211d6
movq -0x1b8(%rbp), %rax
movq 0x688(%rax), %rax
movl -0x1d4(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
vmovd 0xe4(%rax,%rcx,4), %xmm0
vmovdqa %xmm0, -0x2a0(%rbp)
vmovdqa -0x2a0(%rbp), %xmm0
vmovdqa %xmm0, -0x290(%rbp)
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, -0x2c0(%rbp)
vmovdqa -0x2c0(%rbp), %xmm0
vmovdqa %xmm0, -0x2b0(%rbp)
vmovdqa -0x290(%rbp), %xmm2
vmovdqa -0x2b0(%rbp), %xmm1
vmovdqa -0x1f0(%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 0x211d8
jmp 0x211da
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
addl $0x1, %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 $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 $0x2, %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 $0x8, %esi
movl $0x10, %edx
movl $0x8, %ecx
callq 0x21380
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
nopw (%rax,%rax)