#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
char *calloc(int, size_t);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int run(char *fileName) {
  char nameCopy[(80)];
  char *fileBuffer = NULL, *curPos = NULL, *bufEnd = NULL;
  FILE *inFile = NULL, *outFile = NULL;
  size_t fileSize = 0;
  if (strcmp(".vgz", &(fileName[strlen(fileName) - 4])) == 0) {
    perror(".vgz not supported\n");
    return EXIT_FAILURE;
  }
  strncpy(nameCopy, fileName, (80));
  strncpy(&(nameCopy[strlen(fileName) - 4]), "-ay.vgm", (80));
  inFile = fopen(fileName, "rb"), outFile = fopen(nameCopy, "wb");
  if (inFile == NULL || outFile == NULL) {
    perror("File cannot be opened.\n");
    return EXIT_FAILURE;
  }
  fseek(inFile, 0, SEEK_END);
  fileSize = ftell(inFile);
  fseek(inFile, 0, SEEK_SET);
  fileBuffer = calloc(sizeof(char), fileSize);
  if (fileBuffer == NULL) {
    perror("Cannot initialize file buffer.\n");
    return EXIT_FAILURE;
  }
  fread(fileBuffer, 1, fileSize, inFile);
  fclose(inFile);
  fileBuffer[0x75] = 0x78;
  fileBuffer[0x76] = 0x1E;
  curPos = &(fileBuffer[0xE0]);
  bufEnd = &(fileBuffer[fileSize - 1]);
  while (curPos <= bufEnd) {
    size_t ptrInc;
    switch (curPos[0]) {
    case 0x55:
    case 0x56:
      ptrInc = 3;
      if (curPos[1] >= (char)0x00 && curPos[1] <= (char)0x0F) {
        printf("DEBUG: CONVERTED ADDR 0x%X\r", (curPos - fileBuffer));
        curPos[0] = (char)0xA0;
      }
      break;
    case 0x62:
    case 0x63:
      ptrInc = 1;
      break;
    case 0x57:
    case 0x61:
      ptrInc = 3;
      break;
    case 0x66:
      ptrInc = 1;
      curPos = (bufEnd);
      break;
    case 0x67:
      printf("DEBUG: Curr addr 0x%X\n", curPos - fileBuffer);
      ptrInc = ((*(int *)(curPos + 3)));
      printf("DEBUG: Offset Data Block 0x%X\n", ptrInc);
      curPos += ptrInc + 0x07;
      printf("DEBUG: New addr 0x%X\n", curPos - fileBuffer);
      ptrInc = 0;
      break;
    default:
      if (curPos[0] & 0x70)
        ptrInc = 1;
      else
        ptrInc = 3;
      break;
    }
    curPos += ptrInc;
  }
  fwrite(fileBuffer, 1, fileSize, outFile);
  fclose(outFile);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
movq   $0x0,-0x90(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa0(%rbp),%rsi
sub    $0x4,%eax
cltq
add    %rax,%rsi
lea    0xe1d(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    125b <run+0x9b>
lea    0xe0c(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    157e <run+0x3be>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x4,%eax
cltq
lea    -0x60(%rbp),%rdi
add    %rax,%rdi
lea    0xddc(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xdcf(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x80(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x80(%rbp)
je     12d7 <run+0x117>
cmpq   $0x0,-0x88(%rbp)
jne    12f4 <run+0x134>
lea    0xd95(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    157e <run+0x3be>
mov    -0x80(%rbp),%rdi
mov    0x2ce9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x80(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %rax,-0x90(%rbp)
mov    -0x80(%rbp),%rdi
mov    0x2cb5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x90(%rbp),%rsi
mov    $0x1,%edi
call   1080 <calloc@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1369 <run+0x1a9>
lea    0xd38(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    157e <run+0x3be>
mov    -0x68(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    -0x80(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x80(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x68(%rbp),%rax
movb   $0x78,0x75(%rax)
mov    -0x68(%rbp),%rax
movb   $0x1e,0x76(%rax)
mov    -0x68(%rbp),%rax
add    $0xe0,%rax
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x90(%rbp),%rcx
sub    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
cmp    -0x78(%rbp),%rax
ja     154a <run+0x38a>
mov    -0x70(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffab,%eax
mov    %eax,%ecx
mov    %rcx,-0xa8(%rbp)
sub    $0x12,%eax
ja     1503 <run+0x343>
mov    -0xa8(%rbp),%rax
lea    0xc09(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x3,-0x98(%rbp)
mov    -0x70(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jl     144d <run+0x28d>
mov    -0x70(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xf,%eax
jg     144d <run+0x28d>
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xc6a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x70(%rbp),%rax
movb   $0xa0,(%rax)
jmp    1536 <run+0x376>
movq   $0x1,-0x98(%rbp)
jmp    1536 <run+0x376>
movq   $0x3,-0x98(%rbp)
jmp    1536 <run+0x376>
movq   $0x1,-0x98(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    1536 <run+0x376>
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xc29(%rip),%rdi
call   1070 <printf@plt>
mov    -0x70(%rbp),%rax
movslq 0x3(%rax),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
mov    %eax,%esi
lea    0xc1c(%rip),%rdi
call   1070 <printf@plt>
mov    -0x98(%rbp),%rax
add    $0x7,%rax
add    -0x70(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xc0f(%rip),%rdi
call   1070 <printf@plt>
movq   $0x0,-0x98(%rbp)
jmp    1536 <run+0x376>
mov    -0x70(%rbp),%rax
movsbl (%rax),%eax
and    $0x70,%eax
cmp    $0x0,%eax
je     1526 <run+0x366>
movq   $0x1,-0x98(%rbp)
jmp    1531 <run+0x371>
movq   $0x3,-0x98(%rbp)
jmp    1536 <run+0x376>
mov    -0x98(%rbp),%rax
add    -0x70(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    13bf <run+0x1ff>
mov    -0x68(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
mov    -0x88(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2a4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%rbx
call   1060 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%rsi
add    $0xfffffffffffffffc,%rsi
lea    0xe65(%rip),%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13e2 <run+0x222>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
lea    (%rax,%r14,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe42(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
lea    0xe39(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
mov    %rax,%rbp
lea    0xe2a(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rbp,%rbp
je     13eb <run+0x22b>
mov    %rax,%r14
test   %rax,%rax
je     13eb <run+0x22b>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rbp,%rdi
call   10a0 <ftell@plt>
mov    %rax,%rbx
mov    0x2d50(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1080 <calloc@plt>
test   %rax,%rax
je     13f4 <run+0x234>
mov    %rax,%r15
mov    %r14,0x8(%rsp)
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
movw   $0x1e78,0x75(%r15)
mov    %rbx,%rax
mov    %rbx,(%rsp)
lea    -0x1(%rbx),%rax
cmp    $0xe0,%rax
jge    1320 <run+0x160>
mov    %r15,%rdi
mov    $0x1,%esi
mov    (%rsp),%rdx
mov    0x8(%rsp),%rbx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%rax
lea    (%r15,%rax,1),%r12
add    $0xffffffffffffffff,%r12
mov    %r15,%rbp
add    $0xe0,%rbp
lea    0xcc3(%rip),%r14
jmp    134d <run+0x18d>
nop
mov    $0x3,%ebx
add    %rbx,%rbp
cmp    %r12,%rbp
ja     12e7 <run+0x127>
movsbl 0x0(%rbp),%eax
lea    -0x55(%rax),%ecx
cmp    $0x12,%ecx
ja     1389 <run+0x1c9>
mov    $0x1,%ebx
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
mov    $0x3,%ebx
cmpb   $0xf,0x1(%rbp)
ja     1345 <run+0x185>
mov    %ebp,%esi
sub    %r15d,%esi
lea    0xd2d(%rip),%rdi
call   1070 <printf@plt>
movb   $0xa0,0x0(%rbp)
jmp    1345 <run+0x185>
xor    %ecx,%ecx
test   $0x70,%al
sete   %cl
lea    (%rcx,%rcx,1),%rbx
add    $0x1,%rbx
jmp    1345 <run+0x185>
mov    %r12,%rbp
jmp    1345 <run+0x185>
mov    %ebp,%esi
sub    %r15d,%esi
lea    0xd1c(%rip),%rdi
call   1070 <printf@plt>
movslq 0x3(%rbp),%r13
lea    0xd23(%rip),%rdi
mov    %r13d,%esi
call   1070 <printf@plt>
add    %r13,%rbp
add    $0x7,%rbp
mov    %ebp,%esi
sub    %r15d,%esi
lea    0xd27(%rip),%rdi
call   1070 <printf@plt>
xor    %ebx,%ebx
jmp    1345 <run+0x185>
lea    0xc68(%rip),%rdi
jmp    13fb <run+0x23b>
lea    0xc81(%rip),%rdi
jmp    13fb <run+0x23b>
lea    0xc90(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2bc9(%rip),%rax
jmp    130f <run+0x14f>

LLVM IR (-O0):
@.str = [5 x i8] c".vgz\00"
@.str.1 = [20 x i8] c".vgz not supported\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [8 x i8] c"-ay.vgm\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [24 x i8] c"File cannot be opened.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [32 x i8] c"Cannot initialize file buffer.\0A\00"
@.str.7 = [28 x i8] c"DEBUG: CONVERTED ADDR 0x%X\0D\00"
@.str.8 = [23 x i8] c"DEBUG: Curr addr 0x%X\0A\00"
@.str.9 = [31 x i8] c"DEBUG: Offset Data Block 0x%X\0A\00"
@.str.10 = [22 x i8] c"DEBUG: New addr 0x%X\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @run(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [80 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %3
store i8* null, i8** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i32* null, i32** %8
store i32* null, i32** %9
store i64 0, i64* %10
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %12, i64 %16
%18 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %1
%21 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %2
br label %163
23: ; preds = %1
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%25 = load i8*, i8** %3
%26 = call i32 @strncpy(i8* %24, i8* %25, i32 80)
%27 = load i8*, i8** %3
%28 = call i32 @strlen(i8* %27)
%29 = sub nsw i32 %28, 4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %30
%32 = call i32 @strncpy(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 80)
%33 = load i8*, i8** %3
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %34, i32** %8
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %36, i32** %9
%37 = load i32*, i32** %8
%38 = icmp eq i32* %37, null
br i1 %38, label %42, label %39
39: ; preds = %23
%40 = load i32*, i32** %9
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %39, %23
%43 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
store i32 %44, i32* %2
br label %163
45: ; preds = %39
%46 = load i32*, i32** %8
%47 = load i32, i32* @SEEK_END
%48 = call i32 @fseek(i32* %46, i32 0, i32 %47)
%49 = load i32*, i32** %8
%50 = call i64 @ftell(i32* %49)
store i64 %50, i64* %10
%51 = load i32*, i32** %8
%52 = load i32, i32* @SEEK_SET
%53 = call i32 @fseek(i32* %51, i32 0, i32 %52)
%54 = load i64, i64* %10
%55 = call i8* @calloc(i32 1, i64 %54)
store i8* %55, i8** %5
%56 = load i8*, i8** %5
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %61
58: ; preds = %45
%59 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%60 = load i32, i32* @EXIT_FAILURE
store i32 %60, i32* %2
br label %163
61: ; preds = %45
%62 = load i8*, i8** %5
%63 = load i64, i64* %10
%64 = load i32*, i32** %8
%65 = call i32 @fread(i8* %62, i32 1, i64 %63, i32* %64)
%66 = load i32*, i32** %8
%67 = call i32 @fclose(i32* %66)
%68 = load i8*, i8** %5
%69 = getelementptr inbounds i8, i8* %68, i64 117
store i8 120, i8* %69
%70 = load i8*, i8** %5
%71 = getelementptr inbounds i8, i8* %70, i64 118
store i8 30, i8* %71
%72 = load i8*, i8** %5
%73 = getelementptr inbounds i8, i8* %72, i64 224
store i8* %73, i8** %6
%74 = load i8*, i8** %5
%75 = load i64, i64* %10
%76 = sub i64 %75, 1
%77 = getelementptr inbounds i8, i8* %74, i64 %76
store i8* %77, i8** %7
br label %78
78: ; preds = %151, %61
%79 = load i8*, i8** %6
%80 = load i8*, i8** %7
%81 = icmp ule i8* %79, %80
br i1 %81, label %82, label %155
82: ; preds = %78
%83 = load i8*, i8** %6
%84 = getelementptr inbounds i8, i8* %83, i64 0
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
switch i32 %86, label %141 [
i32 85, label %87
i32 86, label %87
i32 98, label %110
i32 99, label %110
i32 87, label %111
i32 97, label %111
i32 102, label %112
i32 103, label %114
]
87: ; preds = %82, %82
store i64 3, i64* %11
%88 = load i8*, i8** %6
%89 = getelementptr inbounds i8, i8* %88, i64 1
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp sge i32 %91, 0
br i1 %92, label %93, label %109
93: ; preds = %87
%94 = load i8*, i8** %6
%95 = getelementptr inbounds i8, i8* %94, i64 1
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp sle i32 %97, 15
br i1 %98, label %99, label %109
99: ; preds = %93
%100 = load i8*, i8** %6
%101 = load i8*, i8** %5
%102 = ptrtoint i8* %100 to i64
%103 = ptrtoint i8* %101 to i64
%104 = sub i64 %102, %103
%105 = trunc i64 %104 to i32
%106 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %105)
%107 = load i8*, i8** %6
%108 = getelementptr inbounds i8, i8* %107, i64 0
store i8 -96, i8* %108
br label %109
109: ; preds = %99, %93, %87
br label %151
110: ; preds = %82, %82
store i64 1, i64* %11
br label %151
111: ; preds = %82, %82
store i64 3, i64* %11
br label %151
112: ; preds = %82
store i64 1, i64* %11
%113 = load i8*, i8** %7
store i8* %113, i8** %6
br label %151
114: ; preds = %82
%115 = load i8*, i8** %6
%116 = load i8*, i8** %5
%117 = ptrtoint i8* %115 to i64
%118 = ptrtoint i8* %116 to i64
%119 = sub i64 %117, %118
%120 = trunc i64 %119 to i32
%121 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %120)
%122 = load i8*, i8** %6
%123 = getelementptr inbounds i8, i8* %122, i64 3
%124 = bitcast i8* %123 to i32*
%125 = load i32, i32* %124
%126 = sext i32 %125 to i64
store i64 %126, i64* %11
%127 = load i64, i64* %11
%128 = trunc i64 %127 to i32
%129 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %128)
%130 = load i64, i64* %11
%131 = add i64 %130, 7
%132 = load i8*, i8** %6
%133 = getelementptr inbounds i8, i8* %132, i64 %131
store i8* %133, i8** %6
%134 = load i8*, i8** %6
%135 = load i8*, i8** %5
%136 = ptrtoint i8* %134 to i64
%137 = ptrtoint i8* %135 to i64
%138 = sub i64 %136, %137
%139 = trunc i64 %138 to i32
%140 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %139)
store i64 0, i64* %11
br label %151
141: ; preds = %82
%142 = load i8*, i8** %6
%143 = getelementptr inbounds i8, i8* %142, i64 0
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = and i32 %145, 112
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %149
148: ; preds = %141
store i64 1, i64* %11
br label %150
149: ; preds = %141
store i64 3, i64* %11
br label %150
150: ; preds = %149, %148
br label %151
151: ; preds = %150, %114, %112, %111, %110, %109
%152 = load i64, i64* %11
%153 = load i8*, i8** %6
%154 = getelementptr inbounds i8, i8* %153, i64 %152
store i8* %154, i8** %6
br label %78
155: ; preds = %78
%156 = load i8*, i8** %5
%157 = load i64, i64* %10
%158 = load i32*, i32** %9
%159 = call i32 @fwrite(i8* %156, i32 1, i64 %157, i32* %158)
%160 = load i32*, i32** %9
%161 = call i32 @fclose(i32* %160)
%162 = load i32, i32* @EXIT_SUCCESS
store i32 %162, i32* %2
br label %163
163: ; preds = %155, %58, %42, %20
%164 = load i32, i32* %2
ret i32 %164
}

LLVM IR (-O2):
@.str = [5 x i8] c".vgz\00"
@.str.1 = [20 x i8] c".vgz not supported\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [8 x i8] c"-ay.vgm\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [24 x i8] c"File cannot be opened.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [32 x i8] c"Cannot initialize file buffer.\0A\00"
@.str.7 = [28 x i8] c"DEBUG: CONVERTED ADDR 0x%X\0D\00"
@.str.8 = [23 x i8] c"DEBUG: Curr addr 0x%X\0A\00"
@.str.9 = [31 x i8] c"DEBUG: Offset Data Block 0x%X\0A\00"
@.str.10 = [22 x i8] c"DEBUG: New addr 0x%X\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @run(i8* %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, -4
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %90
12: ; preds = %1
%13 = call i32 @strncpy(i8* %3, i8* %0, i32 80)
%14 = call i32 @strlen(i8* %0)
%15 = add nsw i32 %14, -4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %16
%18 = call i32 @strncpy(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 80)
%19 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32* %19, null
%22 = icmp eq i32* %20, null
%23 = or i1 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %12
%25 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %90
26: ; preds = %12
%27 = load i32, i32* @SEEK_END
%28 = call i32 @fseek(i32* %19, i32 0, i32 %27)
%29 = call i64 @ftell(i32* %19)
%30 = load i32, i32* @SEEK_SET
%31 = call i32 @fseek(i32* %19, i32 0, i32 %30)
%32 = call i8* @calloc(i32 1, i64 %29)
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %36
34: ; preds = %26
%35 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %90
36: ; preds = %26
%37 = call i32 @fread(i8* %32, i32 1, i64 %29, i32* %19)
%38 = call i32 @fclose(i32* %19)
%39 = getelementptr inbounds i8, i8* %32, i64 117
store i8 120, i8* %39
%40 = getelementptr inbounds i8, i8* %32, i64 118
store i8 30, i8* %40
%41 = add i64 %29, -1
%42 = getelementptr inbounds i8, i8* %32, i64 %41
%43 = icmp slt i64 %41, 224
br i1 %43, label %87, label %44
44: ; preds = %36
%45 = getelementptr inbounds i8, i8* %32, i64 224
%46 = ptrtoint i8* %32 to i64
br label %47
47: ; preds = %44, %82
%48 = phi i8* [ %45, %44 ], [ %85, %82 ]
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
switch i32 %50, label %78 [
i32 85, label %51
i32 86, label %51
i32 98, label %82
i32 99, label %82
i32 87, label %60
i32 97, label %60
i32 102, label %61
i32 103, label %62
]
51: ; preds = %47, %47
%52 = getelementptr inbounds i8, i8* %48, i64 1
%53 = load i8, i8* %52
%54 = icmp ult i8 %53, 16
br i1 %54, label %55, label %82
55: ; preds = %51
%56 = ptrtoint i8* %48 to i64
%57 = sub i64 %56, %46
%58 = trunc i64 %57 to i32
%59 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %58)
store i8 -96, i8* %48
br label %82
60: ; preds = %47, %47
br label %82
61: ; preds = %47
br label %82
62: ; preds = %47
%63 = ptrtoint i8* %48 to i64
%64 = sub i64 %63, %46
%65 = trunc i64 %64 to i32
%66 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds i8, i8* %48, i64 3
%68 = bitcast i8* %67 to i32*
%69 = load i32, i32* %68
%70 = sext i32 %69 to i64
%71 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %69)
%72 = add nsw i64 %70, 7
%73 = getelementptr inbounds i8, i8* %48, i64 %72
%74 = ptrtoint i8* %73 to i64
%75 = sub i64 %74, %46
%76 = trunc i64 %75 to i32
%77 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %76)
br label %82
78: ; preds = %47
%79 = and i32 %50, 112
%80 = icmp eq i32 %79, 0
%81 = select i1 %80, i64 3, i64 1
br label %82
82: ; preds = %78, %47, %47, %51, %55, %62, %61, %60
%83 = phi i8* [ %73, %62 ], [ %42, %61 ], [ %48, %60 ], [ %48, %55 ], [ %48, %51 ], [ %48, %47 ], [ %48, %47 ], [ %48, %78 ]
%84 = phi i64 [ 0, %62 ], [ 1, %61 ], [ 3, %60 ], [ 3, %55 ], [ 3, %51 ], [ 1, %47 ], [ 1, %47 ], [ %81, %78 ]
%85 = getelementptr inbounds i8, i8* %83, i64 %84
%86 = icmp ugt i8* %85, %42
br i1 %86, label %87, label %47
87: ; preds = %82, %36
%88 = call i32 @fwrite(i8* %32, i32 1, i64 %29, i32* %20)
%89 = call i32 @fclose(i32* %20)
br label %90
90: ; preds = %87, %34, %24, %10
%91 = phi i32* [ @EXIT_FAILURE, %10 ], [ @EXIT_FAILURE, %24 ], [ @EXIT_FAILURE, %34 ], [ @EXIT_SUCCESS, %87 ]
%92 = load i32, i32* %91
ret i32 %92
}