// File: /workspace/github_c_makefile_star2_O1/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
xorl %eax, %eax
movswl (%rdi,%rax), %ecx
movswl 0x10(%rdi,%rax), %r8d
leal (%r8,%rcx), %edx
subl %r8d, %ecx
movswl 0x8(%rdi,%rax), %r8d
imull $0x8a8c, %r8d, %r9d     # imm = 0x8A8C
sarl $0x10, %r9d
movswl 0x18(%rdi,%rax), %r10d
imull $0x4e7b, %r10d, %r11d   # imm = 0x4E7B
sarl $0x10, %r11d
addl %r10d, %r11d
subl %r11d, %r9d
imull $0x4e7b, %r8d, %r11d    # imm = 0x4E7B
sarl $0x10, %r11d
addl %r8d, %r11d
imull $0x8a8c, %r10d, %r8d    # imm = 0x8A8C
sarl $0x10, %r8d
addl %r11d, %r8d
leal (%r8,%rdx), %r10d
movl %r10d, -0x40(%rsp,%rax,8)
leal (%r9,%rcx), %r10d
movl %r10d, -0x3c(%rsp,%rax,8)
subl %r9d, %ecx
movl %ecx, -0x38(%rsp,%rax,8)
subl %r8d, %edx
movl %edx, -0x34(%rsp,%rax,8)
addq $0x2, %rax
cmpl $0x8, %eax
jne 0xda0b8
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 0xda181
xorl %ebx, %ebx
movl $0xff, %r8d
cmpl %r8d, %ebx
jl 0xda191
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 0xda1cf
xorl %r9d, %r9d
cmpl %r8d, %r9d
jl 0xda1da
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 0xda1f4
xorl %edx, %edx
cmpl %r8d, %edx
jl 0xda1fe
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 0xda214
xorl %ecx, %ecx
cmpl %r8d, %ecx
jl 0xda21e
movl $0xff, %ecx
movb %cl, 0x3(%rsi,%rax,8)
addq $0x4, %rax
cmpl $0x10, %eax
jne 0xda138
popq %rbx
retq