#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 */
scalar_t__ crAlloc(int);
int /*<<< orphan*/ crError(char *, ...);
int /*<<< orphan*/ crFree(unsigned char *);
int crStrToInt(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
scalar_t__ toupper(unsigned char);
int main(int argc, char *argv[]) {
  FILE *fp = NULL;
  unsigned char *textureData = NULL;
  char *filename;
  unsigned char *temp;
  int width;
  int height;
  int i;
  if (argc != 5) {
    crError("Usage: %s <file.raw> <width> <height> <outputfile.h>");
  }
  filename = argv[1];
  width = crStrToInt(argv[2]);
  height = crStrToInt(argv[3]);
  fp = fopen(filename, "rb");
  if (!fp) {
    crError("Couldn't open %s", filename);
  }
  textureData = (unsigned char *)crAlloc(4 * width * height);
  fread(textureData, 4 * width * height, 1, fp);
  fclose(fp);
  filename = argv[4];
  fp = fopen(filename, "wb");
  if (!fp) {
    crError("Couldn't open %s", filename);
  }
  for (temp = (unsigned char *)filename; *temp; temp++) {
    if (*temp == '.')
      *temp = '_';
    else
      *temp = (unsigned char)toupper(*temp);
  }
  fprintf(fp, "#ifndef %s\n#define %s\n\n", filename, filename);
  fprintf(fp, "#define %s_WIDTH %d\n", filename, width);
  fprintf(fp, "#define %s_HEIGHT %d\n\n", filename, height);
  fprintf(fp, "static unsigned char raw_bytes[] = {\n");
  i = 0;
  for (temp = textureData; temp < textureData + width * height * 4; temp++) {
    fprintf(fp, "0x%02x", *temp);
    if (temp != textureData + width * height * 4 - 1) {
      fprintf(fp, ",");
    }
    i++;
    if (!(i % 12)) {
      fprintf(fp, "\n");
    } else {
      fprintf(fp, " ");
    }
  }
  fprintf(fp, "};\n\n");
  fprintf(fp, "#endif /* %s */\n", filename);
  fclose(fp);
  crFree(textureData);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11ce <main+0x3e>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1060 <crError@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <crStrToInt@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <crStrToInt@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    122b <main+0x9b>
mov    -0x28(%rbp),%rsi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1060 <crError@plt>
mov    -0x34(%rbp),%edi
shl    $0x2,%edi
imul   -0x38(%rbp),%edi
call   1090 <crAlloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%esi
shl    $0x2,%esi
imul   -0x38(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdcf(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12a0 <main+0x110>
mov    -0x28(%rbp),%rsi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1060 <crError@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     12fb <main+0x16b>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2e,%eax
jne    12d1 <main+0x141>
mov    -0x30(%rbp),%rax
movb   $0x5f,(%rax)
jmp    12e5 <main+0x155>
mov    -0x30(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
jmp    12ea <main+0x15a>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12a8 <main+0x118>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd3e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x38(%rbp),%ecx
lea    0xd39(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd3e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%edx
imul   -0x38(%rbp),%edx
shl    $0x2,%edx
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    1435 <main+0x2a5>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rax
movzbl (%rax),%edx
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%edx
imul   -0x38(%rbp),%edx
shl    $0x2,%edx
movslq %edx,%rdx
add    %rdx,%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
je     13d9 <main+0x249>
mov    -0x18(%rbp),%rdi
lea    0xceb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    140d <main+0x27d>
mov    -0x18(%rbp),%rdi
lea    0xcc3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    141f <main+0x28f>
mov    -0x18(%rbp),%rdi
lea    0xca7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1424 <main+0x294>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1368 <main+0x1d8>
mov    -0x18(%rbp),%rdi
lea    0xc81(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1070 <crFree@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
cmp    $0x5,%edi
je     11d4 <main+0x24>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1060 <crError@plt>
mov    0x8(%r15),%rbp
mov    0x10(%r15),%rdi
call   10c0 <crStrToInt@plt>
mov    %eax,%r13d
mov    0x18(%r15),%rdi
call   10c0 <crStrToInt@plt>
mov    %eax,%r12d
lea    0xe3e(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1218 <main+0x68>
lea    0xe2a(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <crError@plt>
mov    %r13d,%r14d
imul   %r12d,%r14d
shl    $0x2,%r14d
mov    %r14d,%edi
call   10a0 <crAlloc@plt>
mov    %rax,(%rsp)
mov    %rax,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x20(%r15),%r15
lea    0xdf4(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1276 <main+0xc6>
lea    0xdcc(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <crError@plt>
mov    %r15,%rbp
jmp    128f <main+0xdf>
nopl   0x0(%rax,%rax,1)
movzbl %cl,%edi
call   1030 <toupper@plt>
mov    %al,0x0(%rbp)
add    $0x1,%rbp
movzbl 0x0(%rbp),%ecx
mov    $0x5f,%al
cmp    $0x2e,%cl
je     1288 <main+0xd8>
test   %cl,%cl
jne    1280 <main+0xd0>
lea    0xda7(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xda8(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r13d,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xda6(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,0x8(%rsp)
mov    %r15,%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xda1(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
test   %r14d,%r14d
jle    13a0 <main+0x1f0>
movslq %r14d,%rbp
mov    (%rsp),%r12
mov    %r12,%rax
add    %rbp,%rax
mov    %rax,0x10(%rsp)
add    $0xffffffffffffffff,%rbp
mov    $0xffffffff,%r14d
mov    $0x1,%r15d
jmp    134f <main+0x19f>
xchg   %ax,%ax
mov    %rbx,%rsi
call   1080 <fputc@plt>
add    $0x1,%r12
add    $0xffffffff,%r14d
add    $0x1,%r15d
add    $0xffffffffffffffff,%rbp
cmp    0x10(%rsp),%r12
jae    13a0 <main+0x1f0>
mov    %r15d,%r13d
mov    $0xaaaaaaab,%eax
imul   %rax,%r13
shr    $0x23,%r13
movzbl (%r12),%edx
mov    %rbx,%rdi
lea    0xd48(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
test   %rbp,%rbp
je     1387 <main+0x1d7>
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
lea    0x0(%r13,%r13,2),%eax
lea    (%r14,%rax,4),%eax
mov    $0xa,%edi
test   %eax,%eax
je     1330 <main+0x180>
mov    $0x20,%edi
jmp    1330 <main+0x180>
lea    0xd16(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xd02(%rip),%rsi
mov    %rbx,%rdi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    (%rsp),%rdi
call   1070 <crFree@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Usage: %s <file.raw> <width> <height> <outputfile.h>\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [17 x i8] c"Couldn't open %s\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [24 x i8] c"#ifndef %s\0A#define %s\0A\0A\00"
@.str.5 = [21 x i8] c"#define %s_WIDTH %d\0A\00"
@.str.6 = [23 x i8] c"#define %s_HEIGHT %d\0A\0A\00"
@.str.7 = [38 x i8] c"static unsigned char raw_bytes[] = {\0A\00"
@.str.8 = [7 x i8] c"0x%02x\00"
@.str.9 = [2 x i8] c",\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [2 x i8] c" \00"
@.str.12 = [5 x i8] c"};\0A\0A\00"
@.str.13 = [17 x i8] c"#endif /* %s */\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i8* null, i8** %7
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 5
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @crError(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %8
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @crStrToInt(i8* %23)
store i32 %24, i32* %10
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @crStrToInt(i8* %27)
store i32 %28, i32* %11
%29 = load i8*, i8** %8
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = icmp ne i32* %31, null
br i1 %32, label %36, label %33
33: ; preds = %17
%34 = load i8*, i8** %8
%35 = call i32 (i8*, ...) @crError(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %33, %17
%37 = load i32, i32* %10
%38 = mul nsw i32 4, %37
%39 = load i32, i32* %11
%40 = mul nsw i32 %38, %39
%41 = call i64 @crAlloc(i32 %40)
%42 = inttoptr i64 %41 to i8*
store i8* %42, i8** %7
%43 = load i8*, i8** %7
%44 = load i32, i32* %10
%45 = mul nsw i32 4, %44
%46 = load i32, i32* %11
%47 = mul nsw i32 %45, %46
%48 = load i32*, i32** %6
%49 = call i32 @fread(i8* %43, i32 %47, i32 1, i32* %48)
%50 = load i32*, i32** %6
%51 = call i32 @fclose(i32* %50)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 4
%54 = load i8*, i8** %53
store i8* %54, i8** %8
%55 = load i8*, i8** %8
%56 = call i32* @fopen(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %56, i32** %6
%57 = load i32*, i32** %6
%58 = icmp ne i32* %57, null
br i1 %58, label %62, label %59
59: ; preds = %36
%60 = load i8*, i8** %8
%61 = call i32 (i8*, ...) @crError(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %59, %36
%63 = load i8*, i8** %8
store i8* %63, i8** %9
br label %64
64: ; preds = %82, %62
%65 = load i8*, i8** %9
%66 = load i8, i8* %65
%67 = icmp ne i8 %66, 0
br i1 %67, label %68, label %85
68: ; preds = %64
%69 = load i8*, i8** %9
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = icmp eq i32 %71, 46
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = load i8*, i8** %9
store i8 95, i8* %74
br label %81
75: ; preds = %68
%76 = load i8*, i8** %9
%77 = load i8, i8* %76
%78 = call i64 @toupper(i8 zeroext %77)
%79 = trunc i64 %78 to i8
%80 = load i8*, i8** %9
store i8 %79, i8* %80
br label %81
81: ; preds = %75, %73
br label %82
82: ; preds = %81
%83 = load i8*, i8** %9
%84 = getelementptr inbounds i8, i8* %83, i32 1
store i8* %84, i8** %9
br label %64
85: ; preds = %64
%86 = load i32*, i32** %6
%87 = load i8*, i8** %8
%88 = load i8*, i8** %8
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %87, i8* %88)
%90 = load i32*, i32** %6
%91 = load i8*, i8** %8
%92 = load i32, i32* %10
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %91, i32 %92)
%94 = load i32*, i32** %6
%95 = load i8*, i8** %8
%96 = load i32, i32* %11
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %95, i32 %96)
%98 = load i32*, i32** %6
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %12
%100 = load i8*, i8** %7
store i8* %100, i8** %9
br label %101
101: ; preds = %143, %85
%102 = load i8*, i8** %9
%103 = load i8*, i8** %7
%104 = load i32, i32* %10
%105 = load i32, i32* %11
%106 = mul nsw i32 %104, %105
%107 = mul nsw i32 %106, 4
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %103, i64 %108
%110 = icmp ult i8* %102, %109
br i1 %110, label %111, label %146
111: ; preds = %101
%112 = load i32*, i32** %6
%113 = load i8*, i8** %9
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
%116 = call i32 (i32*, i8*, ...) @fprintf(i32* %112, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %115)
%117 = load i8*, i8** %9
%118 = load i8*, i8** %7
%119 = load i32, i32* %10
%120 = load i32, i32* %11
%121 = mul nsw i32 %119, %120
%122 = mul nsw i32 %121, 4
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %118, i64 %123
%125 = getelementptr inbounds i8, i8* %124, i64 -1
%126 = icmp ne i8* %117, %125
br i1 %126, label %127, label %130
127: ; preds = %111
%128 = load i32*, i32** %6
%129 = call i32 (i32*, i8*, ...) @fprintf(i32* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %130
130: ; preds = %127, %111
%131 = load i32, i32* %12
%132 = add nsw i32 %131, 1
store i32 %132, i32* %12
%133 = load i32, i32* %12
%134 = srem i32 %133, 12
%135 = icmp ne i32 %134, 0
br i1 %135, label %139, label %136
136: ; preds = %130
%137 = load i32*, i32** %6
%138 = call i32 (i32*, i8*, ...) @fprintf(i32* %137, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %142
139: ; preds = %130
%140 = load i32*, i32** %6
%141 = call i32 (i32*, i8*, ...) @fprintf(i32* %140, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %142
142: ; preds = %139, %136
br label %143
143: ; preds = %142
%144 = load i8*, i8** %9
%145 = getelementptr inbounds i8, i8* %144, i32 1
store i8* %145, i8** %9
br label %101
146: ; preds = %101
%147 = load i32*, i32** %6
%148 = call i32 (i32*, i8*, ...) @fprintf(i32* %147, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%149 = load i32*, i32** %6
%150 = load i8*, i8** %8
%151 = call i32 (i32*, i8*, ...) @fprintf(i32* %149, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8* %150)
%152 = load i32*, i32** %6
%153 = call i32 @fclose(i32* %152)
%154 = load i8*, i8** %7
%155 = call i32 @crFree(i8* %154)
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
@.str = [53 x i8] c"Usage: %s <file.raw> <width> <height> <outputfile.h>\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [17 x i8] c"Couldn't open %s\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [24 x i8] c"#ifndef %s\0A#define %s\0A\0A\00"
@.str.5 = [21 x i8] c"#define %s_WIDTH %d\0A\00"
@.str.6 = [23 x i8] c"#define %s_HEIGHT %d\0A\0A\00"
@.str.7 = [38 x i8] c"static unsigned char raw_bytes[] = {\0A\00"
@.str.8 = [7 x i8] c"0x%02x\00"
@.str.12 = [5 x i8] c"};\0A\0A\00"
@.str.13 = [17 x i8] c"#endif /* %s */\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @crError(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @crStrToInt(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i32 @crStrToInt(i8* %13)
%15 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = tail call i32 (i8*, ...) @crError(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %19
19: ; preds = %17, %6
%20 = shl i32 %11, 2
%21 = mul i32 %14, %20
%22 = tail call i64 @crAlloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
%24 = tail call i32 @fread(i8* %23, i32 %21, i32 1, i32* %15)
%25 = tail call i32 @fclose(i32* %15)
%26 = getelementptr inbounds i8*, i8** %1, i64 4
%27 = load i8*, i8** %26
%28 = tail call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %32
30: ; preds = %19
%31 = tail call i32 (i8*, ...) @crError(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %32
32: ; preds = %30, %19
br label %33
33: ; preds = %32, %39
%34 = phi i8* [ %41, %39 ], [ %27, %32 ]
%35 = load i8, i8* %34
switch i8 %35, label %36 [
i8 0, label %42
i8 46, label %39
]
36: ; preds = %33
%37 = tail call i64 @toupper(i8 zeroext %35)
%38 = trunc i64 %37 to i8
br label %39
39: ; preds = %33, %36
%40 = phi i8 [ %38, %36 ], [ 95, %33 ]
store i8 %40, i8* %34
%41 = getelementptr inbounds i8, i8* %34, i64 1
br label %33
42: ; preds = %33
%43 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %27, i8* %27)
%44 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %27, i32 %11)
%45 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %27, i32 %14)
%46 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i64 37, i64 1, i32* %28)
%47 = sext i32 %21 to i64
%48 = getelementptr inbounds i8, i8* %23, i64 %47
%49 = icmp sgt i32 %21, 0
br i1 %49, label %50, label %69
50: ; preds = %42
%51 = getelementptr inbounds i8, i8* %48, i64 -1
br label %52
52: ; preds = %50, %61
%53 = phi i32 [ 0, %50 ], [ %62, %61 ]
%54 = phi i8* [ %23, %50 ], [ %67, %61 ]
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %56)
%58 = icmp eq i8* %54, %51
br i1 %58, label %61, label %59
59: ; preds = %52
%60 = tail call i32 @fputc(i32 44, i32* %28)
br label %61
61: ; preds = %59, %52
%62 = add nuw nsw i32 %53, 1
%63 = urem i32 %62, 12
%64 = icmp eq i32 %63, 0
%65 = select i1 %64, i32 10, i32 32
%66 = tail call i32 @fputc(i32 %65, i32* %28)
%67 = getelementptr inbounds i8, i8* %54, i64 1
%68 = icmp ult i8* %67, %48
br i1 %68, label %52, label %69
69: ; preds = %61, %42
%70 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i64 4, i64 1, i32* %28)
%71 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8* %27)
%72 = tail call i32 @fclose(i32* %28)
%73 = tail call i32 @crFree(i8* %23)
ret i32 0
}