#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 */

/* Variables and functions */
int /*<<< orphan*/ compress_DDS_alpha_block(unsigned char *, unsigned char *);
int /*<<< orphan*/ compress_DDS_color_block(int, unsigned char *,
                                            unsigned char *);
scalar_t__ malloc(int);
unsigned char *convert_image_to_DXT5(const unsigned char *const uncompressed,
                                     int width, int height, int channels,
                                     int *out_size) {
  unsigned char *compressed;
  int i, j, x, y;
  unsigned char ublock[16 * 4];
  unsigned char cblock[8];
  int index = 0, chan_step = 1;
  int block_count = 0, has_alpha;
  *out_size = 0;
  if ((width < 1) || (height < 1) || (NULL == uncompressed) || (channels < 1) ||
      (channels > 4)) {
    return NULL;
  }
  if (channels < 3) {
    chan_step = 0;
  }
  has_alpha = 1 - (channels & 1);
  *out_size = ((width + 3) >> 2) * ((height + 3) >> 2) * 16;
  compressed = (unsigned char *)malloc(*out_size);
  for (j = 0; j < height; j += 4) {
    for (i = 0; i < width; i += 4) {
      int idx = 0;
      int mx = 4, my = 4;
      if (j + 4 >= height) {
        my = height - j;
      }
      if (i + 4 >= width) {
        mx = width - i;
      }
      for (y = 0; y < my; ++y) {
        for (x = 0; x < mx; ++x) {
          ublock[idx++] =
              uncompressed[(j + y) * width * channels + (i + x) * channels];
          ublock[idx++] = uncompressed[(j + y) * width * channels +
                                       (i + x) * channels + chan_step];
          ublock[idx++] =
              uncompressed[(j + y) * width * channels + (i + x) * channels +
                           chan_step + chan_step];
          ublock[idx++] =
              has_alpha * uncompressed[(j + y) * width * channels +
                                       (i + x) * channels + channels - 1] +
              (1 - has_alpha) * 255;
        }
        for (x = mx; x < 4; ++x) {
          ublock[idx++] = ublock[0];
          ublock[idx++] = ublock[1];
          ublock[idx++] = ublock[2];
          ublock[idx++] = ublock[3];
        }
      }
      for (y = my; y < 4; ++y) {
        for (x = 0; x < 4; ++x) {
          ublock[idx++] = ublock[0];
          ublock[idx++] = ublock[1];
          ublock[idx++] = ublock[2];
          ublock[idx++] = ublock[3];
        }
      }
      compress_DDS_alpha_block(ublock, cblock);
      for (x = 0; x < 8; ++x) {
        compressed[index++] = cblock[x];
      }
      ++block_count;
      compress_DDS_color_block(4, ublock, cblock);
      for (x = 0; x < 8; ++x) {
        compressed[index++] = cblock[x];
      }
    }
  }
  return compressed;
}


x86 assembly (clang, -O0):
<convert_image_to_DXT5>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x8c(%rbp)
movl   $0x1,-0x90(%rbp)
movl   $0x0,-0x94(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x1,-0x14(%rbp)
jl     11a8 <convert_image_to_DXT5+0x78>
cmpl   $0x1,-0x18(%rbp)
jl     11a8 <convert_image_to_DXT5+0x78>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     11a8 <convert_image_to_DXT5+0x78>
cmpl   $0x1,-0x1c(%rbp)
jl     11a8 <convert_image_to_DXT5+0x78>
cmpl   $0x4,-0x1c(%rbp)
jle    11b5 <convert_image_to_DXT5+0x85>
movq   $0x0,-0x8(%rbp)
jmp    1615 <convert_image_to_DXT5+0x4e5>
cmpl   $0x3,-0x1c(%rbp)
jge    11c9 <convert_image_to_DXT5+0x99>
movl   $0x0,-0x90(%rbp)
mov    -0x1c(%rbp),%ecx
and    $0x1,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x98(%rbp)
mov    -0x14(%rbp),%ecx
add    $0x3,%ecx
sar    $0x2,%ecx
mov    -0x18(%rbp),%eax
add    $0x3,%eax
sar    $0x2,%eax
imul   %eax,%ecx
shl    $0x4,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    160d <convert_image_to_DXT5+0x4dd>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    15fa <convert_image_to_DXT5+0x4ca>
movl   $0x0,-0x9c(%rbp)
movl   $0x4,-0xa0(%rbp)
movl   $0x4,-0xa4(%rbp)
mov    -0x38(%rbp),%eax
add    $0x4,%eax
cmp    -0x18(%rbp),%eax
jl     1268 <convert_image_to_DXT5+0x138>
mov    -0x18(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x34(%rbp),%eax
add    $0x4,%eax
cmp    -0x14(%rbp),%eax
jl     1283 <convert_image_to_DXT5+0x153>
mov    -0x14(%rbp),%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0xa0(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    147c <convert_image_to_DXT5+0x34c>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xa0(%rbp),%eax
jge    13e0 <convert_image_to_DXT5+0x2b0>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
imul   -0x14(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0x34(%rbp),%edx
add    -0x3c(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
imul   -0x14(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0x34(%rbp),%edx
add    -0x3c(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
add    -0x90(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    -0x40(%rbp),%ecx
imul   -0x14(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0x34(%rbp),%edx
add    -0x3c(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
add    -0x90(%rbp),%ecx
add    -0x90(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x98(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    -0x38(%rbp),%edx
add    -0x40(%rbp),%edx
imul   -0x14(%rbp),%edx
imul   -0x1c(%rbp),%edx
mov    -0x34(%rbp),%esi
add    -0x3c(%rbp),%esi
imul   -0x1c(%rbp),%esi
add    %esi,%edx
add    -0x1c(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
imul   %ecx,%eax
mov    $0x1,%ecx
sub    -0x98(%rbp),%ecx
imul   $0xff,%ecx,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12a0 <convert_image_to_DXT5+0x170>
mov    -0xa0(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1469 <convert_image_to_DXT5+0x339>
mov    -0x80(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x7f(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x7e(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x7d(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    13e9 <convert_image_to_DXT5+0x2b9>
jmp    146e <convert_image_to_DXT5+0x33e>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    128a <convert_image_to_DXT5+0x15a>
mov    -0xa4(%rbp),%eax
mov    %eax,-0x40(%rbp)
cmpl   $0x4,-0x40(%rbp)
jge    1529 <convert_image_to_DXT5+0x3f9>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1516 <convert_image_to_DXT5+0x3e6>
mov    -0x80(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x7f(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x7e(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x7d(%rbp),%cl
mov    -0x9c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x9c(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1496 <convert_image_to_DXT5+0x366>
jmp    151b <convert_image_to_DXT5+0x3eb>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1485 <convert_image_to_DXT5+0x355>
lea    -0x80(%rbp),%rdi
lea    -0x88(%rbp),%rsi
call   1040 <compress_DDS_alpha_block@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x8,-0x3c(%rbp)
jge    157e <convert_image_to_DXT5+0x44e>
movslq -0x3c(%rbp),%rax
mov    -0x88(%rbp,%rax,1),%dl
mov    -0x30(%rbp),%rax
mov    -0x8c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x8c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1540 <convert_image_to_DXT5+0x410>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
lea    -0x80(%rbp),%rsi
lea    -0x88(%rbp),%rdx
mov    $0x4,%edi
call   1030 <compress_DDS_color_block@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x8,-0x3c(%rbp)
jge    15e7 <convert_image_to_DXT5+0x4b7>
movslq -0x3c(%rbp),%rax
mov    -0x88(%rbp,%rax,1),%dl
mov    -0x30(%rbp),%rax
mov    -0x8c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x8c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    15a9 <convert_image_to_DXT5+0x479>
jmp    15ec <convert_image_to_DXT5+0x4bc>
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    1223 <convert_image_to_DXT5+0xf3>
jmp    15ff <convert_image_to_DXT5+0x4cf>
mov    -0x38(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x38(%rbp)
jmp    1210 <convert_image_to_DXT5+0xe0>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_image_to_DXT5>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
mov    %ecx,%r12d
movl   $0x0,(%r8)
lea    -0x5(%r12),%eax
xor    %ecx,%ecx
mov    %rcx,0xb0(%rsp)
cmp    $0xfffffffc,%eax
jb     1b27 <convert_image_to_DXT5+0x9f7>
mov    %rdi,%rbx
test   %rdi,%rdi
je     1b27 <convert_image_to_DXT5+0x9f7>
test   %esi,%esi
jle    1b27 <convert_image_to_DXT5+0x9f7>
mov    %edx,%r14d
mov    %r14,%rax
test   %eax,%eax
jle    1b27 <convert_image_to_DXT5+0x9f7>
xor    %ebp,%ebp
cmp    $0x3,%r12d
setae  %bpl
mov    %r12d,%r15d
and    $0x1,%r15d
mov    %r15d,%r13d
xor    $0x1,%r13d
add    $0x3,%eax
shr    $0x2,%eax
lea    0x0(,%rsi,4),%ecx
mov    %ecx,0x28(%rsp)
lea    0xc(,%rsi,4),%edi
and    $0xfffffff0,%edi
imul   %eax,%edi
mov    %edi,(%r8)
mov    %rsi,0xc0(%rsp)
call   1050 <malloc@plt>
mov    %r14,%rcx
mov    %r13d,%r10d
mov    %rbp,%r11
mov    0xc0(%rsp),%r9
mov    %rax,0xb0(%rsp)
mov    %r15d,%r13d
shl    $0x8,%r13d
sub    %r15d,%r13d
add    %ebp,%ebp
movd   %r10d,%xmm0
pshufd $0x0,%xmm0,%xmm8
movd   %r13d,%xmm0
pshufd $0x0,%xmm0,%xmm9
lea    -0x1(%r12),%r8d
mov    %r12d,%edx
imul   %r9d,%edx
mov    %rdx,0x178(%rsp)
lea    0x0(,%rdx,4),%edx
mov    %edx,0xcc(%rsp)
lea    0x0(,%r12,4),%edx
mov    %edx,0xe0(%rsp)
mov    %r12d,%r15d
shl    $0x4,%r15d
movl   $0x1,0x24(%rsp)
xor    %eax,%eax
mov    %rax,0xa8(%rsp)
mov    $0xffffffff,%eax
pshufd $0xf5,%xmm8,%xmm10
movdqa 0xd9c(%rip),%xmm11
mov    $0x4,%r14d
xor    %edx,%edx
mov    %r11d,%esi
mov    %r11d,0x20(%rsp)
mov    %ebp,%esi
mov    %ebp,0x10(%rsp)
xor    %esi,%esi
movl   $0x0,0x48(%rsp)
xor    %edi,%edi
mov    %r11,0x110(%rsp)
mov    %r10d,0x4c(%rsp)
mov    %rbp,0x108(%rsp)
mov    %rcx,0x120(%rsp)
movdqa %xmm8,0x1a0(%rsp)
movdqa %xmm9,0x190(%rsp)
movdqa %xmm10,0x180(%rsp)
jmp    1334 <convert_image_to_DXT5+0x204>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xd4(%rsp),%esi
add    $0x1,%esi
mov    0x2c(%rsp),%r8d
mov    0xcc(%rsp),%ecx
add    %ecx,%r8d
add    %ecx,%edx
mov    %edx,0x10(%rsp)
add    %ecx,0x20(%rsp)
mov    0xd8(%rsp),%edx
add    %ecx,%edx
mov    0x28(%rsp),%ecx
add    %ecx,0x24(%rsp)
mov    0xa8(%rsp),%rdi
add    %ecx,%edi
mov    %rdi,0xa8(%rsp)
add    $0x4,%r14d
add    $0xfffffffc,%eax
mov    0x120(%rsp),%rcx
mov    0xd0(%rsp),%edi
cmp    %ecx,%edi
jge    1b27 <convert_image_to_DXT5+0x9f7>
mov    %r8d,0x2c(%rsp)
mov    %r14d,0xe8(%rsp)
mov    %eax,0xec(%rsp)
cmp    %r14d,%ecx
mov    %rcx,%r8
cmovl  %r8d,%r14d
add    %eax,%r14d
mov    %r14d,0xe4(%rsp)
mov    0x28(%rsp),%eax
mov    %eax,%ecx
mov    %esi,0xd4(%rsp)
imul   %esi,%ecx
mov    %ecx,%esi
or     %r11d,%esi
mov    %rsi,0x128(%rsp)
mov    %ebp,%esi
mov    %rcx,0x130(%rsp)
or     %ecx,%esi
mov    %esi,0xdc(%rsp)
mov    %r8d,%ecx
sub    %edi,%ecx
add    $0x4,%edi
mov    %edi,0xd0(%rsp)
cmp    %r8d,%edi
mov    $0x4,%eax
cmovl  %eax,%ecx
mov    %ecx,0x14(%rsp)
mov    $0xffffffff,%esi
mov    0xa8(%rsp),%rax
mov    %eax,0x44(%rsp)
mov    0x24(%rsp),%eax
mov    %eax,0x40(%rsp)
mov    %edx,0xd8(%rsp)
mov    %edx,0x3c(%rsp)
mov    0x20(%rsp),%eax
mov    %eax,0x38(%rsp)
mov    0x10(%rsp),%eax
mov    %eax,0x34(%rsp)
mov    0x2c(%rsp),%eax
mov    %eax,0x30(%rsp)
xor    %edi,%edi
mov    $0x4,%ecx
xor    %eax,%eax
mov    %rax,0xb8(%rsp)
xor    %r8d,%r8d
jmp    1588 <convert_image_to_DXT5+0x458>
lea    0x60(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <compress_DDS_alpha_block@plt>
movslq 0x48(%rsp),%rbp
mov    (%rsp),%al
mov    0xb0(%rsp),%r14
mov    %al,(%r14,%rbp,1)
mov    0x1(%rsp),%al
mov    %al,0x1(%r14,%rbp,1)
mov    0x2(%rsp),%al
mov    %al,0x2(%r14,%rbp,1)
mov    0x3(%rsp),%al
mov    %al,0x3(%r14,%rbp,1)
mov    0x4(%rsp),%al
mov    %al,0x4(%r14,%rbp,1)
mov    0x5(%rsp),%al
mov    %al,0x5(%r14,%rbp,1)
mov    0x6(%rsp),%al
mov    %al,0x6(%r14,%rbp,1)
mov    0x7(%rsp),%al
lea    0x8(%rbp),%edx
mov    %edx,0x18(%rsp)
mov    %al,0x7(%r14,%rbp,1)
mov    $0x4,%edi
lea    0x60(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <compress_DDS_color_block@plt>
movslq 0x18(%rsp),%rax
mov    (%rsp),%cl
mov    %cl,(%r14,%rax,1)
mov    0x1(%rsp),%cl
mov    %cl,0x1(%r14,%rax,1)
mov    0x2(%rsp),%cl
mov    %cl,0x2(%r14,%rax,1)
mov    0x3(%rsp),%cl
mov    %cl,0x3(%r14,%rax,1)
mov    0x4(%rsp),%cl
mov    %cl,0x4(%r14,%rax,1)
mov    0x5(%rsp),%cl
mov    %cl,0x5(%r14,%rax,1)
mov    0x6(%rsp),%cl
mov    %cl,0x6(%r14,%rax,1)
mov    0x7(%rsp),%cl
mov    %cl,0x7(%r14,%rax,1)
lea    0x10(%rbp),%eax
mov    %eax,0x48(%rsp)
mov    0xb8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0xb8(%rsp)
mov    0xf4(%rsp),%ecx
add    $0x4,%ecx
mov    0xf8(%rsp),%edi
add    $0xfffffffc,%edi
mov    0xe0(%rsp),%eax
add    %eax,0x30(%rsp)
add    %eax,0x34(%rsp)
add    %eax,0x38(%rsp)
add    %eax,0x3c(%rsp)
addl   $0x4,0x40(%rsp)
addl   $0x4,0x44(%rsp)
mov    0x138(%rsp),%rsi
add    $0xfffffffc,%esi
mov    0xf0(%rsp),%eax
mov    %eax,%r8d
mov    0xc0(%rsp),%r9
cmp    %r9d,%eax
mov    0x110(%rsp),%r11
mov    0x4c(%rsp),%r10d
mov    0x108(%rsp),%rbp
movdqa 0x1a0(%rsp),%xmm8
movdqa 0x190(%rsp),%xmm9
mov    0xec(%rsp),%eax
movdqa 0x180(%rsp),%xmm10
movdqa 0xa8a(%rip),%xmm11
mov    0xe8(%rsp),%r14d
mov    0x10(%rsp),%edx
jge    12d0 <convert_image_to_DXT5+0x1a0>
cmp    %ecx,%r9d
mov    %ecx,0xf4(%rsp)
cmovl  %r9d,%ecx
lea    0x4(%r8),%edx
cmp    %edx,%r9d
mov    %edx,%eax
cmovl  %r9d,%eax
mov    %r9d,%r14d
sub    %r8d,%r14d
mov    %edx,0xf0(%rsp)
cmp    %r9d,%edx
mov    $0x4,%edx
cmovl  %edx,%r14d
cmpl   $0x0,0x14(%rsp)
mov    %rsi,0x138(%rsp)
mov    %edi,0xf8(%rsp)
jle    1a60 <convert_image_to_DXT5+0x930>
lea    (%rcx,%rsi,1),%edx
mov    %edx,0xfc(%rsp)
add    %edi,%ecx
movslq %ecx,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rcx,0x150(%rsp)
mov    0xb8(%rsp),%rcx
lea    0x0(,%rcx,4),%ecx
sub    %ecx,%eax
movslq %eax,%rcx
lea    -0x1(%rcx),%rax
mov    %rax,0x170(%rsp)
mov    0x130(%rsp),%rax
add    %r8d,%eax
mov    %rax,0x168(%rsp)
mov    0x128(%rsp),%rax
add    %r8d,%eax
mov    %rax,0x160(%rsp)
add    0xdc(%rsp),%r8d
mov    %r8,0x158(%rsp)
mov    %r14d,%edi
movslq %r14d,%r14
mov    %rcx,%rax
mov    %rcx,0x118(%rsp)
and    $0xfffffffffffffff0,%rcx
mov    %rcx,0x148(%rsp)
lea    0x0(,%rcx,4),%rax
mov    %rax,0x140(%rsp)
xor    %esi,%esi
mov    0x44(%rsp),%eax
mov    %eax,%r8d
mov    0x40(%rsp),%eax
mov    %rax,0x18(%rsp)
mov    0x3c(%rsp),%eax
mov    %eax,0x5c(%rsp)
mov    0x38(%rsp),%eax
mov    %eax,0x58(%rsp)
mov    0x34(%rsp),%eax
mov    %eax,0x54(%rsp)
mov    0x30(%rsp),%eax
mov    %eax,0x50(%rsp)
xor    %ecx,%ecx
mov    %edi,0x100(%rsp)
jmp    16fc <convert_image_to_DXT5+0x5cc>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x104(%rsp),%ecx
add    $0x1,%ecx
mov    0x178(%rsp),%rax
add    %eax,0x50(%rsp)
add    %eax,0x54(%rsp)
add    %eax,0x58(%rsp)
add    %eax,0x5c(%rsp)
mov    0x18(%rsp),%rax
add    %r9d,%eax
mov    %rax,0x18(%rsp)
add    %r9d,%r8d
cmp    0x14(%rsp),%ecx
jge    1a62 <convert_image_to_DXT5+0x932>
test   %edi,%edi
mov    %ecx,0x104(%rsp)
jle    17a3 <convert_image_to_DXT5+0x673>
mov    %r8,0x8(%rsp)
movslq %esi,%r8
cmpl   $0x10,0x118(%rsp)
10
jae    1800 <convert_image_to_DXT5+0x6d0>
xor    %edx,%edx
mov    %r8,%rsi
mov    0x8(%rsp),%r8
mov    0x18(%rsp),%rax
lea    (%rax,%rdx,1),%edi
imul   %r12d,%edi
add    $0xffffffff,%edi
lea    (%r8,%rdx,1),%ecx
imul   %r12d,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %ecx,%rcx
movzbl (%rbx,%rcx,1),%eax
mov    %al,0x60(%rsp,%rsi,1)
lea    (%r11,%rcx,1),%eax
cltq
movzbl (%rbx,%rax,1),%eax
mov    %al,0x61(%rsp,%rsi,1)
lea    0x0(%rbp,%rcx,1),%eax
cltq
movzbl (%rbx,%rax,1),%eax
mov    %al,0x62(%rsp,%rsi,1)
movslq %edi,%rdi
movzbl (%rbx,%rdi,1),%eax
imul   %r10d,%eax
add    %r13d,%eax
mov    %al,0x63(%rsp,%rsi,1)
add    $0x4,%rsi
add    $0x1,%rdx
add    %r12d,%edi
add    %r12d,%ecx
cmp    %r14,%rdx
jl     1750 <convert_image_to_DXT5+0x620>
mov    0x100(%rsp),%edi
cmp    $0x3,%edi
jg     16c0 <convert_image_to_DXT5+0x590>
movslq %esi,%rcx
lea    0x63(%rsp),%rax
add    %rax,%rcx
mov    0xfc(%rsp),%edx
xchg   %ax,%ax
movzbl 0x60(%rsp),%eax
mov    %al,-0x3(%rcx)
movzbl 0x61(%rsp),%eax
mov    %al,-0x2(%rcx)
movzbl 0x62(%rsp),%eax
mov    %al,-0x1(%rcx)
movzbl 0x63(%rsp),%eax
mov    %al,(%rcx)
add    $0x4,%rcx
add    $0x4,%esi
add    $0x1,%edx
cmp    $0x3,%edx
jl     17c0 <convert_image_to_DXT5+0x690>
jmp    16c0 <convert_image_to_DXT5+0x590>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x1,%r12d
jne    1721 <convert_image_to_DXT5+0x5f1>
imul   %r9d,%ecx
mov    0x168(%rsp),%rax
lea    (%rax,%rcx,1),%edx
mov    0x170(%rsp),%rax
lea    (%rdx,%rax,1),%esi
cmp    %edx,%esi
jl     1721 <convert_image_to_DXT5+0x5f1>
mov    %rax,%rdx
shr    $0x20,%rdx
jne    1721 <convert_image_to_DXT5+0x5f1>
mov    0x160(%rsp),%rsi
add    %ecx,%esi
lea    (%rsi,%rax,1),%edi
cmp    %esi,%edi
jl     1721 <convert_image_to_DXT5+0x5f1>
test   %rdx,%rdx
jne    1721 <convert_image_to_DXT5+0x5f1>
add    0x158(%rsp),%ecx
lea    (%rcx,%rax,1),%esi
cmp    %ecx,%esi
jl     1721 <convert_image_to_DXT5+0x5f1>
test   %rdx,%rdx
jne    1721 <convert_image_to_DXT5+0x5f1>
mov    0x140(%rsp),%rax
lea    (%rax,%r8,1),%rsi
add    %rsp,%r8
add    $0x60,%r8
mov    0x5c(%rsp),%eax
mov    %eax,%r11d
mov    0x58(%rsp),%eax
mov    %eax,%edi
mov    0x54(%rsp),%eax
mov    %eax,%edx
mov    0x50(%rsp),%eax
mov    %eax,%r9d
xor    %r10d,%r10d
mov    0x150(%rsp),%rax
nopw   0x0(%rax,%rax,1)
movslq %r11d,%r11
movdqu (%rbx,%r11,1),%xmm0
movslq %edi,%rdi
movdqu (%rbx,%rdi,1),%xmm2
movslq %edx,%rdx
movdqu (%rbx,%rdx,1),%xmm1
movslq %r9d,%r9
movdqu (%rbx,%r9,1),%xmm4
movdqa %xmm4,%xmm6
punpcklbw %xmm6,%xmm6
movdqa %xmm6,%xmm5
punpcklwd %xmm5,%xmm5
punpckhwd %xmm6,%xmm6
punpckhbw %xmm4,%xmm4
movdqa %xmm4,%xmm7
punpcklwd %xmm7,%xmm7
punpckhwd %xmm4,%xmm4
movdqa %xmm8,%xmm3
pmuludq %xmm4,%xmm3
pshufd $0xe8,%xmm3,%xmm3
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm10,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm3
movdqa %xmm8,%xmm4
pmuludq %xmm7,%xmm4
pshufd $0xe8,%xmm4,%xmm4
pshufd $0xf5,%xmm7,%xmm7
pmuludq %xmm10,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm4
movdqa %xmm8,%xmm7
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pshufd $0xf5,%xmm6,%xmm6
pmuludq %xmm10,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm7
movdqa %xmm8,%xmm6
pmuludq %xmm5,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pshufd $0xf5,%xmm5,%xmm5
pmuludq %xmm10,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm6
paddd  %xmm9,%xmm6
paddd  %xmm9,%xmm7
paddd  %xmm9,%xmm4
paddd  %xmm9,%xmm3
pand   %xmm11,%xmm3
pand   %xmm11,%xmm4
packuswb %xmm3,%xmm4
pand   %xmm11,%xmm7
pand   %xmm11,%xmm6
packuswb %xmm7,%xmm6
packuswb %xmm4,%xmm6
movdqa %xmm1,%xmm3
punpcklbw %xmm6,%xmm3
movdqa %xmm0,%xmm4
punpcklbw %xmm2,%xmm4
movdqa %xmm4,%xmm5
punpcklwd %xmm3,%xmm5
punpckhwd %xmm3,%xmm4
punpckhbw %xmm6,%xmm1
punpckhbw %xmm2,%xmm0
movdqa %xmm0,%xmm2
punpcklwd %xmm1,%xmm2
punpckhwd %xmm1,%xmm0
movdqu %xmm0,0x30(%r8,%r10,4)
movdqu %xmm2,0x20(%r8,%r10,4)
movdqu %xmm4,0x10(%r8,%r10,4)
movdqu %xmm5,(%r8,%r10,4)
add    $0x10,%r10
add    %r15d,%r9d
add    %r15d,%edx
add    %r15d,%edi
add    %r15d,%r11d
cmp    %r10,%rax
jne    18b0 <convert_image_to_DXT5+0x780>
mov    0x148(%rsp),%rax
mov    %rax,%rdx
cmp    0x118(%rsp),%rax
mov    0xc0(%rsp),%r9
mov    0x110(%rsp),%r11
mov    0x4c(%rsp),%r10d
mov    0x108(%rsp),%rbp
mov    0x8(%rsp),%r8
jne    172b <convert_image_to_DXT5+0x5fb>
jmp    179c <convert_image_to_DXT5+0x66c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %esi,%esi
mov    0xe4(%rsp),%eax
cmpl   $0x3,0x14(%rsp)
jg     1400 <convert_image_to_DXT5+0x2d0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %esi,%rcx
movzbl 0x60(%rsp),%edx
mov    %dl,0x60(%rsp,%rcx,1)
movzbl 0x61(%rsp),%edx
mov    %dl,0x61(%rsp,%rcx,1)
movzbl 0x62(%rsp),%edx
mov    %dl,0x62(%rsp,%rcx,1)
movzbl 0x63(%rsp),%edx
mov    %dl,0x63(%rsp,%rcx,1)
movzbl 0x60(%rsp),%edx
mov    %dl,0x64(%rsp,%rcx,1)
movzbl 0x61(%rsp),%edx
mov    %dl,0x65(%rsp,%rcx,1)
movzbl 0x62(%rsp),%edx
mov    %dl,0x66(%rsp,%rcx,1)
movzbl 0x63(%rsp),%edx
mov    %dl,0x67(%rsp,%rcx,1)
movzbl 0x60(%rsp),%edx
mov    %dl,0x68(%rsp,%rcx,1)
movzbl 0x61(%rsp),%edx
mov    %dl,0x69(%rsp,%rcx,1)
movzbl 0x62(%rsp),%edx
mov    %dl,0x6a(%rsp,%rcx,1)
movzbl 0x63(%rsp),%edx
mov    %dl,0x6b(%rsp,%rcx,1)
movzbl 0x60(%rsp),%edx
mov    %dl,0x6c(%rsp,%rcx,1)
movzbl 0x61(%rsp),%edx
mov    %dl,0x6d(%rsp,%rcx,1)
movzbl 0x62(%rsp),%edx
mov    %dl,0x6e(%rsp,%rcx,1)
movzbl 0x63(%rsp),%edx
lea    0x10(%rcx),%esi
mov    %dl,0x6f(%rsp,%rcx,1)
add    $0x1,%eax
cmp    $0x3,%eax
jl     1a80 <convert_image_to_DXT5+0x950>
jmp    1400 <convert_image_to_DXT5+0x2d0>
mov    0xb0(%rsp),%rax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @convert_image_to_DXT5(i8* %0, i32 %1, i32 %2, i32 %3, i32* nocapture writeonly %4) {
%6 = alloca [64 x i8]
%7 = alloca [8 x i8]
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
store i32 0, i32* %4
%10 = icmp slt i32 %1, 1
%11 = icmp slt i32 %2, 1
%12 = or i1 %10, %11
%13 = icmp eq i8* %0, null
%14 = or i1 %13, %12
%15 = add i32 %3, -5
%16 = icmp ult i32 %15, -4
%17 = or i1 %16, %14
br i1 %17, label %345, label %18
18: ; preds = %5
%19 = icmp ugt i32 %3, 2
%20 = zext i1 %19 to i32
%21 = and i32 %3, 1
%22 = xor i32 %21, 1
%23 = add nuw nsw i32 %2, 3
%24 = lshr i32 %23, 2
%25 = shl i32 %1, 2
%26 = add i32 %25, 12
%27 = and i32 %26, -16
%28 = mul i32 %27, %24
store i32 %28, i32* %4
%29 = tail call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
%31 = add nsw i32 %3, -1
%32 = mul nuw nsw i32 %21, 255
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 1
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 2
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 3
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 1
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 2
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 3
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 4
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 5
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 6
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 7
%43 = shl i32 %1, 2
%44 = select i1 %19, i32 2, i32 0
%45 = icmp ne i32 %3, 1
%46 = insertelement <16 x i32> poison, i32 %22, i64 0
%47 = shufflevector <16 x i32> %46, <16 x i32> poison, <16 x i32> zeroinitializer
%48 = insertelement <16 x i32> poison, i32 %32, i64 0
%49 = shufflevector <16 x i32> %48, <16 x i32> poison, <16 x i32> zeroinitializer
br label %50
50: ; preds = %18, %342
%51 = phi i32 [ 0, %18 ], [ %344, %342 ]
%52 = phi i32 [ 0, %18 ], [ %339, %342 ]
%53 = phi i32 [ 0, %18 ], [ %57, %342 ]
%54 = mul i32 %43, %51
%55 = or i32 %54, %20
%56 = or i32 %44, %54
%57 = add nuw nsw i32 %53, 4
%58 = icmp slt i32 %57, %2
%59 = sub nsw i32 %2, %53
%60 = select i1 %58, i32 4, i32 %59
%61 = icmp sgt i32 %60, 0
%62 = icmp slt i32 %60, 4
br label %63
63: ; preds = %50, %288
%64 = phi i32 [ 0, %50 ], [ %341, %288 ]
%65 = phi i32 [ %52, %50 ], [ %339, %288 ]
%66 = phi i32 [ 0, %50 ], [ %81, %288 ]
%67 = add nuw i32 %66, 4
%68 = call i32 @llvm.smin.i32(i32 %1, i32 %67)
%69 = mul i32 %64, -4
%70 = add i32 %68, %69
%71 = sext i32 %70 to i64
%72 = add nuw i32 %66, 4
%73 = call i32 @llvm.smin.i32(i32 %1, i32 %72)
%74 = mul i32 %64, -4
%75 = add i32 %73, %74
%76 = sext i32 %75 to i64
%77 = add nsw i64 %76, -1
%78 = add i32 %54, %66
%79 = add i32 %55, %66
%80 = add i32 %56, %66
%81 = add nuw nsw i32 %66, 4
%82 = icmp slt i32 %81, %1
%83 = sub nsw i32 %1, %66
%84 = select i1 %82, i32 4, i32 %83
br i1 %61, label %85, label %99
85: ; preds = %63
%86 = icmp sgt i32 %84, 0
%87 = icmp slt i32 %84, 4
%88 = sext i32 %84 to i64
%89 = icmp ult i32 %70, 16
%90 = trunc i64 %77 to i32
%91 = icmp ugt i64 %77, 4294967295
%92 = trunc i64 %77 to i32
%93 = icmp ugt i64 %77, 4294967295
%94 = trunc i64 %77 to i32
%95 = icmp ugt i64 %77, 4294967295
%96 = and i64 %71, -16
%97 = shl nsw i64 %96, 2
%98 = icmp eq i64 %96, %71
br label %101
99: ; preds = %230, %63
%100 = phi i32 [ 0, %63 ], [ %231, %230 ]
br i1 %62, label %234, label %288
101: ; preds = %85, %230
%102 = phi i32 [ 0, %85 ], [ %231, %230 ]
%103 = phi i32 [ 0, %85 ], [ %232, %230 ]
%104 = mul i32 %103, %1
%105 = add i32 %78, %104
%106 = add i32 %79, %104
%107 = add i32 %80, %104
br i1 %86, label %108, label %172
108: ; preds = %101
%109 = add nuw nsw i32 %103, %53
%110 = mul nsw i32 %109, %1
%111 = add i32 %110, %66
%112 = sext i32 %102 to i64
br i1 %89, label %166, label %113
113: ; preds = %108
%114 = add i32 %105, %90
%115 = icmp slt i32 %114, %105
%116 = or i1 %115, %91
%117 = add i32 %106, %92
%118 = icmp slt i32 %117, %106
%119 = or i1 %118, %93
%120 = add i32 %107, %94
%121 = icmp slt i32 %120, %107
%122 = or i1 %121, %95
%123 = or i1 %45, %116
%124 = or i1 %123, %119
%125 = or i1 %124, %122
br i1 %125, label %166, label %126
126: ; preds = %113
%127 = add nsw i64 %97, %112
br label %128
128: ; preds = %128, %126
%129 = phi i64 [ 0, %126 ], [ %163, %128 ]
%130 = shl i64 %129, 2
%131 = add i64 %130, %112
%132 = trunc i64 %129 to i32
%133 = add i32 %111, %132
%134 = mul i32 %133, %3
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i8, i8* %0, i64 %135
%137 = bitcast i8* %136 to <16 x i8>*
%138 = load <16 x i8>, <16 x i8>* %137
%139 = add nsw i32 %134, %20
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %0, i64 %140
%142 = bitcast i8* %141 to <16 x i8>*
%143 = load <16 x i8>, <16 x i8>* %142
%144 = add nsw i32 %139, %20
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %0, i64 %145
%147 = bitcast i8* %146 to <16 x i8>*
%148 = load <16 x i8>, <16 x i8>* %147
%149 = add i32 %31, %134
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i8, i8* %0, i64 %150
%152 = bitcast i8* %151 to <16 x i8>*
%153 = load <16 x i8>, <16 x i8>* %152
%154 = zext <16 x i8> %153 to <16 x i32>
%155 = mul nuw nsw <16 x i32> %47, %154
%156 = add nuw nsw <16 x i32> %155, %49
%157 = trunc <16 x i32> %156 to <16 x i8>
%158 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %131
%159 = bitcast i8* %158 to <64 x i8>*
%160 = shufflevector <16 x i8> %138, <16 x i8> %143, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
%161 = shufflevector <16 x i8> %148, <16 x i8> %157, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
%162 = shufflevector <32 x i8> %160, <32 x i8> %161, <64 x i32> <i32 0, i32 16, i32 32, i32 48, i32 1, i32 17, i32 33, i32 49, i32 2, i32 18, i32 34, i32 50, i32 3, i32 19, i32 35, i32 51, i32 4, i32 20, i32 36, i32 52, i32 5, i32 21, i32 37, i32 53, i32 6, i32 22, i32 38, i32 54, i32 7, i32 23, i32 39, i32 55, i32 8, i32 24, i32 40, i32 56, i32 9, i32 25, i32 41, i32 57, i32 10, i32 26, i32 42, i32 58, i32 11, i32 27, i32 43, i32 59, i32 12, i32 28, i32 44, i32 60, i32 13, i32 29, i32 45, i32 61, i32 14, i32 30, i32 46, i32 62, i32 15, i32 31, i32 47, i32 63>
store <64 x i8> %162, <64 x i8>* %159
%163 = add nuw i64 %129, 16
%164 = icmp eq i64 %163, %96
br i1 %164, label %165, label %128
165: ; preds = %128
br i1 %98, label %169, label %166
166: ; preds = %113, %108, %165
%167 = phi i64 [ 0, %113 ], [ 0, %108 ], [ %96, %165 ]
%168 = phi i64 [ %112, %113 ], [ %112, %108 ], [ %127, %165 ]
br label %176
169: ; preds = %176, %165
%170 = phi i64 [ %127, %165 ], [ %207, %176 ]
%171 = trunc i64 %170 to i32
br label %172
172: ; preds = %169, %101
%173 = phi i32 [ %102, %101 ], [ %171, %169 ]
br i1 %87, label %174, label %230
174: ; preds = %172
%175 = sext i32 %173 to i64
br label %211
176: ; preds = %166, %176
%177 = phi i64 [ %209, %176 ], [ %167, %166 ]
%178 = phi i64 [ %207, %176 ], [ %168, %166 ]
%179 = trunc i64 %177 to i32
%180 = add i32 %111, %179
%181 = mul i32 %180, %3
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %0, i64 %182
%184 = load i8, i8* %183
%185 = add nsw i64 %178, 1
%186 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %178
store i8 %184, i8* %186
%187 = add nsw i32 %181, %20
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds i8, i8* %0, i64 %188
%190 = load i8, i8* %189
%191 = add nsw i64 %178, 2
%192 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %185
store i8 %190, i8* %192
%193 = add nsw i32 %187, %20
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds i8, i8* %0, i64 %194
%196 = load i8, i8* %195
%197 = add nsw i64 %178, 3
%198 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %191
store i8 %196, i8* %198
%199 = add i32 %31, %181
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds i8, i8* %0, i64 %200
%202 = load i8, i8* %201
%203 = zext i8 %202 to i32
%204 = mul nuw nsw i32 %22, %203
%205 = add nuw nsw i32 %204, %32
%206 = trunc i32 %205 to i8
%207 = add nsw i64 %178, 4
%208 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %197
store i8 %206, i8* %208
%209 = add nuw nsw i64 %177, 1
%210 = icmp slt i64 %209, %88
br i1 %210, label %176, label %169
211: ; preds = %174, %211
%212 = phi i64 [ %175, %174 ], [ %224, %211 ]
%213 = phi i32 [ %84, %174 ], [ %226, %211 ]
%214 = load i8, i8* %8
%215 = add nsw i64 %212, 1
%216 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %212
store i8 %214, i8* %216
%217 = load i8, i8* %33
%218 = add nsw i64 %212, 2
%219 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %215
store i8 %217, i8* %219
%220 = load i8, i8* %34
%221 = add nsw i64 %212, 3
%222 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %218
store i8 %220, i8* %222
%223 = load i8, i8* %35
%224 = add nsw i64 %212, 4
%225 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %221
store i8 %223, i8* %225
%226 = add nsw i32 %213, 1
%227 = icmp slt i32 %213, 3
br i1 %227, label %211, label %228
228: ; preds = %211
%229 = trunc i64 %224 to i32
br label %230
230: ; preds = %228, %172
%231 = phi i32 [ %173, %172 ], [ %229, %228 ]
%232 = add nuw nsw i32 %103, 1
%233 = icmp slt i32 %232, %60
br i1 %233, label %101, label %99
234: ; preds = %99, %234
%235 = phi i32 [ %284, %234 ], [ %100, %99 ]
%236 = phi i32 [ %286, %234 ], [ %60, %99 ]
%237 = sext i32 %235 to i64
%238 = load i8, i8* %8
%239 = add nsw i64 %237, 1
%240 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %237
store i8 %238, i8* %240
%241 = load i8, i8* %33
%242 = add nsw i64 %237, 2
%243 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %239
store i8 %241, i8* %243
%244 = load i8, i8* %34
%245 = add nsw i64 %237, 3
%246 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %242
store i8 %244, i8* %246
%247 = load i8, i8* %35
%248 = add nsw i64 %237, 4
%249 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %245
store i8 %247, i8* %249
%250 = load i8, i8* %8
%251 = add nsw i64 %237, 5
%252 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %248
store i8 %250, i8* %252
%253 = load i8, i8* %33
%254 = add nsw i64 %237, 6
%255 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %251
store i8 %253, i8* %255
%256 = load i8, i8* %34
%257 = add nsw i64 %237, 7
%258 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %254
store i8 %256, i8* %258
%259 = load i8, i8* %35
%260 = add nsw i64 %237, 8
%261 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %257
store i8 %259, i8* %261
%262 = load i8, i8* %8
%263 = add nsw i64 %237, 9
%264 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %260
store i8 %262, i8* %264
%265 = load i8, i8* %33
%266 = add nsw i64 %237, 10
%267 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %263
store i8 %265, i8* %267
%268 = load i8, i8* %34
%269 = add nsw i64 %237, 11
%270 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %266
store i8 %268, i8* %270
%271 = load i8, i8* %35
%272 = add nsw i64 %237, 12
%273 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %269
store i8 %271, i8* %273
%274 = load i8, i8* %8
%275 = add nsw i64 %237, 13
%276 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %272
store i8 %274, i8* %276
%277 = load i8, i8* %33
%278 = add nsw i64 %237, 14
%279 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %275
store i8 %277, i8* %279
%280 = load i8, i8* %34
%281 = add nsw i64 %237, 15
%282 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %278
store i8 %280, i8* %282
%283 = load i8, i8* %35
%284 = add i32 %235, 16
%285 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %281
store i8 %283, i8* %285
%286 = add nsw i32 %236, 1
%287 = icmp slt i32 %236, 3
br i1 %287, label %234, label %288
288: ; preds = %234, %99
%289 = call i32 @compress_DDS_alpha_block(i8* %8, i8* %9)
%290 = sext i32 %65 to i64
%291 = load i8, i8* %9
%292 = add nsw i64 %290, 1
%293 = getelementptr inbounds i8, i8* %30, i64 %290
store i8 %291, i8* %293
%294 = load i8, i8* %36
%295 = add nsw i64 %290, 2
%296 = getelementptr inbounds i8, i8* %30, i64 %292
store i8 %294, i8* %296
%297 = load i8, i8* %37
%298 = add nsw i64 %290, 3
%299 = getelementptr inbounds i8, i8* %30, i64 %295
store i8 %297, i8* %299
%300 = load i8, i8* %38
%301 = add nsw i64 %290, 4
%302 = getelementptr inbounds i8, i8* %30, i64 %298
store i8 %300, i8* %302
%303 = load i8, i8* %39
%304 = add nsw i64 %290, 5
%305 = getelementptr inbounds i8, i8* %30, i64 %301
store i8 %303, i8* %305
%306 = load i8, i8* %40
%307 = add nsw i64 %290, 6
%308 = getelementptr inbounds i8, i8* %30, i64 %304
store i8 %306, i8* %308
%309 = load i8, i8* %41
%310 = add nsw i64 %290, 7
%311 = getelementptr inbounds i8, i8* %30, i64 %307
store i8 %309, i8* %311
%312 = load i8, i8* %42
%313 = add i32 %65, 8
%314 = getelementptr inbounds i8, i8* %30, i64 %310
store i8 %312, i8* %314
%315 = call i32 @compress_DDS_color_block(i32 4, i8* %8, i8* %9)
%316 = sext i32 %313 to i64
%317 = load i8, i8* %9
%318 = add nsw i64 %316, 1
%319 = getelementptr inbounds i8, i8* %30, i64 %316
store i8 %317, i8* %319
%320 = load i8, i8* %36
%321 = add nsw i64 %316, 2
%322 = getelementptr inbounds i8, i8* %30, i64 %318
store i8 %320, i8* %322
%323 = load i8, i8* %37
%324 = add nsw i64 %316, 3
%325 = getelementptr inbounds i8, i8* %30, i64 %321
store i8 %323, i8* %325
%326 = load i8, i8* %38
%327 = add nsw i64 %316, 4
%328 = getelementptr inbounds i8, i8* %30, i64 %324
store i8 %326, i8* %328
%329 = load i8, i8* %39
%330 = add nsw i64 %316, 5
%331 = getelementptr inbounds i8, i8* %30, i64 %327
store i8 %329, i8* %331
%332 = load i8, i8* %40
%333 = add nsw i64 %316, 6
%334 = getelementptr inbounds i8, i8* %30, i64 %330
store i8 %332, i8* %334
%335 = load i8, i8* %41
%336 = add nsw i64 %316, 7
%337 = getelementptr inbounds i8, i8* %30, i64 %333
store i8 %335, i8* %337
%338 = load i8, i8* %42
%339 = add i32 %65, 16
%340 = getelementptr inbounds i8, i8* %30, i64 %336
store i8 %338, i8* %340
%341 = add i32 %64, 1
br i1 %82, label %63, label %342
342: ; preds = %288
%343 = icmp slt i32 %57, %2
%344 = add i32 %51, 1
br i1 %343, label %50, label %345
345: ; preds = %342, %5
%346 = phi i8* [ null, %5 ], [ %30, %342 ]
ret i8* %346
}