#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint8_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int PackRGBA(int, int, int, int);
void DecompressBlockDXT5(uint32_t x, uint32_t y, uint32_t width,
                         const uint8_t *blockStorage, uint32_t *image) {
  uint8_t alpha0, alpha1;
  const uint8_t *bits;
  uint32_t alphaCode1;
  uint16_t alphaCode2;
  uint16_t color0, color1;
  uint8_t r0, g0, b0, r1, g1, b1;
  int i, j;
  uint32_t temp, code;
  alpha0 = *(blockStorage);
  alpha1 = *(blockStorage + 1);
  bits = blockStorage + 2;
  alphaCode1 = bits[2] | (bits[3] << 8) | (bits[4] << 16) | (bits[5] << 24);
  alphaCode2 = bits[0] | (bits[1] << 8);
  color0 = *(const uint16_t *)(blockStorage + 8);
  color1 = *(const uint16_t *)(blockStorage + 10);
  temp = (color0 >> 11) * 255 + 16;
  r0 = (uint8_t)((temp / 32 + temp) / 32);
  temp = ((color0 & 0x07E0) >> 5) * 255 + 32;
  g0 = (uint8_t)((temp / 64 + temp) / 64);
  temp = (color0 & 0x001F) * 255 + 16;
  b0 = (uint8_t)((temp / 32 + temp) / 32);
  temp = (color1 >> 11) * 255 + 16;
  r1 = (uint8_t)((temp / 32 + temp) / 32);
  temp = ((color1 & 0x07E0) >> 5) * 255 + 32;
  g1 = (uint8_t)((temp / 64 + temp) / 64);
  temp = (color1 & 0x001F) * 255 + 16;
  b1 = (uint8_t)((temp / 32 + temp) / 32);
  code = *(const uint32_t *)(blockStorage + 12);
  for (j = 0; j < 4; j++) {
    for (i = 0; i < 4; i++) {
      uint8_t finalAlpha;
      int alphaCode, alphaCodeIndex;
      uint8_t colorCode;
      uint32_t finalColor;
      alphaCodeIndex = 3 * (4 * j + i);
      if (alphaCodeIndex <= 12) {
        alphaCode = (alphaCode2 >> alphaCodeIndex) & 0x07;
      } else if (alphaCodeIndex == 15) {
        alphaCode = (alphaCode2 >> 15) | ((alphaCode1 << 1) & 0x06);
      } else {
        alphaCode = (alphaCode1 >> (alphaCodeIndex - 16)) & 0x07;
      }
      if (alphaCode == 0) {
        finalAlpha = alpha0;
      } else if (alphaCode == 1) {
        finalAlpha = alpha1;
      } else {
        if (alpha0 > alpha1) {
          finalAlpha =
              (uint8_t)(((8 - alphaCode) * alpha0 + (alphaCode - 1) * alpha1) /
                        7);
        } else {
          if (alphaCode == 6) {
            finalAlpha = 0;
          } else if (alphaCode == 7) {
            finalAlpha = 255;
          } else {
            finalAlpha = (uint8_t)(((6 - alphaCode) * alpha0 +
                                    (alphaCode - 1) * alpha1) /
                                   5);
          }
        }
      }
      colorCode = (code >> 2 * (4 * j + i)) & 0x03;
      finalColor = 0;
      switch (colorCode) {
      case 0:
        finalColor = PackRGBA(r0, g0, b0, finalAlpha);
        break;
      case 1:
        finalColor = PackRGBA(r1, g1, b1, finalAlpha);
        break;
      case 2:
        finalColor = PackRGBA((2 * r0 + r1) / 3, (2 * g0 + g1) / 3,
                              (2 * b0 + b1) / 3, finalAlpha);
        break;
      case 3:
        finalColor = PackRGBA((r0 + 2 * r1) / 3, (g0 + 2 * g1) / 3,
                              (b0 + 2 * b1) / 3, finalAlpha);
        break;
      }
      image[i + x + (width * (y + j))] = finalColor;
    }
  }
}


x86 assembly (clang, -O0):
<DecompressBlockDXT5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%eax
mov    -0x30(%rbp),%rcx
mov    0xc(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x30(%rbp),%rcx
mov    0x10(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x30(%rbp),%rcx
mov    0x14(%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    -0x30(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
sar    $0xb,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
and    $0x7e0,%eax
sar    $0x5,%eax
imul   $0xff,%eax,%eax
add    $0x20,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
add    -0x64(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,-0x48(%rbp)
mov    -0x3c(%rbp),%eax
and    $0x1f,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%eax
sar    $0xb,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x50(%rbp)
mov    -0x40(%rbp),%eax
and    $0x7e0,%eax
sar    $0x5,%eax
imul   $0xff,%eax,%eax
add    $0x20,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
add    -0x64(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%eax
and    $0x1f,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x64(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    0x30(%rax),%eax
mov    %eax,-0x68(%rbp)
movl   $0x0,-0x60(%rbp)
cmpl   $0x4,-0x60(%rbp)
jge    1553 <DecompressBlockDXT5+0x443>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    1540 <DecompressBlockDXT5+0x430>
mov    -0x60(%rbp),%eax
shl    $0x2,%eax
add    -0x5c(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x74(%rbp)
cmpl   $0xc,-0x74(%rbp)
jg     1306 <DecompressBlockDXT5+0x1f6>
mov    -0x38(%rbp),%eax
mov    -0x74(%rbp),%ecx
sar    %cl,%eax
and    $0x7,%eax
mov    %eax,-0x70(%rbp)
jmp    133f <DecompressBlockDXT5+0x22f>
cmpl   $0xf,-0x74(%rbp)
jne    1329 <DecompressBlockDXT5+0x219>
mov    -0x38(%rbp),%eax
sar    $0xf,%eax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
and    $0x6,%ecx
or     %ecx,%eax
mov    %eax,-0x70(%rbp)
jmp    133a <DecompressBlockDXT5+0x22a>
mov    -0x34(%rbp),%eax
mov    -0x74(%rbp),%ecx
sub    $0x10,%ecx
sar    %cl,%eax
and    $0x7,%eax
mov    %eax,-0x70(%rbp)
jmp    133f <DecompressBlockDXT5+0x22f>
cmpl   $0x0,-0x70(%rbp)
jne    1354 <DecompressBlockDXT5+0x244>
mov    -0x24(%rbp),%eax
mov    %eax,-0x6c(%rbp)
jmp    1400 <DecompressBlockDXT5+0x2f0>
cmpl   $0x1,-0x70(%rbp)
jne    1369 <DecompressBlockDXT5+0x259>
mov    -0x28(%rbp),%eax
mov    %eax,-0x6c(%rbp)
jmp    13fb <DecompressBlockDXT5+0x2eb>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    139d <DecompressBlockDXT5+0x28d>
mov    $0x8,%eax
sub    -0x70(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    -0x70(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x28(%rbp),%ecx
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x6c(%rbp)
jmp    13f6 <DecompressBlockDXT5+0x2e6>
cmpl   $0x6,-0x70(%rbp)
jne    13b3 <DecompressBlockDXT5+0x2a3>
movl   $0x0,-0x6c(%rbp)
jmp    13f1 <DecompressBlockDXT5+0x2e1>
cmpl   $0x7,-0x70(%rbp)
jne    13c9 <DecompressBlockDXT5+0x2b9>
movl   $0xff,-0x6c(%rbp)
jmp    13ec <DecompressBlockDXT5+0x2dc>
mov    $0x6,%eax
sub    -0x70(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    -0x70(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x28(%rbp),%ecx
add    %ecx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x6c(%rbp)
jmp    13f1 <DecompressBlockDXT5+0x2e1>
jmp    13f6 <DecompressBlockDXT5+0x2e6>
jmp    13fb <DecompressBlockDXT5+0x2eb>
jmp    1400 <DecompressBlockDXT5+0x2f0>
mov    -0x68(%rbp),%eax
mov    -0x60(%rbp),%ecx
mov    -0x5c(%rbp),%esi
mov    %ecx,%edx
mov    %esi,%ecx
lea    (%rcx,%rdx,4),%ecx
add    %cl,%cl
sar    %cl,%eax
and    $0x3,%eax
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x78(%rbp),%eax
mov    %rax,-0x88(%rbp)
sub    $0x3,%rax
ja     1511 <DecompressBlockDXT5+0x401>
mov    -0x88(%rbp),%rax
lea    0xbbd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x44(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x6c(%rbp),%ecx
call   1030 <PackRGBA@plt>
mov    %eax,-0x7c(%rbp)
jmp    1511 <DecompressBlockDXT5+0x401>
mov    -0x50(%rbp),%edi
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
mov    -0x6c(%rbp),%ecx
call   1030 <PackRGBA@plt>
mov    %eax,-0x7c(%rbp)
jmp    1511 <DecompressBlockDXT5+0x401>
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
add    -0x50(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x48(%rbp),%eax
shl    $0x1,%eax
add    -0x54(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x4c(%rbp),%eax
shl    $0x1,%eax
add    -0x58(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x6c(%rbp),%ecx
call   1030 <PackRGBA@plt>
mov    %eax,-0x7c(%rbp)
jmp    1511 <DecompressBlockDXT5+0x401>
mov    -0x44(%rbp),%eax
mov    -0x50(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x48(%rbp),%eax
mov    -0x54(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x4c(%rbp),%eax
mov    -0x58(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x6c(%rbp),%ecx
call   1030 <PackRGBA@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    -0x4(%rbp),%ecx
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edi
add    -0x60(%rbp),%edi
imul   %edi,%esi
add    %esi,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12d0 <DecompressBlockDXT5+0x1c0>
jmp    1545 <DecompressBlockDXT5+0x435>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    12bf <DecompressBlockDXT5+0x1af>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DecompressBlockDXT5>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8,0x80(%rsp)
mov    %esi,%ebx
mov    0x10(%rcx),%r10d
mov    0x14(%rcx),%eax
shl    $0x8,%eax
or     %r10d,%eax
mov    0x18(%rcx),%esi
shl    $0x10,%esi
mov    0x1c(%rcx),%ebp
shl    $0x18,%ebp
or     %esi,%ebp
or     %eax,%ebp
mov    %ebp,0x24(%rsp)
mov    0xc(%rcx),%r12d
shl    $0x8,%r12d
or     0x8(%rcx),%r12d
mov    0x20(%rcx),%r9d
mov    0x28(%rcx),%r8d
mov    %r9d,%esi
sar    $0xb,%esi
mov    %esi,%ebp
shl    $0x8,%ebp
sub    %esi,%ebp
lea    0x10(%rbp),%esi
lea    0x2f(%rbp),%eax
test   %esi,%esi
cmovns %esi,%eax
sar    $0x5,%eax
lea    (%rax,%rbp,1),%esi
add    $0x10,%esi
lea    (%rax,%rbp,1),%r14d
add    $0x2f,%r14d
test   %esi,%esi
cmovns %esi,%r14d
sar    $0x5,%r14d
mov    %r9d,%esi
shr    $0x5,%esi
and    $0x3f,%esi
mov    %esi,%ebp
shl    $0x8,%ebp
sub    %esi,%ebp
lea    0x20(%rbp),%esi
shr    $0x6,%esi
lea    (%rsi,%rbp,1),%r15d
add    $0x20,%r15d
shr    $0x6,%r15d
and    $0x1f,%r9d
mov    %r9d,%esi
shl    $0x8,%esi
sub    %r9d,%esi
lea    0x10(%rsi),%eax
shr    $0x5,%eax
lea    (%rax,%rsi,1),%r9d
add    $0x10,%r9d
shr    $0x5,%r9d
mov    %r8d,%eax
sar    $0xb,%eax
mov    %eax,%esi
shl    $0x8,%esi
sub    %eax,%esi
lea    0x10(%rsi),%eax
lea    0x2f(%rsi),%ebp
test   %eax,%eax
cmovns %eax,%ebp
sar    $0x5,%ebp
lea    (%rsi,%rbp,1),%eax
add    $0x10,%eax
add    %esi,%ebp
add    $0x2f,%ebp
test   %eax,%eax
cmovns %eax,%ebp
sar    $0x5,%ebp
mov    %r8d,%eax
shr    $0x5,%eax
and    $0x3f,%eax
mov    %eax,%esi
shl    $0x8,%esi
sub    %eax,%esi
lea    0x20(%rsi),%eax
shr    $0x6,%eax
lea    (%rax,%rsi,1),%r11d
add    $0x20,%r11d
and    $0x1f,%r8d
mov    %r8d,%esi
shl    $0x8,%esi
sub    %r8d,%esi
lea    0x10(%rsi),%eax
shr    $0x5,%eax
lea    (%rax,%rsi,1),%r8d
add    $0x10,%r8d
mov    %r12d,0x28(%rsp)
mov    %r12d,%eax
sar    $0xf,%eax
add    %r10d,%r10d
and    $0x6,%r10d
or     %eax,%r10d
mov    %r10d,0x2c(%rsp)
lea    (%r14,%rbp,2),%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rax
add    %esi,%eax
mov    %rax,0x40(%rsp)
mov    %r14,0x70(%rsp)
mov    %rbp,0x58(%rsp)
lea    0x0(%rbp,%r14,2),%eax
cltq
imul   $0x55555556,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
add    %eax,%esi
mov    %rsi,0x78(%rsp)
mov    %edx,0x8(%rsp)
imul   %edx,%ebx
add    %edi,%ebx
shr    $0x6,%r11d
shr    $0x5,%r8d
mov    (%rcx),%r12d
mov    0x4(%rcx),%r13d
mov    0x30(%rcx),%eax
mov    %eax,0x4(%rsp)
lea    (%r15,%r11,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,0x18(%rsp)
lea    (%r9,%r8,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,0x14(%rsp)
mov    %r15,0x68(%rsp)
mov    %r11,0x50(%rsp)
lea    (%r11,%r15,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,0x20(%rsp)
mov    %r9,0x60(%rsp)
mov    %r8,0x48(%rsp)
lea    (%r8,%r9,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,0x1c(%rsp)
xor    %r15d,%r15d
movq   $0xfffffffffffffff0,0x30(%rsp)
ff ff
xor    %ebp,%ebp
xor    %eax,%eax
jmp    136c <DecompressBlockDXT5+0x25c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x38(%rsp),%rax
add    $0x1,%rax
mov    0xc(%rsp),%ebp
add    $0x8,%ebp
add    $0xc,%r15
addq   $0xc,0x30(%rsp)
mov    0x10(%rsp),%ebx
add    0x8(%rsp),%ebx
cmp    $0x4,%rax
je     1529 <DecompressBlockDXT5+0x419>
mov    %rax,0x38(%rsp)
mov    %ebx,0x10(%rsp)
mov    %ebx,%r14d
xor    %ebx,%ebx
mov    %ebp,0xc(%rsp)
jmp    13b4 <DecompressBlockDXT5+0x2a4>
mov    0x78(%rsp),%rdi
mov    0x20(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    %eax,%ecx
call   1030 <PackRGBA@plt>
movslq %r14d,%r14
mov    0x80(%rsp),%rcx
mov    %eax,(%rcx,%r14,4)
add    $0x2,%ebp
add    $0x3,%rbx
add    $0x1,%r14d
cmp    $0xc,%rbx
je     1340 <DecompressBlockDXT5+0x230>
lea    (%r15,%rbx,1),%rax
cmp    $0xc,%rax
ja     13d0 <DecompressBlockDXT5+0x2c0>
lea    (%r15,%rbx,1),%ecx
mov    0x28(%rsp),%edx
jmp    13ed <DecompressBlockDXT5+0x2dd>
nopl   0x0(%rax,%rax,1)
lea    (%r15,%rbx,1),%rax
add    $0xfffffffffffffff1,%rax
mov    0x2c(%rsp),%edx
test   %rax,%rax
je     13f2 <DecompressBlockDXT5+0x2e2>
mov    0x30(%rsp),%rax
lea    (%rax,%rbx,1),%ecx
mov    0x24(%rsp),%edx
sar    %cl,%edx
and    $0x7,%edx
mov    %r12d,%eax
test   %edx,%edx
je     1401 <DecompressBlockDXT5+0x2f1>
mov    %r13d,%eax
cmp    $0x1,%edx
jne    1440 <DecompressBlockDXT5+0x330>
mov    0x4(%rsp),%ecx
mov    %ecx,%edx
mov    %ebp,%ecx
sar    %cl,%edx
and    $0x3,%edx
lea    0xbeb(%rip),%rsi
movslq (%rsi,%rdx,4),%rcx
add    %rsi,%rcx
jmp    *%rcx
mov    0x70(%rsp),%rdi
mov    0x68(%rsp),%rsi
mov    0x60(%rsp),%rdx
jmp    138d <DecompressBlockDXT5+0x27d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %r13d,%r12d
jle    1490 <DecompressBlockDXT5+0x380>
mov    $0x8,%eax
sub    %edx,%eax
imul   %r12d,%eax
add    $0xffffffff,%edx
imul   %r13d,%edx
add    %eax,%edx
movslq %edx,%rax
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x2,%eax
mov    0x4(%rsp),%ecx
mov    %ecx,%esi
mov    %ebp,%ecx
sar    %cl,%esi
add    %edx,%eax
and    $0x3,%esi
lea    0xb79(%rip),%rdx
movslq (%rdx,%rsi,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
cmp    $0x6,%edx
je     14f2 <DecompressBlockDXT5+0x3e2>
cmp    $0x7,%edx
jne    14f9 <DecompressBlockDXT5+0x3e9>
mov    0x4(%rsp),%eax
mov    %eax,%edx
mov    %ebp,%ecx
sar    %cl,%edx
mov    $0xff,%eax
and    $0x3,%edx
lea    0xb4d(%rip),%rsi
movslq (%rsi,%rdx,4),%rcx
add    %rsi,%rcx
jmp    *%rcx
nopl   0x0(%rax)
mov    0x58(%rsp),%rdi
mov    0x50(%rsp),%rsi
mov    0x48(%rsp),%rdx
jmp    138d <DecompressBlockDXT5+0x27d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x40(%rsp),%rdi
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
jmp    138d <DecompressBlockDXT5+0x27d>
xor    %eax,%eax
jmp    1401 <DecompressBlockDXT5+0x2f1>
mov    $0x6,%eax
sub    %edx,%eax
imul   %r12d,%eax
add    $0xffffffff,%edx
imul   %r13d,%edx
add    %eax,%edx
movslq %edx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
jmp    1401 <DecompressBlockDXT5+0x2f1>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @DecompressBlockDXT5(i32 %0, i32 %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%33 = load i32*, i32** %9
%34 = load i32, i32* %33
store i32 %34, i32* %11
%35 = load i32*, i32** %9
%36 = getelementptr inbounds i32, i32* %35, i64 1
%37 = load i32, i32* %36
store i32 %37, i32* %12
%38 = load i32*, i32** %9
%39 = getelementptr inbounds i32, i32* %38, i64 2
store i32* %39, i32** %13
%40 = load i32*, i32** %13
%41 = getelementptr inbounds i32, i32* %40, i64 2
%42 = load i32, i32* %41
%43 = load i32*, i32** %13
%44 = getelementptr inbounds i32, i32* %43, i64 3
%45 = load i32, i32* %44
%46 = shl i32 %45, 8
%47 = or i32 %42, %46
%48 = load i32*, i32** %13
%49 = getelementptr inbounds i32, i32* %48, i64 4
%50 = load i32, i32* %49
%51 = shl i32 %50, 16
%52 = or i32 %47, %51
%53 = load i32*, i32** %13
%54 = getelementptr inbounds i32, i32* %53, i64 5
%55 = load i32, i32* %54
%56 = shl i32 %55, 24
%57 = or i32 %52, %56
store i32 %57, i32* %14
%58 = load i32*, i32** %13
%59 = getelementptr inbounds i32, i32* %58, i64 0
%60 = load i32, i32* %59
%61 = load i32*, i32** %13
%62 = getelementptr inbounds i32, i32* %61, i64 1
%63 = load i32, i32* %62
%64 = shl i32 %63, 8
%65 = or i32 %60, %64
store i32 %65, i32* %15
%66 = load i32*, i32** %9
%67 = getelementptr inbounds i32, i32* %66, i64 8
%68 = load i32, i32* %67
store i32 %68, i32* %16
%69 = load i32*, i32** %9
%70 = getelementptr inbounds i32, i32* %69, i64 10
%71 = load i32, i32* %70
store i32 %71, i32* %17
%72 = load i32, i32* %16
%73 = ashr i32 %72, 11
%74 = mul nsw i32 %73, 255
%75 = add nsw i32 %74, 16
store i32 %75, i32* %26
%76 = load i32, i32* %26
%77 = sdiv i32 %76, 32
%78 = load i32, i32* %26
%79 = add nsw i32 %77, %78
%80 = sdiv i32 %79, 32
store i32 %80, i32* %18
%81 = load i32, i32* %16
%82 = and i32 %81, 2016
%83 = ashr i32 %82, 5
%84 = mul nsw i32 %83, 255
%85 = add nsw i32 %84, 32
store i32 %85, i32* %26
%86 = load i32, i32* %26
%87 = sdiv i32 %86, 64
%88 = load i32, i32* %26
%89 = add nsw i32 %87, %88
%90 = sdiv i32 %89, 64
store i32 %90, i32* %19
%91 = load i32, i32* %16
%92 = and i32 %91, 31
%93 = mul nsw i32 %92, 255
%94 = add nsw i32 %93, 16
store i32 %94, i32* %26
%95 = load i32, i32* %26
%96 = sdiv i32 %95, 32
%97 = load i32, i32* %26
%98 = add nsw i32 %96, %97
%99 = sdiv i32 %98, 32
store i32 %99, i32* %20
%100 = load i32, i32* %17
%101 = ashr i32 %100, 11
%102 = mul nsw i32 %101, 255
%103 = add nsw i32 %102, 16
store i32 %103, i32* %26
%104 = load i32, i32* %26
%105 = sdiv i32 %104, 32
%106 = load i32, i32* %26
%107 = add nsw i32 %105, %106
%108 = sdiv i32 %107, 32
store i32 %108, i32* %21
%109 = load i32, i32* %17
%110 = and i32 %109, 2016
%111 = ashr i32 %110, 5
%112 = mul nsw i32 %111, 255
%113 = add nsw i32 %112, 32
store i32 %113, i32* %26
%114 = load i32, i32* %26
%115 = sdiv i32 %114, 64
%116 = load i32, i32* %26
%117 = add nsw i32 %115, %116
%118 = sdiv i32 %117, 64
store i32 %118, i32* %22
%119 = load i32, i32* %17
%120 = and i32 %119, 31
%121 = mul nsw i32 %120, 255
%122 = add nsw i32 %121, 16
store i32 %122, i32* %26
%123 = load i32, i32* %26
%124 = sdiv i32 %123, 32
%125 = load i32, i32* %26
%126 = add nsw i32 %124, %125
%127 = sdiv i32 %126, 32
store i32 %127, i32* %23
%128 = load i32*, i32** %9
%129 = getelementptr inbounds i32, i32* %128, i64 12
%130 = load i32, i32* %129
store i32 %130, i32* %27
store i32 0, i32* %25
br label %131
131: ; preds = %292, %5
%132 = load i32, i32* %25
%133 = icmp slt i32 %132, 4
br i1 %133, label %134, label %295
134: ; preds = %131
store i32 0, i32* %24
br label %135
135: ; preds = %288, %134
%136 = load i32, i32* %24
%137 = icmp slt i32 %136, 4
br i1 %137, label %138, label %291
138: ; preds = %135
%139 = load i32, i32* %25
%140 = mul nsw i32 4, %139
%141 = load i32, i32* %24
%142 = add nsw i32 %140, %141
%143 = mul nsw i32 3, %142
store i32 %143, i32* %30
%144 = load i32, i32* %30
%145 = icmp sle i32 %144, 12
br i1 %145, label %146, label %151
146: ; preds = %138
%147 = load i32, i32* %15
%148 = load i32, i32* %30
%149 = ashr i32 %147, %148
%150 = and i32 %149, 7
store i32 %150, i32* %29
br label %168
151: ; preds = %138
%152 = load i32, i32* %30
%153 = icmp eq i32 %152, 15
br i1 %153, label %154, label %161
154: ; preds = %151
%155 = load i32, i32* %15
%156 = ashr i32 %155, 15
%157 = load i32, i32* %14
%158 = shl i32 %157, 1
%159 = and i32 %158, 6
%160 = or i32 %156, %159
store i32 %160, i32* %29
br label %167
161: ; preds = %151
%162 = load i32, i32* %14
%163 = load i32, i32* %30
%164 = sub nsw i32 %163, 16
%165 = ashr i32 %162, %164
%166 = and i32 %165, 7
store i32 %166, i32* %29
br label %167
167: ; preds = %161, %154
br label %168
168: ; preds = %167, %146
%169 = load i32, i32* %29
%170 = icmp eq i32 %169, 0
br i1 %170, label %171, label %173
171: ; preds = %168
%172 = load i32, i32* %11
store i32 %172, i32* %28
br label %216
173: ; preds = %168
%174 = load i32, i32* %29
%175 = icmp eq i32 %174, 1
br i1 %175, label %176, label %178
176: ; preds = %173
%177 = load i32, i32* %12
store i32 %177, i32* %28
br label %215
178: ; preds = %173
%179 = load i32, i32* %11
%180 = load i32, i32* %12
%181 = icmp sgt i32 %179, %180
br i1 %181, label %182, label %193
182: ; preds = %178
%183 = load i32, i32* %29
%184 = sub nsw i32 8, %183
%185 = load i32, i32* %11
%186 = mul nsw i32 %184, %185
%187 = load i32, i32* %29
%188 = sub nsw i32 %187, 1
%189 = load i32, i32* %12
%190 = mul nsw i32 %188, %189
%191 = add nsw i32 %186, %190
%192 = sdiv i32 %191, 7
store i32 %192, i32* %28
br label %214
193: ; preds = %178
%194 = load i32, i32* %29
%195 = icmp eq i32 %194, 6
br i1 %195, label %196, label %197
196: ; preds = %193
store i32 0, i32* %28
br label %213
197: ; preds = %193
%198 = load i32, i32* %29
%199 = icmp eq i32 %198, 7
br i1 %199, label %200, label %201
200: ; preds = %197
store i32 255, i32* %28
br label %212
201: ; preds = %197
%202 = load i32, i32* %29
%203 = sub nsw i32 6, %202
%204 = load i32, i32* %11
%205 = mul nsw i32 %203, %204
%206 = load i32, i32* %29
%207 = sub nsw i32 %206, 1
%208 = load i32, i32* %12
%209 = mul nsw i32 %207, %208
%210 = add nsw i32 %205, %209
%211 = sdiv i32 %210, 5
store i32 %211, i32* %28
br label %212
212: ; preds = %201, %200
br label %213
213: ; preds = %212, %196
br label %214
214: ; preds = %213, %182
br label %215
215: ; preds = %214, %176
br label %216
216: ; preds = %215, %171
%217 = load i32, i32* %27
%218 = load i32, i32* %25
%219 = mul nsw i32 4, %218
%220 = load i32, i32* %24
%221 = add nsw i32 %219, %220
%222 = mul nsw i32 2, %221
%223 = ashr i32 %217, %222
%224 = and i32 %223, 3
store i32 %224, i32* %31
store i32 0, i32* %32
%225 = load i32, i32* %31
switch i32 %225, label %274 [
i32 0, label %226
i32 1, label %232
i32 2, label %238
i32 3, label %256
]
226: ; preds = %216
%227 = load i32, i32* %18
%228 = load i32, i32* %19
%229 = load i32, i32* %20
%230 = load i32, i32* %28
%231 = call i32 @PackRGBA(i32 %227, i32 %228, i32 %229, i32 %230)
store i32 %231, i32* %32
br label %274
232: ; preds = %216
%233 = load i32, i32* %21
%234 = load i32, i32* %22
%235 = load i32, i32* %23
%236 = load i32, i32* %28
%237 = call i32 @PackRGBA(i32 %233, i32 %234, i32 %235, i32 %236)
store i32 %237, i32* %32
br label %274
238: ; preds = %216
%239 = load i32, i32* %18
%240 = mul nsw i32 2, %239
%241 = load i32, i32* %21
%242 = add nsw i32 %240, %241
%243 = sdiv i32 %242, 3
%244 = load i32, i32* %19
%245 = mul nsw i32 2, %244
%246 = load i32, i32* %22
%247 = add nsw i32 %245, %246
%248 = sdiv i32 %247, 3
%249 = load i32, i32* %20
%250 = mul nsw i32 2, %249
%251 = load i32, i32* %23
%252 = add nsw i32 %250, %251
%253 = sdiv i32 %252, 3
%254 = load i32, i32* %28
%255 = call i32 @PackRGBA(i32 %243, i32 %248, i32 %253, i32 %254)
store i32 %255, i32* %32
br label %274
256: ; preds = %216
%257 = load i32, i32* %18
%258 = load i32, i32* %21
%259 = mul nsw i32 2, %258
%260 = add nsw i32 %257, %259
%261 = sdiv i32 %260, 3
%262 = load i32, i32* %19
%263 = load i32, i32* %22
%264 = mul nsw i32 2, %263
%265 = add nsw i32 %262, %264
%266 = sdiv i32 %265, 3
%267 = load i32, i32* %20
%268 = load i32, i32* %23
%269 = mul nsw i32 2, %268
%270 = add nsw i32 %267, %269
%271 = sdiv i32 %270, 3
%272 = load i32, i32* %28
%273 = call i32 @PackRGBA(i32 %261, i32 %266, i32 %271, i32 %272)
store i32 %273, i32* %32
br label %274
274: ; preds = %216, %256, %238, %232, %226
%275 = load i32, i32* %32
%276 = load i32*, i32** %10
%277 = load i32, i32* %24
%278 = load i32, i32* %6
%279 = add nsw i32 %277, %278
%280 = load i32, i32* %8
%281 = load i32, i32* %7
%282 = load i32, i32* %25
%283 = add nsw i32 %281, %282
%284 = mul nsw i32 %280, %283
%285 = add nsw i32 %279, %284
%286 = sext i32 %285 to i64
%287 = getelementptr inbounds i32, i32* %276, i64 %286
store i32 %275, i32* %287
br label %288
288: ; preds = %274
%289 = load i32, i32* %24
%290 = add nsw i32 %289, 1
store i32 %290, i32* %24
br label %135
291: ; preds = %135
br label %292
292: ; preds = %291
%293 = load i32, i32* %25
%294 = add nsw i32 %293, 1
store i32 %294, i32* %25
br label %131
295: ; preds = %131
ret void
}

LLVM IR (-O2):
define void @DecompressBlockDXT5(i32 %0, i32 %1, i32 %2, i32* nocapture %3, i32* nocapture writeonly %4) {
%6 = load i32, i32* %3
%7 = getelementptr inbounds i32, i32* %3, i64 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %3, i64 2
%10 = getelementptr inbounds i32, i32* %3, i64 4
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %3, i64 5
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = or i32 %14, %11
%16 = getelementptr inbounds i32, i32* %3, i64 6
%17 = load i32, i32* %16
%18 = shl i32 %17, 16
%19 = or i32 %15, %18
%20 = getelementptr inbounds i32, i32* %3, i64 7
%21 = load i32, i32* %20
%22 = shl i32 %21, 24
%23 = or i32 %19, %22
%24 = load i32, i32* %9
%25 = getelementptr inbounds i32, i32* %3, i64 3
%26 = load i32, i32* %25
%27 = shl i32 %26, 8
%28 = or i32 %27, %24
%29 = getelementptr inbounds i32, i32* %3, i64 8
%30 = load i32, i32* %29
%31 = getelementptr inbounds i32, i32* %3, i64 10
%32 = load i32, i32* %31
%33 = ashr i32 %30, 11
%34 = mul nsw i32 %33, 255
%35 = add nsw i32 %34, 16
%36 = sdiv i32 %35, 32
%37 = add nsw i32 %36, %35
%38 = sdiv i32 %37, 32
%39 = lshr i32 %30, 5
%40 = and i32 %39, 63
%41 = mul nuw nsw i32 %40, 255
%42 = add nuw nsw i32 %41, 32
%43 = lshr i32 %42, 6
%44 = add nuw nsw i32 %43, %42
%45 = lshr i32 %44, 6
%46 = and i32 %30, 31
%47 = mul nuw nsw i32 %46, 255
%48 = add nuw nsw i32 %47, 16
%49 = lshr i32 %48, 5
%50 = add nuw nsw i32 %49, %48
%51 = lshr i32 %50, 5
%52 = ashr i32 %32, 11
%53 = mul nsw i32 %52, 255
%54 = add nsw i32 %53, 16
%55 = sdiv i32 %54, 32
%56 = add nsw i32 %55, %54
%57 = sdiv i32 %56, 32
%58 = lshr i32 %32, 5
%59 = and i32 %58, 63
%60 = mul nuw nsw i32 %59, 255
%61 = add nuw nsw i32 %60, 32
%62 = lshr i32 %61, 6
%63 = add nuw nsw i32 %62, %61
%64 = lshr i32 %63, 6
%65 = and i32 %32, 31
%66 = mul nuw nsw i32 %65, 255
%67 = add nuw nsw i32 %66, 16
%68 = lshr i32 %67, 5
%69 = add nuw nsw i32 %68, %67
%70 = lshr i32 %69, 5
%71 = getelementptr inbounds i32, i32* %3, i64 12
%72 = load i32, i32* %71
%73 = ashr i32 %28, 15
%74 = shl i32 %11, 1
%75 = and i32 %74, 6
%76 = or i32 %73, %75
%77 = icmp sgt i32 %6, %8
%78 = shl nsw i32 %57, 1
%79 = add nsw i32 %78, %38
%80 = sdiv i32 %79, 3
%81 = shl nuw nsw i32 %64, 1
%82 = add nuw nsw i32 %81, %45
%83 = trunc i32 %82 to i16
%84 = udiv i16 %83, 3
%85 = zext i16 %84 to i32
%86 = shl nuw nsw i32 %70, 1
%87 = add nuw nsw i32 %86, %51
%88 = trunc i32 %87 to i16
%89 = udiv i16 %88, 3
%90 = zext i16 %89 to i32
%91 = shl nsw i32 %38, 1
%92 = add nsw i32 %91, %57
%93 = sdiv i32 %92, 3
%94 = shl nuw nsw i32 %45, 1
%95 = add nuw nsw i32 %94, %64
%96 = trunc i32 %95 to i16
%97 = udiv i16 %96, 3
%98 = zext i16 %97 to i32
%99 = shl nuw nsw i32 %51, 1
%100 = add nuw nsw i32 %99, %70
%101 = trunc i32 %100 to i16
%102 = udiv i16 %101, 3
%103 = zext i16 %102 to i32
br label %104
104: ; preds = %5, %170
%105 = phi i64 [ 0, %5 ], [ %171, %170 ]
%106 = shl nsw i64 %105, 2
%107 = trunc i64 %105 to i32
%108 = add i32 %107, %1
%109 = mul i32 %108, %2
%110 = add i32 %109, %0
br label %111
111: ; preds = %104, %162
%112 = phi i64 [ 0, %104 ], [ %168, %162 ]
%113 = add nuw nsw i64 %112, %106
%114 = mul nuw nsw i64 %113, 3
%115 = icmp ult i64 %114, 13
br i1 %115, label %116, label %120
116: ; preds = %111
%117 = trunc i64 %114 to i32
%118 = ashr i32 %28, %117
%119 = and i32 %118, 7
br label %127
120: ; preds = %111
%121 = icmp eq i64 %113, 5
br i1 %121, label %127, label %122
122: ; preds = %120
%123 = trunc i64 %114 to i32
%124 = add i32 %123, -16
%125 = ashr i32 %23, %124
%126 = and i32 %125, 7
br label %127
127: ; preds = %120, %122, %116
%128 = phi i32 [ %119, %116 ], [ %126, %122 ], [ %76, %120 ]
switch i32 %128, label %130 [
i32 0, label %147
i32 1, label %129
]
129: ; preds = %127
br label %147
130: ; preds = %127
br i1 %77, label %131, label %138
131: ; preds = %130
%132 = sub nsw i32 8, %128
%133 = mul nsw i32 %132, %6
%134 = add nsw i32 %128, -1
%135 = mul nsw i32 %134, %8
%136 = add nsw i32 %133, %135
%137 = sdiv i32 %136, 7
br label %147
138: ; preds = %130
switch i32 %128, label %140 [
i32 6, label %147
i32 7, label %139
]
139: ; preds = %138
br label %147
140: ; preds = %138
%141 = sub nsw i32 6, %128
%142 = mul nsw i32 %141, %6
%143 = add nsw i32 %128, -1
%144 = mul nsw i32 %143, %8
%145 = add nsw i32 %142, %144
%146 = sdiv i32 %145, 5
br label %147
147: ; preds = %138, %127, %129, %140, %139, %131
%148 = phi i32 [ %8, %129 ], [ %137, %131 ], [ 255, %139 ], [ %146, %140 ], [ %6, %127 ], [ 0, %138 ]
%149 = trunc i64 %113 to i32
%150 = shl i32 %149, 1
%151 = ashr i32 %72, %150
%152 = and i32 %151, 3
switch i32 %152, label %161 [
i32 0, label %153
i32 1, label %155
i32 2, label %157
i32 3, label %159
]
153: ; preds = %147
%154 = tail call i32 @PackRGBA(i32 %38, i32 %45, i32 %51, i32 %148)
br label %162
155: ; preds = %147
%156 = tail call i32 @PackRGBA(i32 %57, i32 %64, i32 %70, i32 %148)
br label %162
157: ; preds = %147
%158 = tail call i32 @PackRGBA(i32 %93, i32 %98, i32 %103, i32 %148)
br label %162
159: ; preds = %147
%160 = tail call i32 @PackRGBA(i32 %80, i32 %85, i32 %90, i32 %148)
br label %162
161: ; preds = %147
unreachable
162: ; preds = %159, %157, %155, %153
%163 = phi i32 [ %160, %159 ], [ %158, %157 ], [ %156, %155 ], [ %154, %153 ]
%164 = trunc i64 %112 to i32
%165 = add i32 %110, %164
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i32, i32* %4, i64 %166
store i32 %163, i32* %167
%168 = add nuw nsw i64 %112, 1
%169 = icmp eq i64 %168, 4
br i1 %169, label %170, label %111
170: ; preds = %162
%171 = add nuw nsw i64 %105, 1
%172 = icmp eq i64 %171, 4
br i1 %172, label %173, label %104
173: ; preds = %170
ret void
}