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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int v;
  FILE *fp;
  unsigned char buf[10];
  unsigned short top;
  uint8_t be;
  if (argc != 2 && argc != 3) {
    fprintf(stderr, "%s [executable] {size}\n", argv[0]);
    exit(1);
  }
  if (argc == 2)
    fp = fopen(argv[1], "r");
  else
    fp = fopen(argv[1], "r+");
  if (fp == NULL) {
    perror(argv[1]);
    exit(1);
  }
  if (fread(buf, 10, 1, fp) != 1) {
    fprintf(stderr, "%s: too short ?\n", argv[0]);
    exit(1);
  }
  if (buf[3] != 'F' || buf[4] != 'Z' || buf[5] != 'X' || buf[6] != '1') {
    fprintf(stderr, "%s: not a Fuzix binary format.\n", argv[1]);
    exit(1);
  }
  if (buf[3] == 0x7E || buf[3] == 0x20)
    be = 1;
  else if (buf[3] == 0x4C || buf[3] == 0x38)
    be = 0;
  else if (buf[3] == 0xC3 || buf[3] == 0x18)
    be = 0;
  else {
    fprintf(stderr, "%s: unknown Fuzix binary type.\n", argv[1]);
    exit(1);
  }
  if (argc == 2) {
    if (be)
      top = buf[9] | (buf[8] << 8);
    else
      top = buf[8] | (buf[9] << 8);
    if (top)
      printf("Fuzix binary set at %d bytes.\n", top);
    else
      printf("Fuzix binary, set to allocate all available.\n");
    exit(0);
  }
  if (sscanf(argv[2], "%d", &v) != 1 || v < 0 || v > 65536) {
    fprintf(stderr, "%s: invalid chmem value '%s'.\n", argv[0], argv[2]);
    exit(1);
  }
  if (be) {
    buf[8] = v >> 8;
    buf[9] = v & 0xFF;
  } else {
    buf[8] = v & 0xFF;
    buf[9] = v >> 8;
  }
  rewind(fp);
  if (fwrite(buf, 10, 1, fp) != 1) {
    fprintf(stderr, "%s: write error.\n", argv[0]);
    exit(1);
  }
  fclose(fp);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f2 <main+0x52>
cmpl   $0x3,-0x8(%rbp)
je     11f2 <main+0x52>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1219 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    1231 <main+0x91>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf2(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1253 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    -0x2a(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0xa,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     129b <main+0xfb>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movzbl -0x27(%rbp),%eax
cmp    $0x46,%eax
jne    12cf <main+0x12f>
movzbl -0x26(%rbp),%eax
cmp    $0x5a,%eax
jne    12cf <main+0x12f>
movzbl -0x25(%rbp),%eax
cmp    $0x58,%eax
jne    12cf <main+0x12f>
movzbl -0x24(%rbp),%eax
cmp    $0x31,%eax
je     12f8 <main+0x158>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd47(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movzbl -0x27(%rbp),%eax
cmp    $0x7e,%eax
je     1312 <main+0x172>
movzbl -0x27(%rbp),%eax
cmp    $0x20,%eax
jne    131e <main+0x17e>
movl   $0x1,-0x30(%rbp)
jmp    139f <main+0x1ff>
movzbl -0x27(%rbp),%eax
cmp    $0x4c,%eax
je     1338 <main+0x198>
movzbl -0x27(%rbp),%eax
cmp    $0x38,%eax
jne    1344 <main+0x1a4>
movl   $0x0,-0x30(%rbp)
jmp    139a <main+0x1fa>
movzbl -0x27(%rbp),%eax
cmp    $0xc3,%eax
je     1360 <main+0x1c0>
movzbl -0x27(%rbp),%eax
cmp    $0x18,%eax
jne    136c <main+0x1cc>
movl   $0x0,-0x30(%rbp)
jmp    1395 <main+0x1f5>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcca(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    139a <main+0x1fa>
jmp    139f <main+0x1ff>
cmpl   $0x2,-0x8(%rbp)
jne    1411 <main+0x271>
cmpl   $0x0,-0x30(%rbp)
je     13c9 <main+0x229>
movzbl -0x21(%rbp),%eax
movzbl -0x22(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,-0x2c(%rbp)
jmp    13da <main+0x23a>
movzbl -0x22(%rbp),%eax
movzbl -0x21(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,-0x2c(%rbp)
cmpw   $0x0,-0x2c(%rbp)
je     13fc <main+0x25c>
movzwl -0x2c(%rbp),%esi
lea    0xc7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    140a <main+0x26a>
lea    0xc8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xc9b(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    1449 <main+0x2a9>
cmpl   $0x0,-0x14(%rbp)
jl     1449 <main+0x2a9>
cmpl   $0x10000,-0x14(%rbp)
jle    1479 <main+0x2d9>
mov    0x2b90(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xc56(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x30(%rbp)
je     149c <main+0x2fc>
mov    -0x14(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0x22(%rbp)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x21(%rbp)
jmp    14b0 <main+0x310>
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x22(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x2a(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0xa,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
cmp    $0x1,%eax
je     1501 <main+0x361>
mov    0x2b00(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xbed(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    1198 <main+0x48>
cmp    $0x2,%edi
mov    0x8(%rbx),%rdi
lea    0xea8(%rip),%rax
lea    0xea3(%rip),%rsi
cmove  %rax,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
jne    11bc <main+0x6c>
mov    0x8(%rbx),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe55(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0x6(%rsp),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11ff <main+0xaf>
movd   0x9(%rsp),%xmm0
movd   %xmm0,%eax
mov    0x2df7(%rip),%rcx
mov    (%rcx),%edi
mov    0x8(%rbx),%rdx
cmp    $0x31585a46,%eax
jne    1214 <main+0xc4>
lea    0xe51(%rip),%rsi
jmp    11ab <main+0x5b>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe0b(%rip),%rsi
jmp    11ab <main+0x5b>
lea    0xe13(%rip),%rsi
jmp    11ab <main+0x5b>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"%s [executable] {size}\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [17 x i8] c"%s: too short ?\0A\00"
@.str.4 = [32 x i8] c"%s: not a Fuzix binary format.\0A\00"
@.str.5 = [32 x i8] c"%s: unknown Fuzix binary type.\0A\00"
@.str.6 = [31 x i8] c"Fuzix binary set at %d bytes.\0A\00"
@.str.7 = [46 x i8] c"Fuzix binary, set to allocate all available.\0A\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [31 x i8] c"%s: invalid chmem value '%s'.\0A\00"
@.str.10 = [18 x i8] c"%s: write error.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [10 x i8]
%9 = alloca i16
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %13, %2
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%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
br label %36
31: ; preds = %23
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %35, i32** %7
br label %36
36: ; preds = %31, %26
%37 = load i32*, i32** %7
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %45
39: ; preds = %36
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @perror(i8* %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %36
%46 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%47 = load i32*, i32** %7
%48 = call i32 @fread(i8* %46, i32 10, i32 1, i32* %47)
%49 = icmp ne i32 %48, 1
br i1 %49, label %50, label %57
50: ; preds = %45
%51 = load i32, i32* @stderr
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %54)
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %45
%58 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = icmp ne i32 %60, 70
br i1 %61, label %77, label %62
62: ; preds = %57
%63 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 4
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = icmp ne i32 %65, 90
br i1 %66, label %77, label %67
67: ; preds = %62
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 5
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = icmp ne i32 %70, 88
br i1 %71, label %77, label %72
72: ; preds = %67
%73 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 6
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = icmp ne i32 %75, 49
br i1 %76, label %77, label %84
77: ; preds = %72, %67, %62, %57
%78 = load i32, i32* @stderr
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %81)
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %72
%85 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = icmp eq i32 %87, 126
br i1 %88, label %94, label %89
89: ; preds = %84
%90 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
%91 = load i8, i8* %90
%92 = zext i8 %91 to i32
%93 = icmp eq i32 %92, 32
br i1 %93, label %94, label %95
94: ; preds = %89, %84
store i32 1, i32* %10
br label %126
95: ; preds = %89
%96 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = icmp eq i32 %98, 76
br i1 %99, label %105, label %100
100: ; preds = %95
%101 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
%102 = load i8, i8* %101
%103 = zext i8 %102 to i32
%104 = icmp eq i32 %103, 56
br i1 %104, label %105, label %106
105: ; preds = %100, %95
store i32 0, i32* %10
br label %125
106: ; preds = %100
%107 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
%108 = load i8, i8* %107
%109 = zext i8 %108 to i32
%110 = icmp eq i32 %109, 195
br i1 %110, label %116, label %111
111: ; preds = %106
%112 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = icmp eq i32 %114, 24
br i1 %115, label %116, label %117
116: ; preds = %111, %106
store i32 0, i32* %10
br label %124
117: ; preds = %111
%118 = load i32, i32* @stderr
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 1
%121 = load i8*, i8** %120
%122 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %121)
%123 = call i32 @exit(i32 1)
unreachable
124: ; preds = %116
br label %125
125: ; preds = %124, %105
br label %126
126: ; preds = %125, %94
%127 = load i32, i32* %4
%128 = icmp eq i32 %127, 2
br i1 %128, label %129, label %163
129: ; preds = %126
%130 = load i32, i32* %10
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %142
132: ; preds = %129
%133 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 9
%134 = load i8, i8* %133
%135 = zext i8 %134 to i32
%136 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 8
%137 = load i8, i8* %136
%138 = zext i8 %137 to i32
%139 = shl i32 %138, 8
%140 = or i32 %135, %139
%141 = trunc i32 %140 to i16
store i16 %141, i16* %9
br label %152
142: ; preds = %129
%143 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 8
%144 = load i8, i8* %143
%145 = zext i8 %144 to i32
%146 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 9
%147 = load i8, i8* %146
%148 = zext i8 %147 to i32
%149 = shl i32 %148, 8
%150 = or i32 %145, %149
%151 = trunc i32 %150 to i16
store i16 %151, i16* %9
br label %152
152: ; preds = %142, %132
%153 = load i16, i16* %9
%154 = icmp ne i16 %153, 0
br i1 %154, label %155, label %159
155: ; preds = %152
%156 = load i16, i16* %9
%157 = zext i16 %156 to i32
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %157)
br label %161
159: ; preds = %152
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0))
br label %161
161: ; preds = %159, %155
%162 = call i32 @exit(i32 0)
unreachable
163: ; preds = %126
%164 = load i8**, i8*** %5
%165 = getelementptr inbounds i8*, i8** %164, i64 2
%166 = load i8*, i8** %165
%167 = call i32 @sscanf(i8* %166, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %6)
%168 = icmp ne i32 %167, 1
br i1 %168, label %175, label %169
169: ; preds = %163
%170 = load i32, i32* %6
%171 = icmp slt i32 %170, 0
br i1 %171, label %175, label %172
172: ; preds = %169
%173 = load i32, i32* %6
%174 = icmp sgt i32 %173, 65536
br i1 %174, label %175, label %185
175: ; preds = %172, %169, %163
%176 = load i32, i32* @stderr
%177 = load i8**, i8*** %5
%178 = getelementptr inbounds i8*, i8** %177, i64 0
%179 = load i8*, i8** %178
%180 = load i8**, i8*** %5
%181 = getelementptr inbounds i8*, i8** %180, i64 2
%182 = load i8*, i8** %181
%183 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %179, i8* %182)
%184 = call i32 @exit(i32 1)
unreachable
185: ; preds = %172
%186 = load i32, i32* %10
%187 = icmp ne i32 %186, 0
br i1 %187, label %188, label %197
188: ; preds = %185
%189 = load i32, i32* %6
%190 = ashr i32 %189, 8
%191 = trunc i32 %190 to i8
%192 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 8
store i8 %191, i8* %192
%193 = load i32, i32* %6
%194 = and i32 %193, 255
%195 = trunc i32 %194 to i8
%196 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 9
store i8 %195, i8* %196
br label %206
197: ; preds = %185
%198 = load i32, i32* %6
%199 = and i32 %198, 255
%200 = trunc i32 %199 to i8
%201 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 8
store i8 %200, i8* %201
%202 = load i32, i32* %6
%203 = ashr i32 %202, 8
%204 = trunc i32 %203 to i8
%205 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 9
store i8 %204, i8* %205
br label %206
206: ; preds = %197, %188
%207 = load i32*, i32** %7
%208 = call i32 @rewind(i32* %207)
%209 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%210 = load i32*, i32** %7
%211 = call i32 @fwrite(i8* %209, i32 10, i32 1, i32* %210)
%212 = icmp ne i32 %211, 1
br i1 %212, label %213, label %220
213: ; preds = %206
%214 = load i32, i32* @stderr
%215 = load i8**, i8*** %5
%216 = getelementptr inbounds i8*, i8** %215, i64 0
%217 = load i8*, i8** %216
%218 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %214, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %217)
%219 = call i32 @exit(i32 1)
unreachable
220: ; preds = %206
%221 = load i32*, i32** %7
%222 = call i32 @fclose(i32* %221)
%223 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"%s [executable] {size}\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [17 x i8] c"%s: too short ?\0A\00"
@.str.4 = [32 x i8] c"%s: not a Fuzix binary format.\0A\00"
@.str.5 = [32 x i8] c"%s: unknown Fuzix binary type.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = and i32 %0, -2
%6 = icmp eq i32 %5, 2
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = icmp eq i32 %0, 2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%17 = tail call i32* @fopen(i8* %15, i8* %16)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @perror(i8* %21)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %12
%25 = call i32 @fread(i8* %4, i32 10, i32 1, i32* %17)
%26 = icmp eq i32 %25, 1
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %1
%30 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %24
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
%34 = bitcast i8* %33 to <4 x i8>*
%35 = load <4 x i8>, <4 x i8>* %34
%36 = freeze <4 x i8> %35
%37 = bitcast <4 x i8> %36 to i32
%38 = icmp eq i32 %37, 827873862
%39 = load i32, i32* @stderr
%40 = getelementptr inbounds i8*, i8** %1, i64 1
%41 = load i8*, i8** %40
br i1 %38, label %45, label %42
42: ; preds = %32
%43 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %32
%46 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%47 = tail call i32 @exit(i32 1)
unreachable
}