#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 char int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
char ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char buf[1024];
  int n = 0;
  char DX[2] = "DX";
  int32_t exesize = 0;
  int32_t datsize = 0;
  FILE *f = NULL;
  FILE *out = NULL;
  printf("argc: %d\n", argc);
  if (argc > 4)
    out = fopen(argv[4], "wb");
  else
    out = fopen("out", "wb");
  if (argc > 1) {
    printf("runtime: %s\n", argv[1]);
    f = fopen(argv[1], "rb");
  } else
    f = fopen("system/divrun-LINUX", "rb");
  if (!f) {
    printf("Could not open runtime\n");
    exit(-1);
  }
  while (!feof(f)) {
    n = fread(buf, 1, 1024, f);
    fwrite(buf, 1, n, out);
  }
  if (argc > 2) {
    printf("EXE: %s\n", argv[2]);
    f = fopen(argv[2], "rb");
  } else
    f = fopen("system/EXEC.EXE", "rb");
  if (!f) {
    printf("Could not open div bytecode\n");
    exit(-1);
  }
  fseek(f, 0, SEEK_END);
  exesize = ftell(f);
  fseek(f, 0, SEEK_SET);
  while (!feof(f)) {
    n = fread(buf, 1, 1024, f);
    fwrite(buf, 1, n, out);
  }
  if (argc > 3) {
    printf("data file: %s\n", argv[3]);
    f = fopen(argv[3], "rb");
  } else
    f = fopen("data.div", "rb");
  if (!f) {
    printf("Could not open div data\n");
  } else {
    fseek(f, 0, SEEK_END);
    datsize = ftell(f);
    fseek(f, 0, SEEK_SET);
    while (!feof(f)) {
      n = fread(buf, 1, 1024, f);
      fwrite(buf, 1, n, out);
    }
    fclose(f);
  }
  fwrite(&exesize, 4, 1, out);
  fwrite(&datsize, 4, 1, out);
  fwrite(DX, 2, 1, out);
  fclose(out);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x414(%rbp)
mov    0xe46(%rip),%ax
mov    %ax,-0x416(%rbp)
movb   $0x0,-0x417(%rbp)
movb   $0x0,-0x418(%rbp)
movq   $0x0,-0x420(%rbp)
movq   $0x0,-0x428(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x4,-0x8(%rbp)
jle    1220 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xdfd(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x428(%rbp)
jmp    123a <main+0xaa>
lea    0xde8(%rip),%rdi
lea    0xdde(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    127a <main+0xea>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb7(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
jmp    1294 <main+0x104>
lea    0xda2(%rip),%rdi
lea    0xd98(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    12ba <main+0x12a>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
jmp    12bf <main+0x12f>
mov    -0x420(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12e0 <main+0x150>
jmp    1326 <main+0x196>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x414(%rbp),%edx
mov    -0x428(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
jmp    12bf <main+0x12f>
cmpl   $0x2,-0x8(%rbp)
jle    1366 <main+0x1d6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xccb(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
jmp    1380 <main+0x1f0>
lea    0xceb(%rip),%rdi
lea    0xcac(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    13a6 <main+0x216>
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x420(%rbp),%rdi
mov    0x2c34(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x420(%rbp),%rdi
call   1060 <ftell@plt>
mov    %al,-0x417(%rbp)
mov    -0x420(%rbp),%rdi
mov    0x2bfb(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x420(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1407 <main+0x277>
jmp    144d <main+0x2bd>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x414(%rbp),%edx
mov    -0x428(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
jmp    13e6 <main+0x256>
cmpl   $0x3,-0x8(%rbp)
jle    148d <main+0x2fd>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xba4(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
jmp    14a7 <main+0x317>
lea    0xc00(%rip),%rdi
lea    0xb85(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    14c8 <main+0x338>
lea    0xbe1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    157b <main+0x3eb>
mov    -0x420(%rbp),%rdi
mov    0x2b12(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x420(%rbp),%rdi
call   1060 <ftell@plt>
mov    %al,-0x418(%rbp)
mov    -0x420(%rbp),%rdi
mov    0x2ad9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x420(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1529 <main+0x399>
jmp    156f <main+0x3df>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x414(%rbp),%edx
mov    -0x428(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
jmp    1508 <main+0x378>
mov    -0x420(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x428(%rbp),%rcx
lea    -0x417(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    -0x428(%rbp),%rcx
lea    -0x418(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
lea    -0x416(%rbp),%rdi
mov    -0x428(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    -0x428(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
movw   $0x5844,0xe(%rsp)
movb   $0x0,0xd(%rsp)
movb   $0x0,0xc(%rsp)
lea    0xe31(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x5,%r15d
jl     11f4 <main+0x54>
mov    0x20(%r14),%rdi
lea    0xe20(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
jmp    1210 <main+0x70>
lea    0xe12(%rip),%rdi
lea    0xe08(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
cmp    $0x2,%r15d
jl     1228 <main+0x88>
mov    0x8(%r14),%rsi
lea    0xdf6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r14),%rdi
jmp    122f <main+0x8f>
lea    0xdf2(%rip),%rdi
lea    0xde8(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     147a <main+0x2da>
mov    %rax,%rbp
mov    %rax,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1293 <main+0xf3>
lea    0x10(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r12,%rcx
call   10c0 <fwrite@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1260 <main+0xc0>
cmp    $0x3,%r15d
jl     12b1 <main+0x111>
mov    0x10(%r14),%rsi
lea    0xd91(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%r14),%rdi
jmp    12b8 <main+0x118>
lea    0xd86(%rip),%rdi
lea    0xd5f(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1483 <main+0x2e3>
mov    %rax,%rbp
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1070 <ftell@plt>
mov    %al,0xd(%rsp)
mov    0x2ce2(%rip),%r13
mov    0x0(%r13),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1353 <main+0x1b3>
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r12,%rcx
call   10c0 <fwrite@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1320 <main+0x180>
cmp    $0x4,%r15d
jl     1371 <main+0x1d1>
mov    0x18(%r14),%rsi
lea    0xcea(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%r14),%rdi
jmp    1378 <main+0x1d8>
lea    0xce5(%rip),%rdi
lea    0xc9f(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     140d <main+0x26d>
mov    %rax,%rbp
mov    0x2c51(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1070 <ftell@plt>
mov    %al,0xc(%rsp)
mov    0x0(%r13),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1403 <main+0x263>
lea    0x10(%rsp),%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r12,%rcx
call   10c0 <fwrite@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     13d0 <main+0x230>
mov    %rbp,%rdi
call   1050 <fclose@plt>
jmp    1419 <main+0x279>
lea    0xc85(%rip),%rdi
call   1030 <puts@plt>
lea    0xd(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10c0 <fwrite@plt>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10c0 <fwrite@plt>
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10c0 <fwrite@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbe5(%rip),%rdi
jmp    148a <main+0x2ea>
lea    0xbf3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@__const.main.DX = [2 x i8] c"DX"
@.str = [10 x i8] c"argc: %d\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [4 x i8] c"out\00"
@.str.3 = [13 x i8] c"runtime: %s\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [20 x i8] c"system/divrun-LINUX\00"
@.str.6 = [24 x i8] c"Could not open runtime\0A\00"
@.str.7 = [9 x i8] c"EXE: %s\0A\00"
@.str.8 = [16 x i8] c"system/EXEC.EXE\00"
@.str.9 = [29 x i8] c"Could not open div bytecode\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [15 x i8] c"data file: %s\0A\00"
@.str.11 = [9 x i8] c"data.div\00"
@.str.12 = [25 x i8] c"Could not open div data\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca [2 x i8]
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32*
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%13 = bitcast [2 x i8]* %8 to i8*
store i8 0, i8* %9
store i8 0, i8* %10
store i32* null, i32** %11
store i32* null, i32** %12
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 4
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 4
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %12
br label %25
23: ; preds = %2
%24 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %12
br label %25
25: ; preds = %23, %18
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%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** %11
br label %39
37: ; preds = %25
%38 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %38, i32** %11
br label %39
39: ; preds = %37, %28
%40 = load i32*, i32** %11
%41 = icmp ne i32* %40, null
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %39
br label %46
46: ; preds = %51, %45
%47 = load i32*, i32** %11
%48 = call i32 @feof(i32* %47)
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
br i1 %50, label %51, label %59
51: ; preds = %46
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%53 = load i32*, i32** %11
%54 = call i32 @fread(i8* %52, i32 1, i32 1024, i32* %53)
store i32 %54, i32* %7
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%56 = load i32, i32* %7
%57 = load i32*, i32** %12
%58 = call i32 @fwrite(i8* %55, i32 1, i32 %56, i32* %57)
br label %46
59: ; preds = %46
%60 = load i32, i32* %4
%61 = icmp sgt i32 %60, 2
br i1 %61, label %62, label %71
62: ; preds = %59
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %65)
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 2
%69 = load i8*, i8** %68
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %70, i32** %11
br label %73
71: ; preds = %59
%72 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %72, i32** %11
br label %73
73: ; preds = %71, %62
%74 = load i32*, i32** %11
%75 = icmp ne i32* %74, null
br i1 %75, label %79, label %76
76: ; preds = %73
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%78 = call i32 @exit(i32 -1)
unreachable
79: ; preds = %73
%80 = load i32*, i32** %11
%81 = load i32, i32* @SEEK_END
%82 = call i32 @fseek(i32* %80, i32 0, i32 %81)
%83 = load i32*, i32** %11
%84 = call signext i8 @ftell(i32* %83)
store i8 %84, i8* %9
%85 = load i32*, i32** %11
%86 = load i32, i32* @SEEK_SET
%87 = call i32 @fseek(i32* %85, i32 0, i32 %86)
br label %88
88: ; preds = %93, %79
%89 = load i32*, i32** %11
%90 = call i32 @feof(i32* %89)
%91 = icmp ne i32 %90, 0
%92 = xor i1 %91, true
br i1 %92, label %93, label %101
93: ; preds = %88
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%95 = load i32*, i32** %11
%96 = call i32 @fread(i8* %94, i32 1, i32 1024, i32* %95)
store i32 %96, i32* %7
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%98 = load i32, i32* %7
%99 = load i32*, i32** %12
%100 = call i32 @fwrite(i8* %97, i32 1, i32 %98, i32* %99)
br label %88
101: ; preds = %88
%102 = load i32, i32* %4
%103 = icmp sgt i32 %102, 3
br i1 %103, label %104, label %113
104: ; preds = %101
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 3
%107 = load i8*, i8** %106
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %107)
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 3
%111 = load i8*, i8** %110
%112 = call i32* @fopen(i8* %111, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %112, i32** %11
br label %115
113: ; preds = %101
%114 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %114, i32** %11
br label %115
115: ; preds = %113, %104
%116 = load i32*, i32** %11
%117 = icmp ne i32* %116, null
br i1 %117, label %120, label %118
118: ; preds = %115
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0))
br label %145
120: ; preds = %115
%121 = load i32*, i32** %11
%122 = load i32, i32* @SEEK_END
%123 = call i32 @fseek(i32* %121, i32 0, i32 %122)
%124 = load i32*, i32** %11
%125 = call signext i8 @ftell(i32* %124)
store i8 %125, i8* %10
%126 = load i32*, i32** %11
%127 = load i32, i32* @SEEK_SET
%128 = call i32 @fseek(i32* %126, i32 0, i32 %127)
br label %129
129: ; preds = %134, %120
%130 = load i32*, i32** %11
%131 = call i32 @feof(i32* %130)
%132 = icmp ne i32 %131, 0
%133 = xor i1 %132, true
br i1 %133, label %134, label %142
134: ; preds = %129
%135 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%136 = load i32*, i32** %11
%137 = call i32 @fread(i8* %135, i32 1, i32 1024, i32* %136)
store i32 %137, i32* %7
%138 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%139 = load i32, i32* %7
%140 = load i32*, i32** %12
%141 = call i32 @fwrite(i8* %138, i32 1, i32 %139, i32* %140)
br label %129
142: ; preds = %129
%143 = load i32*, i32** %11
%144 = call i32 @fclose(i32* %143)
br label %145
145: ; preds = %142, %118
%146 = load i32*, i32** %12
%147 = call i32 @fwrite(i8* %9, i32 4, i32 1, i32* %146)
%148 = load i32*, i32** %12
%149 = call i32 @fwrite(i8* %10, i32 4, i32 1, i32* %148)
%150 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%151 = load i32*, i32** %12
%152 = call i32 @fwrite(i8* %150, i32 2, i32 1, i32* %151)
%153 = load i32*, i32** %12
%154 = call i32 @fclose(i32* %153)
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
@.str = [10 x i8] c"argc: %d\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [4 x i8] c"out\00"
@.str.3 = [13 x i8] c"runtime: %s\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [20 x i8] c"system/divrun-LINUX\00"
@.str.7 = [9 x i8] c"EXE: %s\0A\00"
@.str.8 = [16 x i8] c"system/EXEC.EXE\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [15 x i8] c"data file: %s\0A\00"
@.str.11 = [9 x i8] c"data.div\00"
@str = [23 x i8] c"Could not open runtime\00"
@str.13 = [28 x i8] c"Could not open div bytecode\00"
@str.14 = [24 x i8] c"Could not open div data\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca i16
%5 = alloca i8
%6 = alloca i8
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = bitcast i16* %4 to i8*
store i16 22596, i16* %4
store i8 0, i8* %5
store i8 0, i8* %6
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = icmp sgt i32 %0, 4
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 4
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %18
15: ; preds = %2
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp sgt i32 %0, 1
br i1 %17, label %18, label %24
18: ; preds = %11, %15
%19 = phi i32* [ %14, %11 ], [ %16, %15 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %20
br label %24
24: ; preds = %15, %18
%25 = phi i8* [ %23, %18 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), %15 ]
%26 = phi i32* [ %19, %18 ], [ %16, %15 ]
%27 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = tail call i32 @feof(i32* %27)
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %40
32: ; preds = %24
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%34 = tail call i32 @exit(i32 -1)
unreachable
35: ; preds = %29, %35
%36 = call i32 @fread(i8* %7, i32 1, i32 1024, i32* %27)
%37 = call i32 @fwrite(i8* %7, i32 1, i32 %36, i32* %26)
%38 = tail call i32 @feof(i32* %27)
%39 = icmp eq i32 %38, 0
br i1 %39, label %35, label %40
40: ; preds = %35, %29
%41 = icmp sgt i32 %0, 2
br i1 %41, label %42, label %47
42: ; preds = %40
%43 = getelementptr inbounds i8*, i8** %1, i64 2
%44 = load i8*, i8** %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** %43
br label %47
47: ; preds = %40, %42
%48 = phi i8* [ %46, %42 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), %40 ]
%49 = tail call i32* @fopen(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.13, i64 0, i64 0))
%53 = tail call i32 @exit(i32 -1)
unreachable
54: ; preds = %47
%55 = load i32, i32* @SEEK_END
%56 = tail call i32 @fseek(i32* %49, i32 0, i32 %55)
%57 = tail call signext i8 @ftell(i32* %49)
store i8 %57, i8* %5
%58 = load i32, i32* @SEEK_SET
%59 = tail call i32 @fseek(i32* %49, i32 0, i32 %58)
%60 = tail call i32 @feof(i32* %49)
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %54, %62
%63 = call i32 @fread(i8* %7, i32 1, i32 1024, i32* %49)
%64 = call i32 @fwrite(i8* %7, i32 1, i32 %63, i32* %26)
%65 = tail call i32 @feof(i32* %49)
%66 = icmp eq i32 %65, 0
br i1 %66, label %62, label %67
67: ; preds = %62, %54
%68 = icmp sgt i32 %0, 3
br i1 %68, label %69, label %74
69: ; preds = %67
%70 = getelementptr inbounds i8*, i8** %1, i64 3
%71 = load i8*, i8** %70
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %71)
%73 = load i8*, i8** %70
br label %74
74: ; preds = %67, %69
%75 = phi i8* [ %73, %69 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), %67 ]
%76 = tail call i32* @fopen(i8* %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%77 = icmp eq i32* %76, null
br i1 %77, label %78, label %80
78: ; preds = %74
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
br label %95
80: ; preds = %74
%81 = load i32, i32* @SEEK_END
%82 = tail call i32 @fseek(i32* %76, i32 0, i32 %81)
%83 = tail call signext i8 @ftell(i32* %76)
store i8 %83, i8* %6
%84 = load i32, i32* @SEEK_SET
%85 = tail call i32 @fseek(i32* %76, i32 0, i32 %84)
%86 = tail call i32 @feof(i32* %76)
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %93
88: ; preds = %80, %88
%89 = call i32 @fread(i8* %7, i32 1, i32 1024, i32* %76)
%90 = call i32 @fwrite(i8* %7, i32 1, i32 %89, i32* %26)
%91 = tail call i32 @feof(i32* %76)
%92 = icmp eq i32 %91, 0
br i1 %92, label %88, label %93
93: ; preds = %88, %80
%94 = tail call i32 @fclose(i32* %76)
br label %95
95: ; preds = %93, %78
%96 = call i32 @fwrite(i8* %5, i32 4, i32 1, i32* %26)
%97 = call i32 @fwrite(i8* %6, i32 4, i32 1, i32* %26)
%98 = call i32 @fwrite(i8* %8, i32 2, i32 1, i32* %26)
%99 = tail call i32 @fclose(i32* %26)
ret i32 0
}