#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 /*<<< orphan*/ Decompress16x3bitIndices(int const *, int *);
int PackRGBA(int, int, int, int);
void DecompressBlockBC3(uint32_t x, uint32_t y, uint32_t stride,
                        const uint8_t *blockStorage, unsigned char *image) {
  uint8_t alpha0, alpha1;
  uint8_t alphaIndices[16];
  uint16_t color0, color1;
  uint8_t r0, g0, b0, r1, g1, b1;
  int i, j;
  uint32_t temp, code;
  alpha0 = *(blockStorage);
  alpha1 = *(blockStorage + 1);
  Decompress16x3bitIndices(blockStorage + 2, alphaIndices);
  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;
      uint8_t colorCode;
      uint32_t finalColor;
      alphaCode = alphaIndices[4 * j + i];
      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;
      }
      *(uint32_t *)(image + sizeof(uint32_t) * (i + x) + (stride * (y + j))) =
          finalColor;
    }
  }
}


x86 assembly (clang, -O0):
<DecompressBlockBC3>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%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),%rdi
add    $0x8,%rdi
lea    -0x70(%rbp),%rsi
call   1030 <Decompress16x3bitIndices@plt>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
sar    $0xb,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x7c(%rbp)
mov    -0x74(%rbp),%eax
and    $0x7e0,%eax
sar    $0x5,%eax
imul   $0xff,%eax,%eax
add    $0x20,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
add    -0x9c(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,-0x80(%rbp)
mov    -0x74(%rbp),%eax
and    $0x1f,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
mov    -0x78(%rbp),%eax
sar    $0xb,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x88(%rbp)
mov    -0x78(%rbp),%eax
and    $0x7e0,%eax
sar    $0x5,%eax
imul   $0xff,%eax,%eax
add    $0x20,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
add    -0x9c(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8c(%rbp)
mov    -0x78(%rbp),%eax
and    $0x1f,%eax
imul   $0xff,%eax,%eax
add    $0x10,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x9c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x90(%rbp)
mov    -0x18(%rbp),%rax
mov    0x30(%rax),%eax
mov    %eax,-0xa0(%rbp)
movl   $0x0,-0x98(%rbp)
cmpl   $0x4,-0x98(%rbp)
jge    15c1 <DecompressBlockBC3+0x4a1>
movl   $0x0,-0x94(%rbp)
cmpl   $0x4,-0x94(%rbp)
jge    15a8 <DecompressBlockBC3+0x488>
mov    -0x98(%rbp),%eax
shl    $0x2,%eax
add    -0x94(%rbp),%eax
cltq
mov    -0x70(%rbp,%rax,4),%eax
mov    %eax,-0xa8(%rbp)
cmpl   $0x0,-0xa8(%rbp)
jne    1333 <DecompressBlockBC3+0x213>
mov    -0x24(%rbp),%eax
mov    %eax,-0xa4(%rbp)
jmp    1403 <DecompressBlockBC3+0x2e3>
cmpl   $0x1,-0xa8(%rbp)
jne    134e <DecompressBlockBC3+0x22e>
mov    -0x28(%rbp),%eax
mov    %eax,-0xa4(%rbp)
jmp    13fe <DecompressBlockBC3+0x2de>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    138b <DecompressBlockBC3+0x26b>
mov    $0x8,%eax
sub    -0xa8(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    -0xa8(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x28(%rbp),%ecx
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0xa4(%rbp)
jmp    13f9 <DecompressBlockBC3+0x2d9>
cmpl   $0x6,-0xa8(%rbp)
jne    13a7 <DecompressBlockBC3+0x287>
movl   $0x0,-0xa4(%rbp)
jmp    13f4 <DecompressBlockBC3+0x2d4>
cmpl   $0x7,-0xa8(%rbp)
jne    13c3 <DecompressBlockBC3+0x2a3>
movl   $0xff,-0xa4(%rbp)
jmp    13ef <DecompressBlockBC3+0x2cf>
mov    $0x6,%eax
sub    -0xa8(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    -0xa8(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x28(%rbp),%ecx
add    %ecx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0xa4(%rbp)
jmp    13f4 <DecompressBlockBC3+0x2d4>
jmp    13f9 <DecompressBlockBC3+0x2d9>
jmp    13fe <DecompressBlockBC3+0x2de>
jmp    1403 <DecompressBlockBC3+0x2e3>
mov    -0xa0(%rbp),%eax
mov    -0x98(%rbp),%ecx
mov    -0x94(%rbp),%esi
mov    %ecx,%edx
mov    %esi,%ecx
lea    (%rcx,%rdx,4),%ecx
add    %cl,%cl
sar    %cl,%eax
and    $0x3,%eax
mov    %eax,-0xac(%rbp)
movl   $0x0,-0xb0(%rbp)
mov    -0xac(%rbp),%eax
mov    %rax,-0xb8(%rbp)
sub    $0x3,%rax
ja     1562 <DecompressBlockBC3+0x442>
mov    -0xb8(%rbp),%rax
lea    0xba8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x7c(%rbp),%edi
mov    -0x80(%rbp),%esi
mov    -0x84(%rbp),%edx
mov    -0xa4(%rbp),%ecx
call   1040 <PackRGBA@plt>
mov    %eax,-0xb0(%rbp)
jmp    1562 <DecompressBlockBC3+0x442>
mov    -0x88(%rbp),%edi
mov    -0x8c(%rbp),%esi
mov    -0x90(%rbp),%edx
mov    -0xa4(%rbp),%ecx
call   1040 <PackRGBA@plt>
mov    %eax,-0xb0(%rbp)
jmp    1562 <DecompressBlockBC3+0x442>
mov    -0x7c(%rbp),%eax
shl    $0x1,%eax
add    -0x88(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x80(%rbp),%eax
shl    $0x1,%eax
add    -0x8c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x84(%rbp),%eax
shl    $0x1,%eax
add    -0x90(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0xa4(%rbp),%ecx
call   1040 <PackRGBA@plt>
mov    %eax,-0xb0(%rbp)
jmp    1562 <DecompressBlockBC3+0x442>
mov    -0x7c(%rbp),%eax
mov    -0x88(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x80(%rbp),%eax
mov    -0x8c(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x84(%rbp),%eax
mov    -0x90(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0xa4(%rbp),%ecx
call   1040 <PackRGBA@plt>
mov    %eax,-0xb0(%rbp)
mov    -0xb0(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    -0x4(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%esi
add    -0x98(%rbp),%esi
imul   %esi,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    12f0 <DecompressBlockBC3+0x1d0>
jmp    15ad <DecompressBlockBC3+0x48d>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    12d9 <DecompressBlockBC3+0x1b9>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DecompressBlockBC3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,%r15
mov    %edx,(%rsp)
mov    %esi,0x8(%rsp)
mov    %edi,%r14d
mov    (%rcx),%r12d
mov    0x4(%rcx),%r13d
lea    0x8(%rcx),%rdi
lea    0x70(%rsp),%rsi
mov    %rsi,0x20(%rsp)
call   1030 <Decompress16x3bitIndices@plt>
mov    0x20(%r15),%ecx
mov    0x28(%r15),%eax
mov    %ecx,%edx
sar    $0xb,%edx
mov    %edx,%esi
shl    $0x8,%esi
sub    %edx,%esi
lea    0x10(%rsi),%edx
lea    0x2f(%rsi),%edi
test   %edx,%edx
cmovns %edx,%edi
sar    $0x5,%edi
lea    (%rdi,%rsi,1),%edx
add    $0x10,%edx
lea    (%rdi,%rsi,1),%ebx
add    $0x2f,%ebx
mov    %r13d,%edi
test   %edx,%edx
cmovns %edx,%ebx
sar    $0x5,%ebx
mov    %ecx,%edx
shr    $0x5,%edx
and    $0x3f,%edx
mov    %edx,%esi
shl    $0x8,%esi
sub    %edx,%esi
lea    0x20(%rsi),%edx
shr    $0x6,%edx
lea    (%rdx,%rsi,1),%r8d
add    $0x20,%r8d
shr    $0x6,%r8d
and    $0x1f,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
sub    %ecx,%edx
lea    0x10(%rdx),%ecx
shr    $0x5,%ecx
lea    (%rcx,%rdx,1),%r9d
add    $0x10,%r9d
shr    $0x5,%r9d
mov    %eax,%ecx
sar    $0xb,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
sub    %ecx,%edx
lea    0x10(%rdx),%ecx
lea    0x2f(%rdx),%esi
test   %ecx,%ecx
cmovns %ecx,%esi
sar    $0x5,%esi
lea    (%rsi,%rdx,1),%ecx
add    $0x10,%ecx
add    %edx,%esi
add    $0x2f,%esi
test   %ecx,%ecx
cmovns %ecx,%esi
sar    $0x5,%esi
mov    %eax,%ecx
shr    $0x5,%ecx
and    $0x3f,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
sub    %ecx,%edx
lea    0x20(%rdx),%ecx
shr    $0x6,%ecx
add    %ecx,%edx
add    $0x20,%edx
shr    $0x6,%edx
and    $0x1f,%eax
mov    %eax,%ecx
shl    $0x8,%ecx
sub    %eax,%ecx
lea    0x10(%rcx),%eax
shr    $0x5,%eax
lea    (%rax,%rcx,1),%ebp
add    $0x10,%ebp
shr    $0x5,%ebp
mov    0x30(%r15),%eax
mov    %eax,0x4(%rsp)
lea    (%rbx,%rsi,2),%eax
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
shr    $0x20,%rcx
add    %eax,%ecx
mov    %rcx,0x38(%rsp)
lea    (%r8,%rdx,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,0x1c(%rsp)
mov    %rbx,0x60(%rsp)
mov    %rsi,0x50(%rsp)
lea    (%rsi,%rbx,2),%eax
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
shr    $0x20,%rcx
add    %eax,%ecx
mov    %rcx,0x68(%rsp)
lea    (%r9,%rbp,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,0x18(%rsp)
movslq %r14d,%rax
movslq 0x8(%rsp),%rcx
movslq (%rsp),%rsi
mov    %rsi,0x28(%rsp)
imul   %rsi,%rcx
lea    (%rcx,%rax,4),%r14
mov    %r8,0x8(%rsp)
mov    %rdx,0x48(%rsp)
lea    (%rdx,%r8,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,(%rsp)
add    0x10(%rsp),%r14
mov    %r9,0x58(%rsp)
mov    %rbp,0x40(%rsp)
lea    0x0(%rbp,%r9,2),%eax
movzwl %ax,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %eax,0x10(%rsp)
xor    %r15d,%r15d
lea    0xcf0(%rip),%rbx
xor    %eax,%eax
mov    %r13d,%ebp
jmp    1342 <DecompressBlockBC3+0x222>
nopw   0x0(%rax,%rax,1)
mov    0x30(%rsp),%rax
add    $0x1,%rax
add    0x28(%rsp),%r14
add    $0x8,%r15
addq   $0x10,0x20(%rsp)
cmp    $0x4,%rax
je     1498 <DecompressBlockBC3+0x378>
mov    %rax,0x30(%rsp)
xor    %r13d,%r13d
jmp    1373 <DecompressBlockBC3+0x253>
nopl   0x0(%rax)
mov    0x68(%rsp),%rdi
mov    (%rsp),%esi
mov    0x10(%rsp),%edx
mov    %eax,%ecx
call   1040 <PackRGBA@plt>
mov    %ebp,%edi
mov    %eax,(%r14,%r13,2)
add    $0x2,%r13
cmp    $0x8,%r13
je     1320 <DecompressBlockBC3+0x200>
mov    0x20(%rsp),%rax
mov    (%rax,%r13,2),%ecx
mov    %r12d,%eax
test   %ecx,%ecx
je     138a <DecompressBlockBC3+0x26a>
mov    %edi,%eax
cmp    $0x1,%ecx
jne    13c0 <DecompressBlockBC3+0x2a0>
lea    (%r15,%r13,1),%ecx
mov    0x4(%rsp),%edx
sar    %cl,%edx
and    $0x3,%edx
movslq (%rbx,%rdx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    0x60(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    0x58(%rsp),%rdx
jmp    135c <DecompressBlockBC3+0x23c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %edi,%r12d
jle    1408 <DecompressBlockBC3+0x2e8>
mov    $0x8,%eax
sub    %ecx,%eax
imul   %r12d,%eax
add    $0xffffffff,%ecx
imul   %edi,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x2,%eax
lea    (%r15,%r13,1),%ecx
mov    0x4(%rsp),%esi
sar    %cl,%esi
add    %edx,%eax
and    $0x3,%esi
movslq (%rbx,%rsi,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
cmp    $0x6,%ecx
je     1462 <DecompressBlockBC3+0x342>
cmp    $0x7,%ecx
jne    1469 <DecompressBlockBC3+0x349>
lea    (%r15,%r13,1),%ecx
mov    0x4(%rsp),%eax
mov    %eax,%edx
sar    %cl,%edx
mov    $0xff,%eax
and    $0x3,%edx
movslq (%rbx,%rdx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
nop
mov    0x50(%rsp),%rdi
mov    0x48(%rsp),%rsi
mov    0x40(%rsp),%rdx
jmp    135c <DecompressBlockBC3+0x23c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x38(%rsp),%rdi
mov    0x1c(%rsp),%esi
mov    0x18(%rsp),%edx
jmp    135c <DecompressBlockBC3+0x23c>
xor    %eax,%eax
jmp    138a <DecompressBlockBC3+0x26a>
mov    $0x6,%eax
sub    %ecx,%eax
imul   %r12d,%eax
add    $0xffffffff,%ecx
imul   %edi,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
jmp    138a <DecompressBlockBC3+0x26a>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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