#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_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int get32bit(char *);
int /*<<< orphan*/ make32bit(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int samplestooffset(int);
int samplestosize(int);
int main(int argc, char **argv) {
  char buf[0x20];
  int startoff, length;
  int introstartoff, introlength = 0;
  FILE *infile, *introfile = NULL, *outfile;
  int i;
  printf("adxloop 0.1 by hcs\n");
  if (argc != 3 && argc != 4) {
    printf("usage: %s [intro.adx] loop.adx out.adx\n", argv[0]);
    return 1;
  }
  if (argc == 4) {
    introfile = fopen(argv[1], "rb");
    if (!introfile) {
      printf("error opening %s\n", argv[1]);
      return 1;
    }
    infile = fopen(argv[2], "rb");
    if (!infile) {
      printf("error opening %s\n", argv[2]);
      return 1;
    }
    outfile = fopen(argv[3], "wb");
    if (!outfile) {
      printf("error opening %s\n", argv[3]);
      return 1;
    }
    fread(buf, 1, 0x18, introfile);
    introstartoff = get32bit(buf + 0) & 0xffff;
    introlength = get32bit(buf + 0x0c);
  } else {
    infile = fopen(argv[1], "rb");
    if (!infile) {
      printf("error opening %s\n", argv[1]);
      return 1;
    }
    outfile = fopen(argv[2], "wb");
    if (!outfile) {
      printf("error opening %s\n", argv[2]);
      return 1;
    }
  }
  printf("writing new header\n");
  fread(buf, 1, 0x18, infile);
  startoff = get32bit(buf + 0) & 0xffff;
  length = get32bit(buf + 0x0c);
  make32bit(introlength + length, buf + 0xc);
  make32bit(0x800000EC, buf + 0);
  make32bit(0x01F40300, buf + 0x10);
  make32bit(0x000B0001, buf + 0x14);
  fwrite(buf, 1, 0x18, outfile);
  make32bit(1, buf);
  make32bit(introlength / 32 * 32, buf + 4);
  make32bit(samplestooffset(0xf0 + introlength), buf + 8);
  make32bit(introlength + length, buf + 12);
  make32bit(samplestooffset(introlength + length), buf + 16);
  fwrite(buf, 1, 0x14, outfile);
  printf("copying data\n");
  fseek(outfile, 0xf0 - 6, SEEK_SET);
  fwrite("(c)CRI", 6, 1, outfile);
  if (introfile) {
    fseek(introfile, introstartoff + 4, SEEK_SET);
    for (i = samplestosize(introlength); i > 0; i--) {
      fread(buf, 1, 1, introfile);
      fwrite(buf, 1, 1, outfile);
    }
    fclose(introfile);
  }
  fseek(infile, startoff + 4, SEEK_SET);
  while (fread(buf, 1, 1, infile) == 1)
    fwrite(buf, 1, 1, outfile);
  fclose(infile);
  fclose(outfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x40(%rbp)
movq   $0x0,-0x50(%rbp)
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
je     1208 <main+0x68>
cmpl   $0x4,-0x8(%rbp)
je     1208 <main+0x68>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f8 <main+0x458>
cmpl   $0x4,-0x8(%rbp)
jne    131e <main+0x17e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1257 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f8 <main+0x458>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    129c <main+0xfc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f8 <main+0x458>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xda6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12e1 <main+0x141>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f8 <main+0x458>
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%rcx
mov    $0x1,%esi
mov    $0x18,%edx
call   1030 <fread@plt>
lea    -0x30(%rbp),%rdi
call   1050 <get32bit@plt>
and    $0xffff,%eax
mov    %eax,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
add    $0xc,%rdi
call   1050 <get32bit@plt>
mov    %eax,-0x40(%rbp)
jmp    13ad <main+0x20d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd0f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1363 <main+0x1c3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f8 <main+0x458>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xcdf(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    13a8 <main+0x208>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f8 <main+0x458>
jmp    13ad <main+0x20d>
lea    0xca0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    $0x1,%esi
mov    $0x18,%edx
call   1030 <fread@plt>
lea    -0x30(%rbp),%rdi
call   1050 <get32bit@plt>
and    $0xffff,%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
add    $0xc,%rdi
call   1050 <get32bit@plt>
mov    %eax,-0x38(%rbp)
mov    -0x40(%rbp),%edi
add    -0x38(%rbp),%edi
lea    -0x30(%rbp),%rsi
add    $0xc,%rsi
call   1080 <make32bit@plt>
lea    -0x30(%rbp),%rsi
mov    $0x800000ec,%edi
call   1080 <make32bit@plt>
lea    -0x30(%rbp),%rsi
add    $0x10,%rsi
mov    $0x1f40300,%edi
call   1080 <make32bit@plt>
lea    -0x30(%rbp),%rsi
add    $0x14,%rsi
mov    $0xb0001,%edi
call   1080 <make32bit@plt>
lea    -0x30(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x1,%esi
mov    $0x18,%edx
call   10b0 <fwrite@plt>
lea    -0x30(%rbp),%rsi
mov    $0x1,%edi
call   1080 <make32bit@plt>
mov    -0x40(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
shl    $0x5,%edi
lea    -0x30(%rbp),%rsi
add    $0x4,%rsi
call   1080 <make32bit@plt>
mov    -0x40(%rbp),%edi
add    $0xf0,%edi
call   10c0 <samplestooffset@plt>
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
add    $0x8,%rsi
call   1080 <make32bit@plt>
mov    -0x40(%rbp),%edi
add    -0x38(%rbp),%edi
lea    -0x30(%rbp),%rsi
add    $0xc,%rsi
call   1080 <make32bit@plt>
mov    -0x40(%rbp),%edi
add    -0x38(%rbp),%edi
call   10c0 <samplestooffset@plt>
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
add    $0x10,%rsi
call   1080 <make32bit@plt>
lea    -0x30(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x1,%esi
mov    $0x14,%edx
call   10b0 <fwrite@plt>
lea    0xb86(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%rdi
mov    0x2aec(%rip),%rax
mov    (%rax),%edx
mov    $0xea,%esi
call   1090 <fseek@plt>
mov    -0x58(%rbp),%rcx
lea    0xb6b(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
cmpq   $0x0,-0x50(%rbp)
je     1591 <main+0x3f1>
mov    -0x50(%rbp),%rdi
mov    -0x3c(%rbp),%esi
add    $0x4,%esi
mov    0x2aaa(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
mov    -0x40(%rbp),%edi
call   1040 <samplestosize@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jle    1588 <main+0x3e8>
lea    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
lea    -0x30(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   10b0 <fwrite@plt>
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
jmp    1548 <main+0x3a8>
mov    -0x50(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%esi
add    $0x4,%esi
mov    0x2a3e(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
lea    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    15df <main+0x43f>
lea    -0x30(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   10b0 <fwrite@plt>
jmp    15a9 <main+0x409>
mov    -0x48(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x58(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
lea    -0x5(%rbx),%eax
cmp    $0xfffffffd,%eax
ja     11f7 <main+0x37>
mov    0x0(%rbp),%rsi
lea    0xe0e(%rip),%rdi
jmp    14f1 <main+0x331>
mov    0x8(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r15
cmp    $0x4,%ebx
jne    128b <main+0xcb>
test   %r15,%r15
je     14da <main+0x31a>
mov    0x10(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14e0 <main+0x320>
mov    %rax,%r14
mov    0x18(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14e6 <main+0x326>
mov    %rax,%r13
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x18,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1060 <get32bit@plt>
movzwl %ax,%ebx
lea    0xc(%rsp),%rdi
call   1060 <get32bit@plt>
mov    %rax,0x28(%rsp)
add    $0x4,%ebx
mov    %ebx,0x30(%rsp)
jmp    12bd <main+0xfd>
test   %r15,%r15
je     14da <main+0x31a>
mov    0x10(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14e0 <main+0x320>
mov    %rax,%r13
xor    %eax,%eax
mov    %rax,0x28(%rsp)
mov    %r15,%r14
xor    %r15d,%r15d
lea    0xd96(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x18,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1060 <get32bit@plt>
movzwl %ax,%eax
mov    %eax,0x34(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <get32bit@plt>
mov    0x28(%rsp),%rbp
lea    (%rax,%rbp,1),%r12d
mov    %r12d,%edi
mov    %rbx,%rsi
call   10a0 <make32bit@plt>
mov    $0x800000ec,%edi
mov    %rsp,%rsi
call   10a0 <make32bit@plt>
lea    0x10(%rsp),%rsi
mov    $0x1f40300,%edi
call   10a0 <make32bit@plt>
lea    0x14(%rsp),%rsi
mov    $0xb0001,%edi
call   10a0 <make32bit@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x18,%edx
mov    %r13,%rcx
call   10d0 <fwrite@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   10a0 <make32bit@plt>
lea    0x1f(%rbp),%edi
test   %ebp,%ebp
cmovns %ebp,%edi
and    $0xffffffe0,%edi
lea    0x4(%rsp),%rsi
call   10a0 <make32bit@plt>
lea    0xf0(%rbp),%edi
call   10e0 <samplestooffset@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   10a0 <make32bit@plt>
mov    %r12d,%edi
lea    0xc(%rsp),%rsi
call   10a0 <make32bit@plt>
mov    %r12d,%edi
call   10e0 <samplestooffset@plt>
mov    %eax,%edi
lea    0x10(%rsp),%rsi
call   10a0 <make32bit@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x14,%edx
mov    %r13,%rcx
call   10d0 <fwrite@plt>
lea    0xca3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c0a(%rip),%r12
mov    (%r12),%edx
mov    %r13,%rdi
mov    $0xea,%esi
call   10b0 <fseek@plt>
lea    0xc52(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   10d0 <fwrite@plt>
test   %r15,%r15
je     1461 <main+0x2a1>
mov    (%r12),%edx
mov    %r15,%rdi
mov    0x30(%rsp),%esi
call   10b0 <fseek@plt>
mov    0x28(%rsp),%rdi
call   1050 <samplestosize@plt>
test   %eax,%eax
jle    1459 <main+0x299>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
movsbl (%rsp),%edi
mov    %r13,%rsi
call   1090 <fputc@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1430 <main+0x270>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    0x34(%rsp),%esi
add    $0x4,%esi
mov    (%r12),%edx
mov    %r14,%rdi
call   10b0 <fseek@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    14c6 <main+0x306>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp),%edi
mov    %r13,%rsi
call   1090 <fputc@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     14a0 <main+0x2e0>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    %r13,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
jmp    14fd <main+0x33d>
mov    0x8(%rbp),%rsi
jmp    14ea <main+0x32a>
mov    0x10(%rbp),%rsi
jmp    14ea <main+0x32a>
mov    0x18(%rbp),%rsi
lea    0xb3a(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"adxloop 0.1 by hcs\0A\00"
@.str.1 = [40 x i8] c"usage: %s [intro.adx] loop.adx out.adx\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [18 x i8] c"error opening %s\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [20 x i8] c"writing new header\0A\00"
@.str.6 = [14 x i8] c"copying data\0A\00"
@SEEK_SET = global i32 0
@.str.7 = [7 x i8] c"(c)CRI\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32* null, i32** %12
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 4
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %213
26: ; preds = %18, %2
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %76
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %12
%34 = load i32*, i32** %12
%35 = icmp ne i32* %34, null
br i1 %35, label %41, label %36
36: ; preds = %29
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %39)
store i32 1, i32* %3
br label %213
41: ; preds = %29
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %45, i32** %11
%46 = load i32*, i32** %11
%47 = icmp ne i32* %46, null
br i1 %47, label %53, label %48
48: ; preds = %41
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %51)
store i32 1, i32* %3
br label %213
53: ; preds = %41
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call i32* @fopen(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %57, i32** %13
%58 = load i32*, i32** %13
%59 = icmp ne i32* %58, null
br i1 %59, label %65, label %60
60: ; preds = %53
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %63)
store i32 1, i32* %3
br label %213
65: ; preds = %53
%66 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%67 = load i32*, i32** %12
%68 = call i32 @fread(i8* %66, i32 1, i32 24, i32* %67)
%69 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%70 = getelementptr inbounds i8, i8* %69, i64 0
%71 = call i32 @get32bit(i8* %70)
%72 = and i32 %71, 65535
store i32 %72, i32* %9
%73 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%74 = getelementptr inbounds i8, i8* %73, i64 12
%75 = call i32 @get32bit(i8* %74)
store i32 %75, i32* %10
br label %101
76: ; preds = %26
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = call i32* @fopen(i8* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %80, i32** %11
%81 = load i32*, i32** %11
%82 = icmp ne i32* %81, null
br i1 %82, label %88, label %83
83: ; preds = %76
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 1
%86 = load i8*, i8** %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %86)
store i32 1, i32* %3
br label %213
88: ; preds = %76
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 2
%91 = load i8*, i8** %90
%92 = call i32* @fopen(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %92, i32** %13
%93 = load i32*, i32** %13
%94 = icmp ne i32* %93, null
br i1 %94, label %100, label %95
95: ; preds = %88
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 2
%98 = load i8*, i8** %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %98)
store i32 1, i32* %3
br label %213
100: ; preds = %88
br label %101
101: ; preds = %100, %65
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%103 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%104 = load i32*, i32** %11
%105 = call i32 @fread(i8* %103, i32 1, i32 24, i32* %104)
%106 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%107 = getelementptr inbounds i8, i8* %106, i64 0
%108 = call i32 @get32bit(i8* %107)
%109 = and i32 %108, 65535
store i32 %109, i32* %7
%110 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%111 = getelementptr inbounds i8, i8* %110, i64 12
%112 = call i32 @get32bit(i8* %111)
store i32 %112, i32* %8
%113 = load i32, i32* %10
%114 = load i32, i32* %8
%115 = add nsw i32 %113, %114
%116 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%117 = getelementptr inbounds i8, i8* %116, i64 12
%118 = call i32 @make32bit(i32 %115, i8* %117)
%119 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%120 = getelementptr inbounds i8, i8* %119, i64 0
%121 = call i32 @make32bit(i32 -2147483412, i8* %120)
%122 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%123 = getelementptr inbounds i8, i8* %122, i64 16
%124 = call i32 @make32bit(i32 32768768, i8* %123)
%125 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%126 = getelementptr inbounds i8, i8* %125, i64 20
%127 = call i32 @make32bit(i32 720897, i8* %126)
%128 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%129 = load i32*, i32** %13
%130 = call i32 @fwrite(i8* %128, i32 1, i32 24, i32* %129)
%131 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%132 = call i32 @make32bit(i32 1, i8* %131)
%133 = load i32, i32* %10
%134 = sdiv i32 %133, 32
%135 = mul nsw i32 %134, 32
%136 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%137 = getelementptr inbounds i8, i8* %136, i64 4
%138 = call i32 @make32bit(i32 %135, i8* %137)
%139 = load i32, i32* %10
%140 = add nsw i32 240, %139
%141 = call i32 @samplestooffset(i32 %140)
%142 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%143 = getelementptr inbounds i8, i8* %142, i64 8
%144 = call i32 @make32bit(i32 %141, i8* %143)
%145 = load i32, i32* %10
%146 = load i32, i32* %8
%147 = add nsw i32 %145, %146
%148 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%149 = getelementptr inbounds i8, i8* %148, i64 12
%150 = call i32 @make32bit(i32 %147, i8* %149)
%151 = load i32, i32* %10
%152 = load i32, i32* %8
%153 = add nsw i32 %151, %152
%154 = call i32 @samplestooffset(i32 %153)
%155 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%156 = getelementptr inbounds i8, i8* %155, i64 16
%157 = call i32 @make32bit(i32 %154, i8* %156)
%158 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%159 = load i32*, i32** %13
%160 = call i32 @fwrite(i8* %158, i32 1, i32 20, i32* %159)
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%162 = load i32*, i32** %13
%163 = load i32, i32* @SEEK_SET
%164 = call i32 @fseek(i32* %162, i32 234, i32 %163)
%165 = load i32*, i32** %13
%166 = call i32 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6, i32 1, i32* %165)
%167 = load i32*, i32** %12
%168 = icmp ne i32* %167, null
br i1 %168, label %169, label %193
169: ; preds = %101
%170 = load i32*, i32** %12
%171 = load i32, i32* %9
%172 = add nsw i32 %171, 4
%173 = load i32, i32* @SEEK_SET
%174 = call i32 @fseek(i32* %170, i32 %172, i32 %173)
%175 = load i32, i32* %10
%176 = call i32 @samplestosize(i32 %175)
store i32 %176, i32* %14
br label %177
177: ; preds = %187, %169
%178 = load i32, i32* %14
%179 = icmp sgt i32 %178, 0
br i1 %179, label %180, label %190
180: ; preds = %177
%181 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%182 = load i32*, i32** %12
%183 = call i32 @fread(i8* %181, i32 1, i32 1, i32* %182)
%184 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%185 = load i32*, i32** %13
%186 = call i32 @fwrite(i8* %184, i32 1, i32 1, i32* %185)
br label %187
187: ; preds = %180
%188 = load i32, i32* %14
%189 = add nsw i32 %188, -1
store i32 %189, i32* %14
br label %177
190: ; preds = %177
%191 = load i32*, i32** %12
%192 = call i32 @fclose(i32* %191)
br label %193
193: ; preds = %190, %101
%194 = load i32*, i32** %11
%195 = load i32, i32* %7
%196 = add nsw i32 %195, 4
%197 = load i32, i32* @SEEK_SET
%198 = call i32 @fseek(i32* %194, i32 %196, i32 %197)
br label %199
199: ; preds = %204, %193
%200 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%201 = load i32*, i32** %11
%202 = call i32 @fread(i8* %200, i32 1, i32 1, i32* %201)
%203 = icmp eq i32 %202, 1
br i1 %203, label %204, label %208
204: ; preds = %199
%205 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%206 = load i32*, i32** %13
%207 = call i32 @fwrite(i8* %205, i32 1, i32 1, i32* %206)
br label %199
208: ; preds = %199
%209 = load i32*, i32** %11
%210 = call i32 @fclose(i32* %209)
%211 = load i32*, i32** %13
%212 = call i32 @fclose(i32* %211)
store i32 0, i32* %3
br label %213
213: ; preds = %208, %95, %83, %60, %48, %36, %21
%214 = load i32, i32* %3
ret i32 %214
}

LLVM IR (-O2):
@.str.1 = [40 x i8] c"usage: %s [intro.adx] loop.adx out.adx\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [18 x i8] c"error opening %s\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@SEEK_SET = global i32 0
@.str.7 = [7 x i8] c"(c)CRI\00"
@str = [19 x i8] c"adxloop 0.1 by hcs\00"
@str.8 = [19 x i8] c"writing new header\00"
@str.9 = [13 x i8] c"copying data\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%6 = add i32 %0, -5
%7 = icmp ult i32 %6, -2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %124
11: ; preds = %2
%12 = icmp eq i32 %0, 4
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %12, label %17, label %44
17: ; preds = %11
br i1 %16, label %18, label %21
18: ; preds = %17
%19 = load i8*, i8** %13
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %124
21: ; preds = %17
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i8*, i8** %22
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %124
29: ; preds = %21
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = tail call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i8*, i8** %30
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %124
37: ; preds = %29
%38 = call i32 @fread(i8* %4, i32 1, i32 24, i32* %15)
%39 = call i32 @get32bit(i8* %4)
%40 = and i32 %39, 65535
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 12
%42 = call i32 @get32bit(i8* %41)
%43 = add nuw nsw i32 %40, 4
br label %56
44: ; preds = %11
br i1 %16, label %45, label %48
45: ; preds = %44
%46 = load i8*, i8** %13
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %46)
br label %124
48: ; preds = %44
%49 = getelementptr inbounds i8*, i8** %1, i64 2
%50 = load i8*, i8** %49
%51 = tail call i32* @fopen(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i8*, i8** %49
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %54)
br label %124
56: ; preds = %48, %37
%57 = phi i32 [ %43, %37 ], [ undef, %48 ]
%58 = phi i32 [ %42, %37 ], [ 0, %48 ]
%59 = phi i32* [ %24, %37 ], [ %15, %48 ]
%60 = phi i32* [ %15, %37 ], [ null, %48 ]
%61 = phi i32* [ %32, %37 ], [ %51, %48 ]
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
%63 = call i32 @fread(i8* %4, i32 1, i32 24, i32* %59)
%64 = call i32 @get32bit(i8* %4)
%65 = and i32 %64, 65535
%66 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 12
%67 = call i32 @get32bit(i8* %66)
%68 = add nsw i32 %67, %58
%69 = call i32 @make32bit(i32 %68, i8* %66)
%70 = call i32 @make32bit(i32 -2147483412, i8* %4)
%71 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 16
%72 = call i32 @make32bit(i32 32768768, i8* %71)
%73 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 20
%74 = call i32 @make32bit(i32 720897, i8* %73)
%75 = call i32 @fwrite(i8* %4, i32 1, i32 24, i32* %61)
%76 = call i32 @make32bit(i32 1, i8* %4)
%77 = sdiv i32 %58, 32
%78 = shl nsw i32 %77, 5
%79 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 4
%80 = call i32 @make32bit(i32 %78, i8* %79)
%81 = add nsw i32 %58, 240
%82 = call i32 @samplestooffset(i32 %81)
%83 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 8
%84 = call i32 @make32bit(i32 %82, i8* %83)
%85 = call i32 @make32bit(i32 %68, i8* %66)
%86 = call i32 @samplestooffset(i32 %68)
%87 = call i32 @make32bit(i32 %86, i8* %71)
%88 = call i32 @fwrite(i8* %4, i32 1, i32 20, i32* %61)
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%90 = load i32, i32* @SEEK_SET
%91 = call i32 @fseek(i32* %61, i32 234, i32 %90)
%92 = call i32 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6, i32 1, i32* %61)
%93 = icmp eq i32* %60, null
br i1 %93, label %109, label %94
94: ; preds = %56
%95 = load i32, i32* @SEEK_SET
%96 = call i32 @fseek(i32* %60, i32 %57, i32 %95)
%97 = call i32 @samplestosize(i32 %58)
%98 = icmp sgt i32 %97, 0
br i1 %98, label %99, label %107
99: ; preds = %94, %99
%100 = phi i32 [ %105, %99 ], [ %97, %94 ]
%101 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %60)
%102 = load i8, i8* %4
%103 = sext i8 %102 to i32
%104 = call i32 @fputc(i32 %103, i32* %61)
%105 = add nsw i32 %100, -1
%106 = icmp ugt i32 %100, 1
br i1 %106, label %99, label %107
107: ; preds = %99, %94
%108 = call i32 @fclose(i32* %60)
br label %109
109: ; preds = %107, %56
%110 = add nuw nsw i32 %65, 4
%111 = load i32, i32* @SEEK_SET
%112 = call i32 @fseek(i32* %59, i32 %110, i32 %111)
%113 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %59)
%114 = icmp eq i32 %113, 1
br i1 %114, label %115, label %121
115: ; preds = %109, %115
%116 = load i8, i8* %4
%117 = sext i8 %116 to i32
%118 = call i32 @fputc(i32 %117, i32* %61)
%119 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %59)
%120 = icmp eq i32 %119, 1
br i1 %120, label %115, label %121
121: ; preds = %115, %109
%122 = call i32 @fclose(i32* %59)
%123 = call i32 @fclose(i32* %61)
br label %124
124: ; preds = %121, %53, %45, %34, %26, %18, %8
%125 = phi i32 [ 1, %8 ], [ 0, %121 ], [ 1, %34 ], [ 1, %26 ], [ 1, %18 ], [ 1, %53 ], [ 1, %45 ]
ret i32 %125
}