// File: /workspace/github_c_makefile_star2_O3/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_idct
void plm_video_idct(int *block) {
	int
		b1, b3, b4, b6, b7, tmp1, tmp2, m0,
		x0, x1, x2, x3, x4, y3, y4, y5, y6, y7;

	// Transform columns
	for (int i = 0; i < 8; ++i) {
		b1 = block[4 * 8 + i];
		b3 = block[2 * 8 + i] + block[6 * 8 + i];
		b4 = block[5 * 8 + i] - block[3 * 8 + i];
		tmp1 = block[1 * 8 + i] + block[7 * 8 + i];
		tmp2 = block[3 * 8 + i] + block[5 * 8 + i];
		b6 = block[1 * 8 + i] - block[7 * 8 + i];
		b7 = tmp1 + tmp2;
		m0 = block[0 * 8 + i];
		x4 = ((b6 * 473 - b4 * 196 + 128) >> 8) - b7;
		x0 = x4 - (((tmp1 - tmp2) * 362 + 128) >> 8);
		x1 = m0 - b1;
		x2 = (((block[2 * 8 + i] - block[6 * 8 + i]) * 362 + 128) >> 8) - b3;
		x3 = m0 + b1;
		y3 = x1 + x2;
		y4 = x3 + b3;
		y5 = x1 - x2;
		y6 = x3 - b3;
		y7 = -x0 - ((b4 * 473 + b6 * 196 + 128) >> 8);
		block[0 * 8 + i] = b7 + y4;
		block[1 * 8 + i] = x4 + y3;
		block[2 * 8 + i] = y5 - x0;
		block[3 * 8 + i] = y6 - y7;
		block[4 * 8 + i] = y6 + y7;
		block[5 * 8 + i] = x0 + y5;
		block[6 * 8 + i] = y3 - x4;
		block[7 * 8 + i] = y4 - b7;
	}

	// Transform rows
	for (int i = 0; i < 64; i += 8) {
		b1 = block[4 + i];
		b3 = block[2 + i] + block[6 + i];
		b4 = block[5 + i] - block[3 + i];
		tmp1 = block[1 + i] + block[7 + i];
		tmp2 = block[3 + i] + block[5 + i];
		b6 = block[1 + i] - block[7 + i];
		b7 = tmp1 + tmp2;
		m0 = block[0 + i];
		x4 = ((b6 * 473 - b4 * 196 + 128) >> 8) - b7;
		x0 = x4 - (((tmp1 - tmp2) * 362 + 128) >> 8);
		x1 = m0 - b1;
		x2 = (((block[2 + i] - block[6 + i]) * 362 + 128) >> 8) - b3;
		x3 = m0 + b1;
		y3 = x1 + x2;
		y4 = x3 + b3;
		y5 = x1 - x2;
		y6 = x3 - b3;
		y7 = -x0 - ((b4 * 473 + b6 * 196 + 128) >> 8);
		block[0 + i] = (b7 + y4 + 128) >> 8;
		block[1 + i] = (x4 + y3 + 128) >> 8;
		block[2 + i] = (y5 - x0 + 128) >> 8;
		block[3 + i] = (y6 - y7 + 128) >> 8;
		block[4 + i] = (y6 + y7 + 128) >> 8;
		block[5 + i] = (x0 + y5 + 128) >> 8;
		block[6 + i] = (y3 - x4 + 128) >> 8;
		block[7 + i] = (y4 - b7 + 128) >> 8;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq $-0x8, %rax
movdqu 0xa0(%rdi,%rax,4), %xmm7
movdqu 0xe0(%rdi,%rax,4), %xmm15
movdqu 0x20(%rdi,%rax,4), %xmm5
movdqu 0x40(%rdi,%rax,4), %xmm6
movdqu 0x60(%rdi,%rax,4), %xmm4
movdqu 0x80(%rdi,%rax,4), %xmm1
movdqa %xmm15, %xmm8
paddd %xmm4, %xmm8
movdqu 0xc0(%rdi,%rax,4), %xmm0
movdqa %xmm0, %xmm10
psubd %xmm1, %xmm10
movdqu 0x100(%rdi,%rax,4), %xmm9
movdqa %xmm9, %xmm14
paddd %xmm6, %xmm14
paddd %xmm0, %xmm1
psubd %xmm9, %xmm6
movdqa %xmm6, %xmm0
movdqa 0x3458(%rip), %xmm2     # 0x9030
pmuludq %xmm2, %xmm0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
pshufd $0xf5, %xmm6, %xmm11    # xmm11 = xmm6[1,1,3,3]
movdqa %xmm11, %xmm9
pmuludq %xmm2, %xmm9
pshufd $0xe8, %xmm9, %xmm9     # xmm9 = xmm9[0,2,2,3]
punpckldq %xmm9, %xmm0    # xmm0 = xmm0[0],xmm9[0],xmm0[1],xmm9[1]
movdqa %xmm10, %xmm9
movdqa 0x3437(%rip), %xmm3     # 0x9040
pmuludq %xmm3, %xmm9
pshufd $0xe8, %xmm9, %xmm13    # xmm13 = xmm9[0,2,2,3]
pshufd $0xf5, %xmm10, %xmm12   # xmm12 = xmm10[1,1,3,3]
movdqa %xmm12, %xmm9
pmuludq %xmm3, %xmm9
pshufd $0xe8, %xmm9, %xmm9     # xmm9 = xmm9[0,2,2,3]
punpckldq %xmm9, %xmm13   # xmm13 = xmm13[0],xmm9[0],xmm13[1],xmm9[1]
movdqa %xmm14, %xmm9
paddd %xmm1, %xmm9
paddd %xmm0, %xmm13
movdqa 0x340a(%rip), %xmm3     # 0x9050
paddd %xmm3, %xmm13
psrad $0x8, %xmm13
psubd %xmm9, %xmm13
psubd %xmm1, %xmm14
pshufd $0xf5, %xmm14, %xmm0    # xmm0 = xmm14[1,1,3,3]
movdqa 0x33f7(%rip), %xmm2     # 0x9060
pmuludq %xmm2, %xmm14
pshufd $0xe8, %xmm14, %xmm1    # xmm1 = xmm14[0,2,2,3]
pmuludq %xmm2, %xmm0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
paddd %xmm3, %xmm1
psrad $0x8, %xmm1
movdqa %xmm5, %xmm14
psubd %xmm7, %xmm14
psubd %xmm15, %xmm4
pshufd $0xf5, %xmm4, %xmm0     # xmm0 = xmm4[1,1,3,3]
pmuludq %xmm2, %xmm4
pshufd $0xe8, %xmm4, %xmm4     # xmm4 = xmm4[0,2,2,3]
pmuludq %xmm2, %xmm0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
punpckldq %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1]
paddd %xmm3, %xmm4
psrad $0x8, %xmm4
psubd %xmm8, %xmm4
movdqa %xmm14, %xmm15
paddd %xmm4, %xmm15
movdqa %xmm13, %xmm0
paddd %xmm15, %xmm0
psubd %xmm13, %xmm15
psubd %xmm1, %xmm13
paddd %xmm7, %xmm5
psubd %xmm4, %xmm14
movdqa %xmm5, %xmm1
paddd %xmm8, %xmm1
psubd %xmm8, %xmm5
movdqa 0x3331(%rip), %xmm2     # 0x9030
pmuludq %xmm2, %xmm10
pshufd $0xe8, %xmm10, %xmm4    # xmm4 = xmm10[0,2,2,3]
pmuludq %xmm2, %xmm12
pshufd $0xe8, %xmm12, %xmm7    # xmm7 = xmm12[0,2,2,3]
punpckldq %xmm7, %xmm4    # xmm4 = xmm4[0],xmm7[0],xmm4[1],xmm7[1]
movdqa 0x334f(%rip), %xmm2     # 0x9070
pmuludq %xmm2, %xmm6
pshufd $0xe8, %xmm6, %xmm6     # xmm6 = xmm6[0,2,2,3]
pmuludq %xmm2, %xmm11
pshufd $0xe8, %xmm11, %xmm7    # xmm7 = xmm11[0,2,2,3]
punpckldq %xmm7, %xmm6    # xmm6 = xmm6[0],xmm7[0],xmm6[1],xmm7[1]
paddd %xmm4, %xmm6
movdqa %xmm1, %xmm4
paddd %xmm9, %xmm4
movdqu %xmm4, 0x20(%rdi,%rax,4)
paddd %xmm3, %xmm6
psrad $0x8, %xmm6
paddd %xmm13, %xmm6
movdqu %xmm0, 0x40(%rdi,%rax,4)
movdqa %xmm14, %xmm0
psubd %xmm13, %xmm0
movdqu %xmm0, 0x60(%rdi,%rax,4)
movdqa %xmm6, %xmm0
paddd %xmm5, %xmm0
movdqu %xmm0, 0x80(%rdi,%rax,4)
psubd %xmm6, %xmm5
movdqu %xmm5, 0xa0(%rdi,%rax,4)
paddd %xmm13, %xmm14
movdqu %xmm14, 0xc0(%rdi,%rax,4)
movdqu %xmm15, 0xe0(%rdi,%rax,4)
psubd %xmm9, %xmm1
movdqu %xmm1, 0x100(%rdi,%rax,4)
addq $0x4, %rax
jne 0x5b64
movq $-0x8, %rax
movl $0x80, %ecx
movl 0x30(%rdi,%rax,4), %r8d
movl 0x28(%rdi,%rax,4), %r15d
movl 0x38(%rdi,%rax,4), %r12d
leal (%r12,%r15), %r9d
movl 0x34(%rdi,%rax,4), %ebx
movl 0x2c(%rdi,%rax,4), %edx
movl %ebx, %r10d
subl %edx, %r10d
movl 0x20(%rdi,%rax,4), %esi
movl 0x24(%rdi,%rax,4), %r11d
movl 0x3c(%rdi,%rax,4), %r14d
leal (%r14,%r11), %r13d
addl %edx, %ebx
subl %r14d, %r11d
leal (%rbx,%r13), %edx
imull $0x1d9, %r11d, %ebp     # imm = 0x1D9
imull $0xffffff3c, %r10d, %r14d # imm = 0xFFFFFF3C
addl %ebp, %r14d
addl %ecx, %r14d
sarl $0x8, %r14d
subl %edx, %r14d
subl %ebx, %r13d
imull $0x16a, %r13d, %ebp     # imm = 0x16A
addl %ecx, %ebp
sarl $0x8, %ebp
movl %esi, %ebx
subl %r8d, %ebx
subl %r12d, %r15d
imull $0x16a, %r15d, %r15d    # imm = 0x16A
addl %ecx, %r15d
sarl $0x8, %r15d
subl %r9d, %r15d
leal (%rbx,%r15), %r12d
leal (%r14,%r12), %r13d
addl $0x80, %r13d
addl %ecx, %r12d
subl %r14d, %r12d
subl %ebp, %r14d
addl %r8d, %esi
leal (%rsi,%r9), %r8d
subl %r15d, %ebx
subl %r9d, %esi
imull $0x1d9, %r10d, %r9d     # imm = 0x1D9
imull $0xc4, %r11d, %r10d
addl %r9d, %r10d
addl %ecx, %r10d
sarl $0x8, %r10d
addl %r14d, %r10d
leal (%rdx,%r8), %r9d
addl %ecx, %r9d
sarl $0x8, %r9d
movl %r9d, 0x20(%rdi,%rax,4)
sarl $0x8, %r13d
movl %r13d, 0x24(%rdi,%rax,4)
leal (%rbx,%rcx), %r9d
subl %r14d, %r9d
sarl $0x8, %r9d
movl %r9d, 0x28(%rdi,%rax,4)
leal (%rsi,%r10), %r9d
addl $0x80, %r9d
addl %ecx, %esi
sarl $0x8, %r9d
movl %r9d, 0x2c(%rdi,%rax,4)
subl %r10d, %esi
sarl $0x8, %esi
movl %esi, 0x30(%rdi,%rax,4)
leal (%rbx,%r14), %esi
addl $0x80, %esi
sarl $0x8, %esi
movl %esi, 0x34(%rdi,%rax,4)
sarl $0x8, %r12d
movl %r12d, 0x38(%rdi,%rax,4)
subl %edx, %r8d
addl %ecx, %r8d
sarl $0x8, %r8d
movl %r8d, 0x3c(%rdi,%rax,4)
addq $0x8, %rax
cmpq $0x38, %rax
jb 0x5dcb
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq