#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
size_t mul8bit(int, int);
int /*<<< orphan*/ prepare_opt_table(unsigned char *, unsigned char *, int);
int main(void) {
  FILE *fp;
  int i, v;
  unsigned char expand5[32];
  unsigned char expand6[64];
  unsigned char quantRB[256 + 16];
  unsigned char quantG[256 + 16];
  unsigned char omatch5[256][2];
  unsigned char omatch6[256][2];
  fp = fopen("dxt_tables.h", "w");
  fprintf(fp, "#ifndef DXT_TABLES_H\n"
              "#define DXT_TABLES_H\n\n");
  for (i = 0; i < 32; ++i)
    expand5[i] = (i << 3) | (i >> 2);
  for (i = 0; i < 64; ++i)
    expand6[i] = (i << 2) | (i >> 4);
  for (i = 0; i < 256 + 16; ++i) {
    v = i - 8;
    if (v < 0)
      v = 0;
    if (v > 255)
      v = 255;
    quantRB[i] = expand5[mul8bit(v, 31)];
    quantG[i] = expand6[mul8bit(v, 63)];
  }
  fprintf(fp, "static const unsigned char quantRB[256 + 16] =\n"
              "{");
  for (i = 0; i < 256 + 16; ++i) {
    if (i % 8 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "0x%02x, ", quantRB[i]);
  }
  fprintf(fp, "\n};\n\n");
  fprintf(fp, "static const unsigned char quantG[256 + 16] =\n"
              "{");
  for (i = 0; i < 256 + 16; ++i) {
    if (i % 8 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "0x%02x, ", quantG[i]);
  }
  fprintf(fp, "\n};\n\n");
  prepare_opt_table(&omatch5[0][0], expand5, 32);
  prepare_opt_table(&omatch6[0][0], expand6, 64);
  fprintf(fp, "static const unsigned char omatch5[256][2] =\n"
              "{");
  for (i = 0; i < 256; ++i) {
    if (i % 4 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "{0x%02x, 0x%02x}, ", omatch5[i][0], omatch5[i][1]);
  }
  fprintf(fp, "\n};\n\n");
  fprintf(fp, "static const unsigned char omatch6[256][2] =\n"
              "{");
  for (i = 0; i < 256; ++i) {
    if (i % 4 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "{0x%02x, 0x%02x}, ", omatch6[i][0], omatch6[i][1]);
  }
  fprintf(fp, "\n};\n\n");
  fprintf(fp, "#endif\n");
  fclose(fp);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6a0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    11c2 <main+0x72>
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
mov    -0x14(%rbp),%ecx
sar    $0x2,%ecx
or     %ecx,%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1192 <main+0x42>
movl   $0x0,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jge    11f9 <main+0xa9>
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
mov    -0x14(%rbp),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c9 <main+0x79>
movl   $0x0,-0x14(%rbp)
cmpl   $0x110,-0x14(%rbp)
jge    1281 <main+0x131>
mov    -0x14(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1227 <main+0xd7>
movl   $0x0,-0x18(%rbp)
cmpl   $0xff,-0x18(%rbp)
jle    123b <main+0xeb>
movl   $0xff,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x1f,%esi
call   1050 <mul8bit@plt>
mov    -0x40(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x190(%rbp,%rax,1)
mov    -0x18(%rbp),%edi
mov    $0x3f,%esi
call   1050 <mul8bit@plt>
mov    -0x80(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x2a0(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1200 <main+0xb0>
mov    -0x10(%rbp),%rdi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x110,-0x14(%rbp)
jge    12f9 <main+0x1a9>
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12cd <main+0x17d>
mov    -0x10(%rbp),%rdi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
movzbl -0x190(%rbp,%rax,1),%edx
ff
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    129a <main+0x14a>
mov    -0x10(%rbp),%rdi
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x110,-0x14(%rbp)
jge    1383 <main+0x233>
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1357 <main+0x207>
mov    -0x10(%rbp),%rdi
lea    0xd1c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
movzbl -0x2a0(%rbp,%rax,1),%edx
ff
lea    0xd03(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1324 <main+0x1d4>
mov    -0x10(%rbp),%rdi
lea    0xcec(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    -0x4a0(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x20,%edx
call   1060 <prepare_opt_table@plt>
lea    -0x6a0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x40,%edx
call   1060 <prepare_opt_table@plt>
mov    -0x10(%rbp),%rdi
lea    0xce6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1443 <main+0x2f3>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    140b <main+0x2bb>
mov    -0x10(%rbp),%rdi
lea    0xc68(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
movzbl -0x4a0(%rbp,%rax,2),%edx
ff
movslq -0x14(%rbp),%rax
movzbl -0x49f(%rbp,%rax,2),%ecx
ff
lea    0xcb1(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13d8 <main+0x288>
mov    -0x10(%rbp),%rdi
lea    0xc2c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xc92(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    14d9 <main+0x389>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    14a1 <main+0x351>
mov    -0x10(%rbp),%rdi
lea    0xbd2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
movzbl -0x6a0(%rbp,%rax,2),%edx
ff
movslq -0x14(%rbp),%rax
movzbl -0x69f(%rbp,%rax,2),%ecx
ff
lea    0xc1b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    146e <main+0x31e>
mov    -0x10(%rbp),%rdi
lea    0xb96(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xc2b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x6a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x680,%rsp
lea    0xeea(%rip),%rdi
lea    0xef0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
lea    0xee3(%rip),%rdi
mov    $0x2b,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
movaps 0xe5b(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xe60(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe64(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe68(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe6c(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe70(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
xor    %ebx,%ebx
mov    $0x107,%r14d
nopl   (%rax)
cmp    $0x9,%rbx
mov    $0x8,%ebp
cmovae %ebx,%ebp
cmp    $0x107,%ebp
cmovae %r14d,%ebp
add    $0xfffffff8,%ebp
mov    %ebp,%edi
mov    $0x1f,%esi
call   1050 <mul8bit@plt>
movzbl (%rsp,%rax,1),%eax
mov    %al,0x170(%rsp,%rbx,1)
mov    %ebp,%edi
mov    $0x3f,%esi
call   1050 <mul8bit@plt>
movzbl 0x20(%rsp,%rax,1),%eax
mov    %al,0x60(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x110,%rbx
jne    11f0 <main+0x90>
lea    0xe52(%rip),%rdi
mov    $0x30,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xe6a(%rip),%r14
lea    0xe68(%rip),%r15
xor    %ebx,%ebx
jmp    1292 <main+0x132>
nopl   (%rax)
movzbl 0x170(%rsp,%rbx,1),%edx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x110,%rbx
je     12ae <main+0x14e>
test   $0x7,%bl
jne    1270 <main+0x110>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %r12,%rcx
call   1080 <fwrite@plt>
jmp    1270 <main+0x110>
lea    0xe25(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xe12(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xde5(%rip),%r14
lea    0xde3(%rip),%r15
xor    %ebx,%ebx
jmp    131f <main+0x1bf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x60(%rsp,%rbx,1),%edx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x110,%rbx
je     133b <main+0x1db>
test   $0x7,%bl
jne    1300 <main+0x1a0>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %r12,%rcx
call   1080 <fwrite@plt>
jmp    1300 <main+0x1a0>
lea    0xd98(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0x480(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x20,%edx
call   1060 <prepare_opt_table@plt>
lea    0x280(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0x40,%edx
call   1060 <prepare_opt_table@plt>
lea    0xd89(%rip),%rdi
mov    $0x2e,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xd2c(%rip),%r14
lea    0xd98(%rip),%r15
xor    %ebx,%ebx
jmp    13da <main+0x27a>
nopl   0x0(%rax,%rax,1)
movzbl 0x480(%rsp,%rbx,2),%edx
movzbl 0x481(%rsp,%rbx,2),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     13f6 <main+0x296>
test   $0x3,%bl
jne    13b0 <main+0x250>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %r12,%rcx
call   1080 <fwrite@plt>
jmp    13b0 <main+0x250>
lea    0xcdd(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xd3c(%rip),%rdi
mov    $0x2e,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xc9d(%rip),%r14
lea    0xd09(%rip),%r15
xor    %ebx,%ebx
jmp    146a <main+0x30a>
nopw   0x0(%rax,%rax,1)
movzbl 0x280(%rsp,%rbx,2),%edx
movzbl 0x281(%rsp,%rbx,2),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     1486 <main+0x326>
test   $0x3,%bl
jne    1440 <main+0x2e0>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %r12,%rcx
call   1080 <fwrite@plt>
jmp    1440 <main+0x2e0>
lea    0xc4d(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xcdb(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x680,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"dxt_tables.h\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [44 x i8] c"#ifndef DXT_TABLES_H\0A#define DXT_TABLES_H\0A\0A\00"
@.str.3 = [49 x i8] c"static const unsigned char quantRB[256 + 16] =\0A{\00"
@.str.4 = [5 x i8] c"\0A \00"
@.str.5 = [9 x i8] c"0x%02x, \00"
@.str.6 = [6 x i8] c"\0A};\0A\0A\00"
@.str.7 = [48 x i8] c"static const unsigned char quantG[256 + 16] =\0A{\00"
@.str.8 = [47 x i8] c"static const unsigned char omatch5[256][2] =\0A{\00"
@.str.9 = [19 x i8] c"{0x%02x, 0x%02x}, \00"
@.str.10 = [47 x i8] c"static const unsigned char omatch6[256][2] =\0A{\00"
@.str.11 = [8 x i8] c"#endif\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [32 x i8]
%6 = alloca [64 x i8]
%7 = alloca [272 x i8]
%8 = alloca [272 x i8]
%9 = alloca [256 x [2 x i8]]
%10 = alloca [256 x [2 x i8]]
store i32 0, i32* %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %14
14: ; preds = %27, %0
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 32
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = load i32, i32* %3
%19 = shl i32 %18, 3
%20 = load i32, i32* %3
%21 = ashr i32 %20, 2
%22 = or i32 %19, %21
%23 = trunc i32 %22 to i8
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %17
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %14
30: ; preds = %14
store i32 0, i32* %3
br label %31
31: ; preds = %44, %30
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 64
br i1 %33, label %34, label %47
34: ; preds = %31
%35 = load i32, i32* %3
%36 = shl i32 %35, 2
%37 = load i32, i32* %3
%38 = ashr i32 %37, 4
%39 = or i32 %36, %38
%40 = trunc i32 %39 to i8
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %42
store i8 %40, i8* %43
br label %44
44: ; preds = %34
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %31
47: ; preds = %31
store i32 0, i32* %3
br label %48
48: ; preds = %76, %47
%49 = load i32, i32* %3
%50 = icmp slt i32 %49, 272
br i1 %50, label %51, label %79
51: ; preds = %48
%52 = load i32, i32* %3
%53 = sub nsw i32 %52, 8
store i32 %53, i32* %4
%54 = load i32, i32* %4
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %51
store i32 0, i32* %4
br label %57
57: ; preds = %56, %51
%58 = load i32, i32* %4
%59 = icmp sgt i32 %58, 255
br i1 %59, label %60, label %61
60: ; preds = %57
store i32 255, i32* %4
br label %61
61: ; preds = %60, %57
%62 = load i32, i32* %4
%63 = call i64 @mul8bit(i32 %62, i32 31)
%64 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 %67
store i8 %65, i8* %68
%69 = load i32, i32* %4
%70 = call i64 @mul8bit(i32 %69, i32 63)
%71 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = load i32, i32* %3
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [272 x i8], [272 x i8]* %8, i64 0, i64 %74
store i8 %72, i8* %75
br label %76
76: ; preds = %61
%77 = load i32, i32* %3
%78 = add nsw i32 %77, 1
store i32 %78, i32* %3
br label %48
79: ; preds = %48
%80 = load i32*, i32** %2
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %82
82: ; preds = %100, %79
%83 = load i32, i32* %3
%84 = icmp slt i32 %83, 272
br i1 %84, label %85, label %103
85: ; preds = %82
%86 = load i32, i32* %3
%87 = srem i32 %86, 8
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %85
%90 = load i32*, i32** %2
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %92
92: ; preds = %89, %85
%93 = load i32*, i32** %2
%94 = load i32, i32* %3
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [272 x i8], [272 x i8]* %7, i64 0, i64 %95
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %92
%101 = load i32, i32* %3
%102 = add nsw i32 %101, 1
store i32 %102, i32* %3
br label %82
103: ; preds = %82
%104 = load i32*, i32** %2
%105 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%106 = load i32*, i32** %2
%107 = call i32 (i32*, i8*, ...) @fprintf(i32* %106, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %108
108: ; preds = %126, %103
%109 = load i32, i32* %3
%110 = icmp slt i32 %109, 272
br i1 %110, label %111, label %129
111: ; preds = %108
%112 = load i32, i32* %3
%113 = srem i32 %112, 8
%114 = icmp eq i32 %113, 0
br i1 %114, label %115, label %118
115: ; preds = %111
%116 = load i32*, i32** %2
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %118
118: ; preds = %115, %111
%119 = load i32*, i32** %2
%120 = load i32, i32* %3
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [272 x i8], [272 x i8]* %8, i64 0, i64 %121
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %124)
br label %126
126: ; preds = %118
%127 = load i32, i32* %3
%128 = add nsw i32 %127, 1
store i32 %128, i32* %3
br label %108
129: ; preds = %108
%130 = load i32*, i32** %2
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%132 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %9, i64 0, i64 0
%133 = getelementptr inbounds [2 x i8], [2 x i8]* %132, i64 0, i64 0
%134 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%135 = call i32 @prepare_opt_table(i8* %133, i8* %134, i32 32)
%136 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %10, i64 0, i64 0
%137 = getelementptr inbounds [2 x i8], [2 x i8]* %136, i64 0, i64 0
%138 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%139 = call i32 @prepare_opt_table(i8* %137, i8* %138, i32 64)
%140 = load i32*, i32** %2
%141 = call i32 (i32*, i8*, ...) @fprintf(i32* %140, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %142
142: ; preds = %167, %129
%143 = load i32, i32* %3
%144 = icmp slt i32 %143, 256
br i1 %144, label %145, label %170
145: ; preds = %142
%146 = load i32, i32* %3
%147 = srem i32 %146, 4
%148 = icmp eq i32 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %145
%150 = load i32*, i32** %2
%151 = call i32 (i32*, i8*, ...) @fprintf(i32* %150, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %152
152: ; preds = %149, %145
%153 = load i32*, i32** %2
%154 = load i32, i32* %3
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %9, i64 0, i64 %155
%157 = getelementptr inbounds [2 x i8], [2 x i8]* %156, i64 0, i64 0
%158 = load i8, i8* %157
%159 = zext i8 %158 to i32
%160 = load i32, i32* %3
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %9, i64 0, i64 %161
%163 = getelementptr inbounds [2 x i8], [2 x i8]* %162, i64 0, i64 1
%164 = load i8, i8* %163
%165 = zext i8 %164 to i32
%166 = call i32 (i32*, i8*, ...) @fprintf(i32* %153, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %159, i32 %165)
br label %167
167: ; preds = %152
%168 = load i32, i32* %3
%169 = add nsw i32 %168, 1
store i32 %169, i32* %3
br label %142
170: ; preds = %142
%171 = load i32*, i32** %2
%172 = call i32 (i32*, i8*, ...) @fprintf(i32* %171, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%173 = load i32*, i32** %2
%174 = call i32 (i32*, i8*, ...) @fprintf(i32* %173, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %3
br label %175
175: ; preds = %200, %170
%176 = load i32, i32* %3
%177 = icmp slt i32 %176, 256
br i1 %177, label %178, label %203
178: ; preds = %175
%179 = load i32, i32* %3
%180 = srem i32 %179, 4
%181 = icmp eq i32 %180, 0
br i1 %181, label %182, label %185
182: ; preds = %178
%183 = load i32*, i32** %2
%184 = call i32 (i32*, i8*, ...) @fprintf(i32* %183, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %185
185: ; preds = %182, %178
%186 = load i32*, i32** %2
%187 = load i32, i32* %3
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %10, i64 0, i64 %188
%190 = getelementptr inbounds [2 x i8], [2 x i8]* %189, i64 0, i64 0
%191 = load i8, i8* %190
%192 = zext i8 %191 to i32
%193 = load i32, i32* %3
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %10, i64 0, i64 %194
%196 = getelementptr inbounds [2 x i8], [2 x i8]* %195, i64 0, i64 1
%197 = load i8, i8* %196
%198 = zext i8 %197 to i32
%199 = call i32 (i32*, i8*, ...) @fprintf(i32* %186, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %192, i32 %198)
br label %200
200: ; preds = %185
%201 = load i32, i32* %3
%202 = add nsw i32 %201, 1
store i32 %202, i32* %3
br label %175
203: ; preds = %175
%204 = load i32*, i32** %2
%205 = call i32 (i32*, i8*, ...) @fprintf(i32* %204, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%206 = load i32*, i32** %2
%207 = call i32 (i32*, i8*, ...) @fprintf(i32* %206, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%208 = load i32*, i32** %2
%209 = call i32 @fclose(i32* %208)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"dxt_tables.h\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [44 x i8] c"#ifndef DXT_TABLES_H\0A#define DXT_TABLES_H\0A\0A\00"
@.str.3 = [49 x i8] c"static const unsigned char quantRB[256 + 16] =\0A{\00"
@.str.4 = [5 x i8] c"\0A \00"
@.str.5 = [9 x i8] c"0x%02x, \00"
@.str.6 = [6 x i8] c"\0A};\0A\0A\00"
@.str.7 = [48 x i8] c"static const unsigned char quantG[256 + 16] =\0A{\00"
@.str.8 = [47 x i8] c"static const unsigned char omatch5[256][2] =\0A{\00"
@.str.9 = [19 x i8] c"{0x%02x, 0x%02x}, \00"
@.str.10 = [47 x i8] c"static const unsigned char omatch6[256][2] =\0A{\00"
@.str.11 = [8 x i8] c"#endif\0A\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = alloca [64 x i8]
%3 = alloca [272 x i8]
%4 = alloca [272 x i8]
%5 = alloca [256 x [2 x i8]]
%6 = alloca [256 x [2 x i8]]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [272 x i8], [272 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %5, i64 0, i64 0, i64 0
%12 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %6, i64 0, i64 0, i64 0
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 43, i64 1, i32* %13)
%15 = bitcast [32 x i8]* %1 to <16 x i8>*
store <16 x i8> <i8 0, i8 8, i8 16, i8 24, i8 33, i8 41, i8 49, i8 57, i8 66, i8 74, i8 82, i8 90, i8 99, i8 107, i8 115, i8 123>, <16 x i8>* %15
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 16
%17 = bitcast i8* %16 to <16 x i8>*
store <16 x i8> <i8 -124, i8 -116, i8 -108, i8 -100, i8 -91, i8 -83, i8 -75, i8 -67, i8 -58, i8 -50, i8 -42, i8 -34, i8 -25, i8 -17, i8 -9, i8 -1>, <16 x i8>* %17
%18 = bitcast [64 x i8]* %2 to <16 x i8>*
store <16 x i8> <i8 0, i8 4, i8 8, i8 12, i8 16, i8 20, i8 24, i8 28, i8 32, i8 36, i8 40, i8 44, i8 48, i8 52, i8 56, i8 60>, <16 x i8>* %18
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 16
%20 = bitcast i8* %19 to <16 x i8>*
store <16 x i8> <i8 65, i8 69, i8 73, i8 77, i8 81, i8 85, i8 89, i8 93, i8 97, i8 101, i8 105, i8 109, i8 113, i8 117, i8 121, i8 125>, <16 x i8>* %20
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 32
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> <i8 -126, i8 -122, i8 -118, i8 -114, i8 -110, i8 -106, i8 -102, i8 -98, i8 -94, i8 -90, i8 -86, i8 -82, i8 -78, i8 -74, i8 -70, i8 -66>, <16 x i8>* %22
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 48
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> <i8 -61, i8 -57, i8 -53, i8 -49, i8 -45, i8 -41, i8 -37, i8 -33, i8 -29, i8 -25, i8 -21, i8 -17, i8 -13, i8 -9, i8 -5, i8 -1>, <16 x i8>* %24
br label %25
25: ; preds = %0, %25
%26 = phi i64 [ %41, %25 ], [ 0, %0 ]
%27 = icmp ugt i64 %26, 8
%28 = select i1 %27, i64 %26, i64 8
%29 = trunc i64 %28 to i32
%30 = icmp ult i32 %29, 263
%31 = select i1 %30, i32 %29, i32 263
%32 = add nsw i32 %31, -8
%33 = tail call i64 @mul8bit(i32 %32, i32 31)
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = getelementptr inbounds [272 x i8], [272 x i8]* %3, i64 0, i64 %26
store i8 %35, i8* %36
%37 = tail call i64 @mul8bit(i32 %32, i32 63)
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 %26
store i8 %39, i8* %40
%41 = add nuw nsw i64 %26, 1
%42 = icmp eq i64 %41, 272
br i1 %42, label %43, label %25
43: ; preds = %25
%44 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i64 48, i64 1, i32* %13)
br label %45
45: ; preds = %43, %51
%46 = phi i64 [ 0, %43 ], [ %56, %51 ]
%47 = and i64 %46, 7
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %13)
br label %51
51: ; preds = %49, %45
%52 = getelementptr inbounds [272 x i8], [272 x i8]* %3, i64 0, i64 %46
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %54)
%56 = add nuw nsw i64 %46, 1
%57 = icmp eq i64 %56, 272
br i1 %57, label %58, label %45
58: ; preds = %51
%59 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 5, i64 1, i32* %13)
%60 = tail call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i64 47, i64 1, i32* %13)
br label %61
61: ; preds = %58, %67
%62 = phi i64 [ 0, %58 ], [ %72, %67 ]
%63 = and i64 %62, 7
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %13)
br label %67
67: ; preds = %65, %61
%68 = getelementptr inbounds [272 x i8], [272 x i8]* %4, i64 0, i64 %62
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %70)
%72 = add nuw nsw i64 %62, 1
%73 = icmp eq i64 %72, 272
br i1 %73, label %74, label %61
74: ; preds = %67
%75 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 5, i64 1, i32* %13)
%76 = call i32 @prepare_opt_table(i8* %11, i8* %7, i32 32)
%77 = call i32 @prepare_opt_table(i8* %12, i8* %8, i32 64)
%78 = call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i64 46, i64 1, i32* %13)
br label %79
79: ; preds = %74, %85
%80 = phi i64 [ 0, %74 ], [ %93, %85 ]
%81 = and i64 %80, 3
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %13)
br label %85
85: ; preds = %83, %79
%86 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %5, i64 0, i64 %80, i64 0
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %5, i64 0, i64 %80, i64 1
%90 = load i8, i8* %89
%91 = zext i8 %90 to i32
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %88, i32 %91)
%93 = add nuw nsw i64 %80, 1
%94 = icmp eq i64 %93, 256
br i1 %94, label %95, label %79
95: ; preds = %85
%96 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 5, i64 1, i32* %13)
%97 = call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0), i64 46, i64 1, i32* %13)
br label %98
98: ; preds = %95, %104
%99 = phi i64 [ 0, %95 ], [ %112, %104 ]
%100 = and i64 %99, 3
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %98
%103 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %13)
br label %104
104: ; preds = %102, %98
%105 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %6, i64 0, i64 %99, i64 0
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = getelementptr inbounds [256 x [2 x i8]], [256 x [2 x i8]]* %6, i64 0, i64 %99, i64 1
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
%111 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %107, i32 %110)
%112 = add nuw nsw i64 %99, 1
%113 = icmp eq i64 %112, 256
br i1 %113, label %114, label %98
114: ; preds = %104
%115 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 5, i64 1, i32* %13)
%116 = call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i64 7, i64 1, i32* %13)
%117 = call i32 @fclose(i32* %13)
ret i32 0
}