// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/libraries/libwebp/src/dsp/dec.c
// Function: TransformOne_C
static void TransformOne_C(const int16_t* in, uint8_t* dst) {
  int C[4 * 4], *tmp;
  int i;
  tmp = C;
  for (i = 0; i < 4; ++i) {    // vertical pass
    const int a = in[0] + in[8];    // [-4096, 4094]
    const int b = in[0] - in[8];    // [-4095, 4095]
    const int c = WEBP_TRANSFORM_AC3_MUL2(in[4]) -
                  WEBP_TRANSFORM_AC3_MUL1(in[12]);  // [-3783, 3783]
    const int d = WEBP_TRANSFORM_AC3_MUL1(in[4]) +
                  WEBP_TRANSFORM_AC3_MUL2(in[12]);  // [-3785, 3781]
    tmp[0] = a + d;   // [-7881, 7875]
    tmp[1] = b + c;   // [-7878, 7878]
    tmp[2] = b - c;   // [-7878, 7878]
    tmp[3] = a - d;   // [-7877, 7879]
    tmp += 4;
    in++;
  }
  // Each pass is expanding the dynamic range by ~3.85 (upper bound).
  // The exact value is (2. + (20091 + 35468) / 65536).
  // After the second pass, maximum interval is [-3794, 3794], assuming
  // an input in [-2048, 2047] interval. We then need to add a dst value
  // in the [0, 255] range.
  // In the worst case scenario, the input to clip_8b() can be as large as
  // [-60713, 60968].
  tmp = C;
  for (i = 0; i < 4; ++i) {    // horizontal pass
    const int dc = tmp[0] + 4;
    const int a =  dc +  tmp[8];
    const int b =  dc -  tmp[8];
    const int c =
        WEBP_TRANSFORM_AC3_MUL2(tmp[4]) - WEBP_TRANSFORM_AC3_MUL1(tmp[12]);
    const int d =
        WEBP_TRANSFORM_AC3_MUL1(tmp[4]) + WEBP_TRANSFORM_AC3_MUL2(tmp[12]);
    STORE(0, 0, a + d);
    STORE(1, 0, b + c);
    STORE(2, 0, b - c);
    STORE(3, 0, a - d);
    tmp++;
    dst += BPS;
  }
}

// Assembly:
pushq %rbx
movq (%rdi), %xmm0
punpcklwd %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3]
psrad $0x10, %xmm0
movq 0x10(%rdi), %xmm1
punpcklwd %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1],xmm2[2],xmm1[2],xmm2[3],xmm1[3]
psrad $0x10, %xmm2
movdqa %xmm2, %xmm1
paddd %xmm0, %xmm1
psubd %xmm2, %xmm0
movq 0x8(%rdi), %xmm5
punpcklwd %xmm5, %xmm3    # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1],xmm3[2],xmm5[2],xmm3[3],xmm5[3]
psrad $0x10, %xmm3
movdqa 0x5157d(%rip), %xmm2    # 0x12a6f0
pshufd $0xf5, %xmm3, %xmm4     # xmm4 = xmm3[1,1,3,3]
movdqa 0x51580(%rip), %xmm6    # 0x12a700
pmulhw %xmm6, %xmm5
punpcklwd %xmm5, %xmm5    # xmm5 = xmm5[0,0,1,1,2,2,3,3]
psrad $0x10, %xmm5
paddd %xmm3, %xmm5
pmuludq %xmm2, %xmm3
pshufd $0xe8, %xmm3, %xmm3     # xmm3 = xmm3[0,2,2,3]
pmuludq %xmm2, %xmm4
pshufd $0xe8, %xmm4, %xmm4     # xmm4 = xmm4[0,2,2,3]
punpckldq %xmm4, %xmm3    # xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
psrad $0x10, %xmm3
movq 0x18(%rdi), %xmm4
punpcklwd %xmm4, %xmm7    # xmm7 = xmm7[0],xmm4[0],xmm7[1],xmm4[1],xmm7[2],xmm4[2],xmm7[3],xmm4[3]
psrad $0x10, %xmm7
pmulhw %xmm6, %xmm4
punpcklwd %xmm4, %xmm4    # xmm4 = xmm4[0,0,1,1,2,2,3,3]
psrad $0x10, %xmm4
paddd %xmm7, %xmm4
psubd %xmm4, %xmm3
pshufd $0xf5, %xmm7, %xmm4     # xmm4 = xmm7[1,1,3,3]
pmuludq %xmm2, %xmm7
pshufd $0xe8, %xmm7, %xmm6     # xmm6 = xmm7[0,2,2,3]
pmuludq %xmm2, %xmm4
pshufd $0xe8, %xmm4, %xmm2     # xmm2 = xmm4[0,2,2,3]
punpckldq %xmm2, %xmm6    # xmm6 = xmm6[0],xmm2[0],xmm6[1],xmm2[1]
psrad $0x10, %xmm6
paddd %xmm5, %xmm6
movdqa %xmm6, %xmm2
paddd %xmm1, %xmm2
movdqa %xmm3, %xmm4
paddd %xmm0, %xmm4
psubd %xmm3, %xmm0
psubd %xmm6, %xmm1
movdqa %xmm0, %xmm3
punpckldq %xmm1, %xmm3    # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
movdqa %xmm2, %xmm5
punpckldq %xmm4, %xmm5    # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
movdqa %xmm5, %xmm6
punpcklqdq %xmm3, %xmm6    # xmm6 = xmm6[0],xmm3[0]
punpckhqdq %xmm3, %xmm5    # xmm5 = xmm5[1],xmm3[1]
punpckhdq %xmm1, %xmm0    # xmm0 = xmm0[2],xmm1[2],xmm0[3],xmm1[3]
punpckhdq %xmm4, %xmm2    # xmm2 = xmm2[2],xmm4[2],xmm2[3],xmm4[3]
movdqa %xmm2, %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
punpckhqdq %xmm0, %xmm2    # xmm2 = xmm2[1],xmm0[1]
movdqa %xmm2, -0x10(%rsp)
movdqa %xmm1, -0x20(%rsp)
movdqa %xmm5, -0x30(%rsp)
movdqa %xmm6, -0x40(%rsp)
xorl %eax, %eax
movl -0x40(%rsp,%rax), %edx
movl -0x30(%rsp,%rax), %r10d
movl -0x20(%rsp,%rax), %r11d
leal (%rdx,%r11), %ecx
addl $0x4, %ecx
movl -0x10(%rsp,%rax), %r9d
imull $0x4e7b, %r10d, %r8d    # imm = 0x4E7B
sarl $0x10, %r8d
addl %r10d, %r8d
imull $0x8a8c, %r9d, %edi     # imm = 0x8A8C
sarl $0x10, %edi
addl %r8d, %edi
movzbl (%rsi,%rax,8), %r8d
leal (%rdi,%rcx), %ebx
sarl $0x3, %ebx
addl %r8d, %ebx
testl %ebx, %ebx
jg 0xd929e
xorl %ebx, %ebx
movl $0xff, %r8d
cmpl %r8d, %ebx
jl 0xd92ae
movl $0xff, %ebx
addl $0x4, %edx
subl %r11d, %edx
imull $0x8a8c, %r10d, %r10d   # imm = 0x8A8C
sarl $0x10, %r10d
imull $0x4e7b, %r9d, %r11d    # imm = 0x4E7B
sarl $0x10, %r11d
addl %r9d, %r11d
subl %r11d, %r10d
movb %bl, (%rsi,%rax,8)
movzbl 0x1(%rsi,%rax,8), %r11d
leal (%r10,%rdx), %r9d
sarl $0x3, %r9d
addl %r11d, %r9d
testl %r9d, %r9d
jg 0xd92ec
xorl %r9d, %r9d
cmpl %r8d, %r9d
jl 0xd92f7
movl $0xff, %r9d
movb %r9b, 0x1(%rsi,%rax,8)
movzbl 0x2(%rsi,%rax,8), %r9d
subl %r10d, %edx
sarl $0x3, %edx
addl %r9d, %edx
testl %edx, %edx
jg 0xd9311
xorl %edx, %edx
cmpl %r8d, %edx
jl 0xd931b
movl $0xff, %edx
movb %dl, 0x2(%rsi,%rax,8)
movzbl 0x3(%rsi,%rax,8), %edx
subl %edi, %ecx
sarl $0x3, %ecx
addl %edx, %ecx
testl %ecx, %ecx
jg 0xd9331
xorl %ecx, %ecx
cmpl %r8d, %ecx
jl 0xd933b
movl $0xff, %ecx
movb %cl, 0x3(%rsi,%rax,8)
addq $0x4, %rax
cmpl $0x10, %eax
jne 0xd9255
popq %rbx
retq