// File: /workspace/github_c_makefile_star2_O3/tvlabs[P]edge264/./edge264_intra.c
// Function: decode_intra4x4
static void decode_intra4x4(int mode, uint8_t * restrict p, size_t stride, i16x8 clip) {
	INIT_P();
	i8x16 v, shuf;
	i32x4 pred;
	switch (mode) {
	default: __builtin_unreachable();
	
	case I4x4_V_8:
		pred = set32(*(int32_t *)P(0, -1));
		goto store_4x4;
	
	case I4x4_H_8:
		*(int32_t *)P(0, 0) = ((i32x4)set8(*P(-1, 0)))[0];
		*(int32_t *)P(0, 1) = ((i32x4)set8(*P(-1, 1)))[0];
		*(int32_t *)P(0, 2) = ((i32x4)set8(*P(-1, 2)))[0];
		*(int32_t *)P(0, 3) = ((i32x4)set8(*P(-1, 3)))[0];
		return;
	
	case I4x4_DC_8:
		v = ziplo32(ldleft4(0, 1, 2, 3), load32(P(0, -1)));
	dc_4x4:
		pred = broadcast8(shrru16(sumh8(v), 3), __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__);
		goto store_4x4;
	case I4x4_DCA_8: {
		i8x16 v0 = load32(P(0, -1));
		v = ziplo32(v0, v0);
		} goto dc_4x4;
	case I4x4_DCB_8: {
		i8x16 v0 = ldleft4(0, 1, 2, 3);
		v = ziplo32(v0, v0);
		} goto dc_4x4;
	case I4x4_DCAB_8:
		pred = set8(-128);
		goto store_4x4;
	
	case I4x4_DDL_8:
		v = spreadh8(load64(P(0, -1)));
		shuf = (i8x16){0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6};
		goto lowpass_4x4;
	case I4x4_DDLC_8:
		v = spreadq8(load32(P(0, -1)));
		shuf = (i8x16){0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6};
		goto lowpass_4x4;
	case I4x4_DDR_8:
		shuf = (i8x16){3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3};
		goto down_right_4x4;
	case I4x4_VR_8:
		shuf = (i8x16){12, 13, 14, 15, 3, 4, 5, 6, 2, 12, 13, 14, 1, 3, 4, 5};
		goto down_right_4x4;
	case I4x4_HD_8:
		shuf = (i8x16){11, 3, 4, 5, 10, 2, 11, 3, 9, 1, 10, 2, 8, 0, 9, 1};
		goto down_right_4x4;
	case I4x4_VL_8:
		v = load64(P(0, -1));
		shuf = (i8x16){8, 9, 10, 11, 0, 1, 2, 3, 9, 10, 11, 12, 1, 2, 3, 4};
		goto lowpass_4x4;
	case I4x4_VLC_8:
		v = spreadq8(load32(P(0, -1)));
		shuf = (i8x16){8, 9, 10, 11, 0, 1, 2, 3, 9, 10, 11, 12, 1, 2, 3, 4};
		goto lowpass_4x4;
	case I4x4_HU_8:
		v = shlc128(ldleft4(3, 2, 1, 0), 1);
		shuf = (i8x16){11, 2, 10, 1, 10, 1, 9, 0, 9, 0, 8, 8, 8, 8, 8, 8};
		goto lowpass_4x4;
	down_right_4x4:
		v = ldedge4x4();
	lowpass_4x4: {
		i8x16 w = shr128(v, 1);
		i8x16 x = shr128(v, 2);
		pred = shuffle(lowpass8(ziplo64(v, v), ziplo64(w, w), ziplo64(x, v)), shuf);
	} store_4x4:
		*(int32_t *)P(0, 0) = pred[0];
		*(int32_t *)P(0, 1) = pred[1];
		*(int32_t *)P(0, 2) = pred[2];
		*(int32_t *)P(0, 3) = pred[3];
		return;
	}
}

// Assembly:
movq %rdx, %rax
negq %rax
leaq (%rsi,%rdx,8), %rcx
subq %rdx, %rcx
movl %edi, %edi
leaq 0x20c6f(%rip), %r8      # 0x33bc8
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
vpbroadcastd (%rsi,%rax), %xmm0
jmp 0x13140
vmovq (%rsi,%rax), %xmm1
jmp 0x12fb0
vmovd -0x4(%rsi), %xmm0
vmovd -0x4(%rsi,%rdx), %xmm1
vpunpcklbw %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
vmovd -0x4(%rsi,%rdx,2), %xmm1
vmovd -0x4(%rcx,%rax,4), %xmm2
vpunpcklbw %xmm2, %xmm1, %xmm1 # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
vpunpcklwd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
vpxor %xmm1, %xmm1, %xmm1
vshufps $0xef, %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[3,3],xmm1[2,3]
jmp 0x13007
vmovd (%rsi,%rax), %xmm0
vpshufb 0x207b0(%rip), %xmm0, %xmm1 # 0x33760
vmovdqa 0x207b8(%rip), %xmm0    # 0x33770
jmp 0x13108
vmovdqa 0x207cb(%rip), %xmm0    # 0x33790
jmp 0x130d9
vmovd -0x4(%rsi), %xmm0
vmovd -0x4(%rsi,%rdx), %xmm1
vpunpcklbw %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
vmovd -0x4(%rsi,%rdx,2), %xmm1
vmovd -0x4(%rcx,%rax,4), %xmm2
vpunpcklbw %xmm2, %xmm1, %xmm1 # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
vpunpcklwd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
vpsrldq $0xc, %xmm0, %xmm0      # xmm0 = xmm0[12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
vmovss (%rsi,%rax), %xmm1
vunpcklps %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
jmp 0x13007
vmovss (%rsi,%rax), %xmm0
vshufps $0x50, %xmm0, %xmm0, %xmm0 # xmm0 = xmm0[0,0,1,1]
vpxor %xmm1, %xmm1, %xmm1
vpsadbw %xmm1, %xmm0, %xmm0
vpsrlw $0x2, %xmm0, %xmm0
vpavgw %xmm1, %xmm0, %xmm0
vpbroadcastb %xmm0, %xmm0
jmp 0x13140
vmovd (%rsi,%rax), %xmm0
vpshufb 0x20730(%rip), %xmm0, %xmm1 # 0x33760
jmp 0x130bd
vpbroadcastb -0x1(%rsi), %xmm0
vmovd %xmm0, (%rsi)
vpbroadcastb -0x1(%rsi,%rdx), %xmm0
vmovd %xmm0, (%rsi,%rdx)
vpbroadcastb -0x1(%rsi,%rdx,2), %xmm0
vmovd %xmm0, (%rsi,%rdx,2)
vpbroadcastb -0x1(%rcx,%rax,4), %xmm0
shlq $0x2, %rax
vmovd %xmm0, %edx
jmp 0x1315c
vpbroadcastd 0x242f8(%rip), %xmm0 # 0x3736c
jmp 0x13140
vmovd -0x4(%rcx,%rax,4), %xmm0
vmovd -0x4(%rsi,%rdx,2), %xmm1
vpunpcklbw %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
vmovd -0x4(%rsi,%rdx), %xmm1
vmovd -0x4(%rsi), %xmm2
vpunpcklbw %xmm2, %xmm1, %xmm1 # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
vpunpcklwd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
vpshufb 0x2069b(%rip), %xmm0, %xmm1 # 0x33740
vmovdqa 0x206a3(%rip), %xmm0    # 0x33750
jmp 0x13108
vmovq (%rsi,%rax), %xmm0
vpshufb 0x206f3(%rip), %xmm0, %xmm1 # 0x337b0
vmovdqa 0x206db(%rip), %xmm0    # 0x337a0
jmp 0x13108
vmovdqa 0x206b1(%rip), %xmm0    # 0x33780
jmp 0x130d9
vmovdqa 0x20657(%rip), %xmm0    # 0x33730
vmovq -0x1(%rsi,%rax), %xmm1
vmovd -0x4(%rcx,%rax,4), %xmm2
vmovd -0x4(%rsi,%rdx,2), %xmm3
vmovd -0x4(%rsi,%rdx), %xmm4
vpunpcklbw %xmm3, %xmm2, %xmm2 # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1],xmm2[2],xmm3[2],xmm2[3],xmm3[3],xmm2[4],xmm3[4],xmm2[5],xmm3[5],xmm2[6],xmm3[6],xmm2[7],xmm3[7]
vmovd -0x4(%rsi), %xmm3
vpunpcklbw %xmm3, %xmm4, %xmm3 # xmm3 = xmm4[0],xmm3[0],xmm4[1],xmm3[1],xmm4[2],xmm3[2],xmm4[3],xmm3[3],xmm4[4],xmm3[4],xmm4[5],xmm3[5],xmm4[6],xmm3[6],xmm4[7],xmm3[7]
vpunpcklwd %xmm3, %xmm2, %xmm2 # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1],xmm2[2],xmm3[2],xmm2[3],xmm3[3]
vpalignr $0xc, %xmm2, %xmm1, %xmm1 # xmm1 = xmm2[12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11]
vpbroadcastq %xmm1, %xmm2
vpshufb 0x206aa(%rip), %xmm1, %xmm3 # 0x337c0
vpshufb 0x206b1(%rip), %xmm1, %xmm1 # 0x337d0
vpavgb %xmm1, %xmm2, %xmm4
vpbroadcastb 0x20a98(%rip), %xmm5 # 0x33bc4
vpternlogq $0x60, %xmm1, %xmm2, %xmm5
vpsubusb %xmm5, %xmm4, %xmm1
vpavgb %xmm3, %xmm1, %xmm1
vpshufb %xmm0, %xmm1, %xmm0
vmovd %xmm0, (%rsi)
vpextrd $0x1, %xmm0, (%rsi,%rdx)
vpextrd $0x2, %xmm0, (%rsi,%rdx,2)
vpextrd $0x3, %xmm0, %edx
shlq $0x2, %rax
movl %edx, (%rcx,%rax)
retq