// File: /workspace/github_c_makefile_star2_O0/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_process_macroblock
void plm_video_process_macroblock(
	plm_video_t *self, uint8_t *s, uint8_t *d,
	int motion_h, int motion_v, int block_size, int interpolate
) {
	int dw = self->mb_width * block_size;

	int hp = motion_h >> 1;
	int vp = motion_v >> 1;
	int odd_h = (motion_h & 1) == 1;
	int odd_v = (motion_v & 1) == 1;

	unsigned int si = ((self->mb_row * block_size) + vp) * dw + (self->mb_col * block_size) + hp;
	unsigned int di = (self->mb_row * dw + self->mb_col) * block_size;
	
	unsigned int max_address = (dw * (self->mb_height * block_size - block_size + 1) - block_size);
	if (si > max_address || di > max_address) {
		return; // corrupt video
	}

	#define PLM_MB_CASE(INTERPOLATE, ODD_H, ODD_V, OP) \
		case ((INTERPOLATE << 2) | (ODD_H << 1) | (ODD_V)): \
			PLM_BLOCK_SET(d, di, dw, si, dw, block_size, OP); \
			break

	switch ((interpolate << 2) | (odd_h << 1) | (odd_v)) {
		PLM_MB_CASE(0, 0, 0, (s[si]));
		PLM_MB_CASE(0, 0, 1, (s[si] + s[si + dw] + 1) >> 1);
		PLM_MB_CASE(0, 1, 0, (s[si] + s[si + 1] + 1) >> 1);
		PLM_MB_CASE(0, 1, 1, (s[si] + s[si + 1] + s[si + dw] + s[si + dw + 1] + 2) >> 2);

		PLM_MB_CASE(1, 0, 0, (d[di] + (s[si]) + 1) >> 1);
		PLM_MB_CASE(1, 0, 1, (d[di] + ((s[si] + s[si + dw] + 1) >> 1) + 1) >> 1);
		PLM_MB_CASE(1, 1, 0, (d[di] + ((s[si] + s[si + 1] + 1) >> 1) + 1) >> 1);
		PLM_MB_CASE(1, 1, 1, (d[di] + ((s[si] + s[si + 1] + s[si + dw] + s[si + dw + 1] + 2) >> 2) + 1) >> 1);
	}

	#undef PLM_MB_CASE
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
imull -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
sarl %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
sarl %eax
movl %eax, -0x30(%rbp)
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %eax
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x80(%rax), %eax
imull -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
imull -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x84(%rcx), %ecx
imull -0x24(%rbp), %ecx
addl %ecx, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movl 0x80(%rax), %eax
imull -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
addl 0x84(%rcx), %eax
imull -0x24(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x28(%rcx), %ecx
imull -0x24(%rbp), %ecx
subl -0x24(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
subl -0x24(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x44(%rbp), %eax
ja 0x749f
movl -0x40(%rbp), %eax
cmpl -0x44(%rbp), %eax
jbe 0x74a4
jmp 0x7b14
movl 0x10(%rbp), %eax
shll $0x2, %eax
movl -0x34(%rbp), %ecx
addl %ecx, %ecx
orl %ecx, %eax
movl -0x38(%rbp), %ecx
orl %ecx, %eax
movl %eax, %ecx
movq %rcx, -0xd0(%rbp)
subl $0x7, %eax
ja 0x7b14
movq -0xd0(%rbp), %rax
leaq 0x5b6a(%rip), %rcx      # 0xd040
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x74e1
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x755f
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7542
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x7509
movl -0x4c(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x48(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x74fa
jmp 0x7561
jmp 0x7b14
jmp 0x7568
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7600
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x75e3
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
addl -0x28(%rbp), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
addl $0x1, %eax
sarl %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x7590
movl -0x5c(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x58(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x7581
jmp 0x7602
jmp 0x7b14
jmp 0x7609
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x76a1
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7684
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
addl $0x1, %eax
sarl %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x7631
movl -0x6c(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x68(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x7622
jmp 0x76a3
jmp 0x7b14
jmp 0x76aa
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7780
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7760
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
addl -0x28(%rbp), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
addl -0x28(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
addl $0x2, %eax
sarl $0x2, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x76d9
movl -0x7c(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x78(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x76c3
jmp 0x7782
jmp 0x7b14
jmp 0x7789
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl $0x0, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7847
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x781b
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
addl $0x1, %eax
sarl %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x77c4
movl -0x8c(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x88(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x77ab
jmp 0x7849
jmp 0x7b14
jmp 0x7850
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7925
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x78f9
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movq -0x10(%rbp), %rdx
movl -0x3c(%rbp), %esi
addl -0x28(%rbp), %esi
movl %esi, %esi
movzbl (%rdx,%rsi), %edx
addl %edx, %ecx
addl $0x1, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x1, %eax
sarl %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x788b
movl -0x9c(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x98(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x7872
jmp 0x7927
jmp 0x7b14
jmp 0x792e
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0xac(%rbp)
movl $0x0, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7a03
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x79d7
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movq -0x10(%rbp), %rdx
movl -0x3c(%rbp), %esi
addl $0x1, %esi
movl %esi, %esi
movzbl (%rdx,%rsi), %edx
addl %edx, %ecx
addl $0x1, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x1, %eax
sarl %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x7969
movl -0xac(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0xa8(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x7950
jmp 0x7a05
jmp 0x7b14
jmp 0x7a0c
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl $0x0, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7b10
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7ae4
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x3c(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
movq -0x10(%rbp), %rdx
movl -0x3c(%rbp), %esi
addl $0x1, %esi
movl %esi, %esi
movzbl (%rdx,%rsi), %edx
addl %edx, %ecx
movq -0x10(%rbp), %rdx
movl -0x3c(%rbp), %esi
addl -0x28(%rbp), %esi
movl %esi, %esi
movzbl (%rdx,%rsi), %edx
addl %edx, %ecx
movq -0x10(%rbp), %rdx
movl -0x3c(%rbp), %esi
addl -0x28(%rbp), %esi
addl $0x1, %esi
movl %esi, %esi
movzbl (%rdx,%rsi), %edx
addl %edx, %ecx
addl $0x2, %ecx
sarl $0x2, %ecx
addl %ecx, %eax
addl $0x1, %eax
sarl %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x7a47
movl -0xbc(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0xb8(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x7a2e
jmp 0x7b12
jmp 0x7b14
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)