#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*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, unsigned int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
unsigned int ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strchr(char *, char);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Specify file to open\n");
    return (0);
  }
  char *fullpath = argv[1];
  FILE *f = fopen(fullpath, "r");
  if (!f) {
    fprintf(stderr, "Couldn't open file %s\n", fullpath);
    return (0);
  }
  fseek(f, 0, SEEK_END);
  unsigned int length = ftell(f);
  rewind(f);
  unsigned char *buf = (unsigned char *)malloc(length);
  unsigned char *repack = (unsigned char *)malloc(length);
  if (fread(buf, length, 1, f) < 1) {
    fclose(f);
    fprintf(stderr, "Couldn't read file %s\n", fullpath);
    return (0);
  }
  fclose(f);
  unsigned char *p = buf;
  p = buf + 34;
  p = (unsigned char *)strchr((char *)p, '\0') + 1;
  p = (unsigned char *)strchr((char *)p, '\0') + 1;
  p = (unsigned char *)strchr((char *)p, '\0') + 1;
  unsigned paylength = length - (p - buf) - 4;
  printf("// Data payload offset is %d %x\n", (int)(p - buf),
         (unsigned int)(p - buf));
  printf("// Data payload in file is %d bytes\n", paylength);
  printf("// Module 16 -> %d\n", paylength % 16);
  unsigned int frames = paylength / 16;
  unsigned int iter;
  unsigned int reg;
  for (reg = 0; reg < 16; reg++) {
    for (iter = 0; iter < frames; iter++) {
      repack[(iter * 16) + reg] = p[(reg * frames) + iter];
    }
  }
  printf("/* interleaved */\n");
  unsigned int framelimit = 2000;
  printf("#include <avr/pgmspace.h>\n");
  printf("unsigned int framelimit = %d;\n", framelimit);
  printf("const unsigned char song_hacked_ym[] PROGMEM = {\n");
  unsigned int framecount = framelimit;
  unsigned int a;
  unsigned char *data = repack;
  while (framecount) {
    printf("  ");
    for (a = 0; a < 16; a++) {
      printf("0x%02x, ", *data);
      data++;
    }
    printf("\n");
    framecount--;
  }
  printf("};\n");
  printf("unsigned long int song_hacked_fullym_len = %d;\n", paylength);
  printf("unsigned int song_hacked_ym_len = %d;\n", framelimit * 16);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11e3 <main+0x43>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f0 <main+0x350>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1235 <main+0x95>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f0 <main+0x350>
mov    -0x20(%rbp),%rdi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x24(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jge    12c4 <main+0x124>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f0 <main+0x350>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    $0x22,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1050 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1050 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1050 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
sub    $0x4,%rax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%esi
and    $0xf,%esi
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
cmpl   $0x10,-0x50(%rbp)
jae    13f2 <main+0x252>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x48(%rbp),%eax
jae    13df <main+0x23f>
mov    -0x40(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x4c(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
mov    -0x4c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x50(%rbp),%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13a0 <main+0x200>
jmp    13e4 <main+0x244>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    138f <main+0x1ef>
lea    0xca7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x7d0,-0x54(%rbp)
lea    0xca5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x54(%rbp),%esi
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpl   $0x0,-0x58(%rbp)
je     14b6 <main+0x316>
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x10,-0x5c(%rbp)
jae    149a <main+0x2fa>
mov    -0x68(%rbp),%rax
movzbl (%rax),%esi
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1461 <main+0x2c1>
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
jmp    1442 <main+0x2a2>
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xc61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x54(%rbp),%esi
shl    $0x4,%esi
lea    0xc7d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jg     11ef <main+0x2f>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1576 <main+0x3b6>
mov    0x8(%rsi),%rbx
lea    0xe1c(%rip),%rsi
mov    %rbx,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1545 <main+0x385>
mov    %rax,%rbp
mov    %rbx,0x8(%rsp)
mov    0x2dce(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %rbp,%rdi
call   10b0 <ftell@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1090 <rewind@plt>
mov    %r15d,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    %r15d,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
mov    $0x1,%r12d
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1050 <fread@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
call   1060 <fclose@plt>
test   %r13d,%r13d
jle    155a <main+0x39a>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
add    $0x22,%rdi
xor    %r13d,%r13d
xor    %esi,%esi
call   1070 <strchr@plt>
lea    0x1(%rax),%rdi
xor    %esi,%esi
call   1070 <strchr@plt>
lea    0x1(%rax),%rdi
xor    %esi,%esi
call   1070 <strchr@plt>
mov    %rax,%rbp
add    $0x1,%rax
mov    %rax,0x8(%rsp)
mov    %eax,%edx
sub    %ebx,%edx
sub    %edx,%r15d
add    $0xfffffffc,%r15d
lea    0xd7b(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd8c(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15d,%esi
and    $0xf,%esi
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15d,%eax
shr    $0x4,%eax
cmp    $0x2,%eax
cmovae %eax,%r12d
mov    %r12d,%ecx
and    $0xfffffffe,%ecx
add    $0x2,%rbp
mov    %r14,%rdx
add    $0x10,%rdx
jmp    1331 <main+0x171>
nopl   0x0(%rax)
add    $0x1,%r13
add    %rax,%rbp
add    $0x1,%rdx
cmp    $0x10,%r13
je     13a4 <main+0x1e4>
cmp    $0x10,%r15d
jb     1320 <main+0x160>
cmp    $0x20,%r15d
jae    1350 <main+0x190>
xor    %esi,%esi
jmp    137c <main+0x1bc>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdx,%rdi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x1(%rbp,%rsi,1),%ebx
mov    %bl,-0x10(%rdi)
movzbl 0x0(%rbp,%rsi,1),%ebx
mov    %bl,(%rdi)
add    $0x2,%rsi
add    $0x20,%rdi
cmp    %rsi,%rcx
jne    1360 <main+0x1a0>
test   $0x1,%r12b
je     1320 <main+0x160>
mov    %r13,%rdi
imul   %rax,%rdi
add    %rsi,%rdi
mov    0x8(%rsp),%rbx
mov    (%rbx,%rdi,1),%bl
shl    $0x4,%rsi
add    %r13,%rsi
mov    %bl,(%r14,%rsi,1)
jmp    1320 <main+0x160>
lea    0xd77(%rip),%rdi
call   1040 <puts@plt>
lea    0xd7d(%rip),%rdi
call   1040 <puts@plt>
lea    0xcdd(%rip),%rdi
mov    $0x7d0,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd78(%rip),%rdi
call   1040 <puts@plt>
lea    0xcdd(%rip),%r12
lea    0xcd9(%rip),%rbp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl (%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x1(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x2(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x3(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x4(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x5(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x6(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x7(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x8(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0x9(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0xa(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0xb(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0xc(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0xd(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0xe(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movzbl 0xf(%r14,%rbx,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rbx
cmp    $0x7d00,%ebx
jne    13f0 <main+0x230>
lea    0xc65(%rip),%rdi
call   1040 <puts@plt>
lea    0xba5(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xbc4(%rip),%rdi
mov    $0x7d00,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1576 <main+0x3b6>
mov    0x2a8c(%rip),%rax
mov    (%rax),%edi
lea    0xac3(%rip),%rsi
mov    %rbx,%rdx
jmp    156f <main+0x3af>
mov    0x2a77(%rip),%rax
mov    (%rax),%edi
lea    0xac5(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Specify file to open\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Couldn't open file %s\0A\00"
@SEEK_END = global i32 0
@.str.3 = [23 x i8] c"Couldn't read file %s\0A\00"
@.str.4 = [33 x i8] c"// Data payload offset is %d %x\0A\00"
@.str.5 = [37 x i8] c"// Data payload in file is %d bytes\0A\00"
@.str.6 = [20 x i8] c"// Module 16 -> %d\0A\00"
@.str.7 = [19 x i8] c"/* interleaved */\0A\00"
@.str.8 = [27 x i8] c"#include <avr/pgmspace.h>\0A\00"
@.str.9 = [31 x i8] c"unsigned int framelimit = %d;\0A\00"
@.str.10 = [50 x i8] c"const unsigned char song_hacked_ym[] PROGMEM = {\0A\00"
@.str.11 = [3 x i8] c" \00"
@.str.12 = [9 x i8] c"0x%02x, \00"
@.str.13 = [2 x i8] c"\0A\00"
@.str.14 = [4 x i8] c"};\0A\00"
@.str.15 = [48 x i8] c"unsigned long int song_hacked_fullym_len = %d;\0A\00"
@.str.16 = [39 x i8] c"unsigned int song_hacked_ym_len = %d;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %179
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %6
%29 = load i8*, i8** %6
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %7
%31 = load i32*, i32** %7
%32 = icmp ne i32* %31, null
br i1 %32, label %37, label %33
33: ; preds = %25
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %6
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %35)
store i32 0, i32* %3
br label %179
37: ; preds = %25
%38 = load i32*, i32** %7
%39 = load i32, i32* @SEEK_END
%40 = call i32 @fseek(i32* %38, i32 0, i32 %39)
%41 = load i32*, i32** %7
%42 = call i32 @ftell(i32* %41)
store i32 %42, i32* %8
%43 = load i32*, i32** %7
%44 = call i32 @rewind(i32* %43)
%45 = load i32, i32* %8
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to i8*
store i8* %47, i8** %9
%48 = load i32, i32* %8
%49 = call i64 @malloc(i32 %48)
%50 = inttoptr i64 %49 to i8*
store i8* %50, i8** %10
%51 = load i8*, i8** %9
%52 = load i32, i32* %8
%53 = load i32*, i32** %7
%54 = call i32 @fread(i8* %51, i32 %52, i32 1, i32* %53)
%55 = icmp slt i32 %54, 1
br i1 %55, label %56, label %62
56: ; preds = %37
%57 = load i32*, i32** %7
%58 = call i32 @fclose(i32* %57)
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %6
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %60)
store i32 0, i32* %3
br label %179
62: ; preds = %37
%63 = load i32*, i32** %7
%64 = call i32 @fclose(i32* %63)
%65 = load i8*, i8** %9
store i8* %65, i8** %11
%66 = load i8*, i8** %9
%67 = getelementptr inbounds i8, i8* %66, i64 34
store i8* %67, i8** %11
%68 = load i8*, i8** %11
%69 = call i64 @strchr(i8* %68, i8 signext 0)
%70 = inttoptr i64 %69 to i8*
%71 = getelementptr inbounds i8, i8* %70, i64 1
store i8* %71, i8** %11
%72 = load i8*, i8** %11
%73 = call i64 @strchr(i8* %72, i8 signext 0)
%74 = inttoptr i64 %73 to i8*
%75 = getelementptr inbounds i8, i8* %74, i64 1
store i8* %75, i8** %11
%76 = load i8*, i8** %11
%77 = call i64 @strchr(i8* %76, i8 signext 0)
%78 = inttoptr i64 %77 to i8*
%79 = getelementptr inbounds i8, i8* %78, i64 1
store i8* %79, i8** %11
%80 = load i32, i32* %8
%81 = zext i32 %80 to i64
%82 = load i8*, i8** %11
%83 = load i8*, i8** %9
%84 = ptrtoint i8* %82 to i64
%85 = ptrtoint i8* %83 to i64
%86 = sub i64 %84, %85
%87 = sub nsw i64 %81, %86
%88 = sub nsw i64 %87, 4
%89 = trunc i64 %88 to i32
store i32 %89, i32* %12
%90 = load i8*, i8** %11
%91 = load i8*, i8** %9
%92 = ptrtoint i8* %90 to i64
%93 = ptrtoint i8* %91 to i64
%94 = sub i64 %92, %93
%95 = trunc i64 %94 to i32
%96 = load i8*, i8** %11
%97 = load i8*, i8** %9
%98 = ptrtoint i8* %96 to i64
%99 = ptrtoint i8* %97 to i64
%100 = sub i64 %98, %99
%101 = trunc i64 %100 to i32
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %95, i32 %101)
%103 = load i32, i32* %12
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %103)
%105 = load i32, i32* %12
%106 = urem i32 %105, 16
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %12
%109 = udiv i32 %108, 16
store i32 %109, i32* %13
store i32 0, i32* %15
br label %110
110: ; preds = %139, %62
%111 = load i32, i32* %15
%112 = icmp ult i32 %111, 16
br i1 %112, label %113, label %142
113: ; preds = %110
store i32 0, i32* %14
br label %114
114: ; preds = %135, %113
%115 = load i32, i32* %14
%116 = load i32, i32* %13
%117 = icmp ult i32 %115, %116
br i1 %117, label %118, label %138
118: ; preds = %114
%119 = load i8*, i8** %11
%120 = load i32, i32* %15
%121 = load i32, i32* %13
%122 = mul i32 %120, %121
%123 = load i32, i32* %14
%124 = add i32 %122, %123
%125 = zext i32 %124 to i64
%126 = getelementptr inbounds i8, i8* %119, i64 %125
%127 = load i8, i8* %126
%128 = load i8*, i8** %10
%129 = load i32, i32* %14
%130 = mul i32 %129, 16
%131 = load i32, i32* %15
%132 = add i32 %130, %131
%133 = zext i32 %132 to i64
%134 = getelementptr inbounds i8, i8* %128, i64 %133
store i8 %127, i8* %134
br label %135
135: ; preds = %118
%136 = load i32, i32* %14
%137 = add i32 %136, 1
store i32 %137, i32* %14
br label %114
138: ; preds = %114
br label %139
139: ; preds = %138
%140 = load i32, i32* %15
%141 = add i32 %140, 1
store i32 %141, i32* %15
br label %110
142: ; preds = %110
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
store i32 2000, i32* %16
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%145 = load i32, i32* %16
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %145)
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0))
%148 = load i32, i32* %16
store i32 %148, i32* %17
%149 = load i8*, i8** %10
store i8* %149, i8** %19
br label %150
150: ; preds = %168, %142
%151 = load i32, i32* %17
%152 = icmp ne i32 %151, 0
br i1 %152, label %153, label %172
153: ; preds = %150
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %18
br label %155
155: ; preds = %165, %153
%156 = load i32, i32* %18
%157 = icmp ult i32 %156, 16
br i1 %157, label %158, label %168
158: ; preds = %155
%159 = load i8*, i8** %19
%160 = load i8, i8* %159
%161 = zext i8 %160 to i32
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %161)
%163 = load i8*, i8** %19
%164 = getelementptr inbounds i8, i8* %163, i32 1
store i8* %164, i8** %19
br label %165
165: ; preds = %158
%166 = load i32, i32* %18
%167 = add i32 %166, 1
store i32 %167, i32* %18
br label %155
168: ; preds = %155
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%170 = load i32, i32* %17
%171 = add i32 %170, -1
store i32 %171, i32* %17
br label %150
172: ; preds = %150
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%174 = load i32, i32* %12
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0), i32 %174)
%176 = load i32, i32* %16
%177 = mul i32 %176, 16
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.16, i64 0, i64 0), i32 %177)
store i32 0, i32* %3
br label %179
179: ; preds = %172, %56, %33, %22
%180 = load i32, i32* %3
ret i32 %180
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Specify file to open\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Couldn't open file %s\0A\00"
@SEEK_END = global i32 0
@.str.3 = [23 x i8] c"Couldn't read file %s\0A\00"
@.str.4 = [33 x i8] c"// Data payload offset is %d %x\0A\00"
@.str.5 = [37 x i8] c"// Data payload in file is %d bytes\0A\00"
@.str.6 = [20 x i8] c"// Module 16 -> %d\0A\00"
@.str.9 = [31 x i8] c"unsigned int framelimit = %d;\0A\00"
@.str.11 = [3 x i8] c" \00"
@.str.12 = [9 x i8] c"0x%02x, \00"
@.str.15 = [48 x i8] c"unsigned long int song_hacked_fullym_len = %d;\0A\00"
@.str.16 = [39 x i8] c"unsigned int song_hacked_ym_len = %d;\0A\00"
@str = [18 x i8] c"/* interleaved */\00"
@str.17 = [26 x i8] c"#include <avr/pgmspace.h>\00"
@str.18 = [49 x i8] c"const unsigned char song_hacked_ym[] PROGMEM = {\00"
@str.19 = [3 x i8] c"};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %174
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %174
15: ; preds = %7
%16 = load i32, i32* @SEEK_END
%17 = tail call i32 @fseek(i32* %10, i32 0, i32 %16)
%18 = tail call i32 @ftell(i32* %10)
%19 = tail call i32 @rewind(i32* %10)
%20 = tail call i64 @malloc(i32 %18)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i64 @malloc(i32 %18)
%23 = inttoptr i64 %22 to i8*
%24 = tail call i32 @fread(i8* %21, i32 %18, i32 1, i32* %10)
%25 = icmp slt i32 %24, 1
%26 = tail call i32 @fclose(i32* %10)
br i1 %25, label %27, label %30
27: ; preds = %15
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %174
30: ; preds = %15
%31 = getelementptr inbounds i8, i8* %21, i64 34
%32 = tail call i64 @strchr(i8* %31, i8 signext 0)
%33 = inttoptr i64 %32 to i8*
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = tail call i64 @strchr(i8* %34, i8 signext 0)
%36 = inttoptr i64 %35 to i8*
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = tail call i64 @strchr(i8* %37, i8 signext 0)
%39 = inttoptr i64 %38 to i8*
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = ptrtoint i8* %40 to i64
%42 = sub i64 %41, %20
%43 = trunc i64 %42 to i32
%44 = sub i32 %18, %43
%45 = add i32 %44, -4
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %43, i32 %43)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%48 = and i32 %45, 15
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %48)
%50 = lshr i32 %45, 4
%51 = icmp ult i32 %45, 16
%52 = call i32 @llvm.umax.i32(i32 %50, i32 1)
%53 = zext i32 %50 to i64
%54 = zext i32 %52 to i64
%55 = and i64 %54, 1
%56 = icmp ult i32 %45, 32
%57 = and i64 %54, 268435454
%58 = icmp eq i64 %55, 0
br label %59
59: ; preds = %30, %91
%60 = phi i64 [ 0, %30 ], [ %92, %91 ]
br i1 %51, label %91, label %61
61: ; preds = %59
%62 = mul nuw nsw i64 %60, %53
br i1 %56, label %82, label %63
63: ; preds = %61, %63
%64 = phi i64 [ %79, %63 ], [ 0, %61 ]
%65 = phi i64 [ %80, %63 ], [ 0, %61 ]
%66 = add nuw nsw i64 %64, %62
%67 = getelementptr inbounds i8, i8* %40, i64 %66
%68 = load i8, i8* %67
%69 = shl i64 %64, 4
%70 = add nuw nsw i64 %69, %60
%71 = getelementptr inbounds i8, i8* %23, i64 %70
store i8 %68, i8* %71
%72 = or i64 %64, 1
%73 = add nuw nsw i64 %72, %62
%74 = getelementptr inbounds i8, i8* %40, i64 %73
%75 = load i8, i8* %74
%76 = shl i64 %72, 4
%77 = add nuw nsw i64 %76, %60
%78 = getelementptr inbounds i8, i8* %23, i64 %77
store i8 %75, i8* %78
%79 = add nuw nsw i64 %64, 2
%80 = add i64 %65, 2
%81 = icmp eq i64 %80, %57
br i1 %81, label %82, label %63
82: ; preds = %63, %61
%83 = phi i64 [ 0, %61 ], [ %79, %63 ]
br i1 %58, label %91, label %84
84: ; preds = %82
%85 = add nuw nsw i64 %83, %62
%86 = getelementptr inbounds i8, i8* %40, i64 %85
%87 = load i8, i8* %86
%88 = shl i64 %83, 4
%89 = add nuw nsw i64 %88, %60
%90 = getelementptr inbounds i8, i8* %23, i64 %89
store i8 %87, i8* %90
br label %91
91: ; preds = %84, %82, %59
%92 = add nuw nsw i64 %60, 1
%93 = icmp eq i64 %92, 16
br i1 %93, label %94, label %59
94: ; preds = %91
%95 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%96 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.17, i64 0, i64 0))
%97 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 2000)
%98 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.18, i64 0, i64 0))
br label %99
99: ; preds = %94, %99
%100 = phi i8* [ %23, %94 ], [ %166, %99 ]
%101 = phi i32 [ 2000, %94 ], [ %168, %99 ]
%102 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%103 = load i8, i8* %100
%104 = zext i8 %103 to i32
%105 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %104)
%106 = getelementptr inbounds i8, i8* %100, i64 1
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %108)
%110 = getelementptr inbounds i8, i8* %100, i64 2
%111 = load i8, i8* %110
%112 = zext i8 %111 to i32
%113 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %112)
%114 = getelementptr inbounds i8, i8* %100, i64 3
%115 = load i8, i8* %114
%116 = zext i8 %115 to i32
%117 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %116)
%118 = getelementptr inbounds i8, i8* %100, i64 4
%119 = load i8, i8* %118
%120 = zext i8 %119 to i32
%121 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %120)
%122 = getelementptr inbounds i8, i8* %100, i64 5
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %124)
%126 = getelementptr inbounds i8, i8* %100, i64 6
%127 = load i8, i8* %126
%128 = zext i8 %127 to i32
%129 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %128)
%130 = getelementptr inbounds i8, i8* %100, i64 7
%131 = load i8, i8* %130
%132 = zext i8 %131 to i32
%133 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %132)
%134 = getelementptr inbounds i8, i8* %100, i64 8
%135 = load i8, i8* %134
%136 = zext i8 %135 to i32
%137 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %136)
%138 = getelementptr inbounds i8, i8* %100, i64 9
%139 = load i8, i8* %138
%140 = zext i8 %139 to i32
%141 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %140)
%142 = getelementptr inbounds i8, i8* %100, i64 10
%143 = load i8, i8* %142
%144 = zext i8 %143 to i32
%145 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %144)
%146 = getelementptr inbounds i8, i8* %100, i64 11
%147 = load i8, i8* %146
%148 = zext i8 %147 to i32
%149 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %148)
%150 = getelementptr inbounds i8, i8* %100, i64 12
%151 = load i8, i8* %150
%152 = zext i8 %151 to i32
%153 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %152)
%154 = getelementptr inbounds i8, i8* %100, i64 13
%155 = load i8, i8* %154
%156 = zext i8 %155 to i32
%157 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %156)
%158 = getelementptr inbounds i8, i8* %100, i64 14
%159 = load i8, i8* %158
%160 = zext i8 %159 to i32
%161 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %160)
%162 = getelementptr inbounds i8, i8* %100, i64 15
%163 = load i8, i8* %162
%164 = zext i8 %163 to i32
%165 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %164)
%166 = getelementptr inbounds i8, i8* %100, i64 16
%167 = tail call i32 @putchar(i32 10)
%168 = add nsw i32 %101, -1
%169 = icmp eq i32 %168, 0
br i1 %169, label %170, label %99
170: ; preds = %99
%171 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.19, i64 0, i64 0))
%172 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0), i32 %45)
%173 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.16, i64 0, i64 0), i32 32000)
br label %174
174: ; preds = %12, %170, %27, %4
ret i32 0
}