#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*/ 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[8];
  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, 8, 1, fp) != 1) {
    fprintf(stderr, "%s: too short ?\n", argv[0]);
    exit(1);
  }
  if (buf[0] != 0xC3 || buf[3] != 'U' || buf[4] != 'Z') {
    fprintf(stderr, "%s: not an UZI binary format.\n", argv[1]);
    exit(1);
  }
  if (argc == 2) {
    if (buf[5] == 'I')
      printf("classic UZI binary.\n");
    else if (buf[5] & 0x80)
      printf("chmem UZI binary set at %d bytes.\n", (buf[5] & 0x7F) << 9);
    else
      printf("UZI binary with unknown tail byte %d\n", buf[5]);
    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 (v == 0)
    buf[5] = 'I';
  else
    buf[5] = ((v + 511) >> 9) | 0x80;
  rewind(fp);
  if (fwrite(buf, 8, 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    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x8,%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 -0x28(%rbp),%eax
cmp    $0xc3,%eax
jne    12c4 <main+0x124>
movzbl -0x25(%rbp),%eax
cmp    $0x55,%eax
jne    12c4 <main+0x124>
movzbl -0x24(%rbp),%eax
cmp    $0x5a,%eax
je     12ed <main+0x14d>
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd52(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1364 <main+0x1c4>
movzbl -0x23(%rbp),%eax
cmp    $0x49,%eax
jne    1317 <main+0x177>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    135d <main+0x1bd>
movzbl -0x23(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1346 <main+0x1a6>
movzbl -0x23(%rbp),%esi
and    $0x7f,%esi
shl    $0x9,%esi
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1358 <main+0x1b8>
movzbl -0x23(%rbp),%esi
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    135d <main+0x1bd>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd38(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    139c <main+0x1fc>
cmpl   $0x0,-0x14(%rbp)
jl     139c <main+0x1fc>
cmpl   $0x10000,-0x14(%rbp)
jle    13cc <main+0x22c>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xcf3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
jne    13df <main+0x23f>
movb   $0x49,-0x23(%rbp)
jmp    13f2 <main+0x252>
mov    -0x14(%rbp),%eax
add    $0x1ff,%eax
sar    $0x9,%eax
or     $0x80,%eax
mov    %al,-0x23(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x8,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
cmp    $0x1,%eax
je     1443 <main+0x2a3>
mov    0x2bbe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc9b(%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   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    11fd <main+0x4d>
mov    %edi,%ebp
cmp    $0x2,%edi
mov    0x8(%rbx),%rdi
lea    0xe43(%rip),%rax
lea    0xe3e(%rip),%rsi
cmove  %rax,%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
jne    1215 <main+0x65>
mov    0x8(%rbx),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdf0(%rip),%rsi
jmp    1298 <main+0xe8>
mov    %rax,%r14
lea    0x4(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    126f <main+0xbf>
cmpb   $0xc3,0x4(%rsp)
jne    1284 <main+0xd4>
cmpb   $0x55,0x7(%rsp)
jne    1284 <main+0xd4>
cmpb   $0x5a,0x8(%rsp)
jne    1284 <main+0xd4>
cmp    $0x2,%ebp
jne    12a9 <main+0xf9>
movzbl 0x9(%rsp),%esi
cmp    $0x49,%esi
jne    1322 <main+0x172>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd9b(%rip),%rsi
jmp    1298 <main+0xe8>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd96(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x10(%rbx),%rdi
lea    0xde2(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    1331 <main+0x181>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     1331 <main+0x181>
cmp    $0x10001,%eax
jge    1331 <main+0x181>
lea    0x1ff(%rax),%ecx
shr    $0x9,%ecx
or     $0x80,%cl
test   %eax,%eax
movzbl %cl,%eax
mov    $0x49,%ecx
cmovne %eax,%ecx
mov    %cl,0x9(%rsp)
mov    %r14,%rdi
call   1070 <rewind@plt>
lea    0x4(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
jne    1359 <main+0x1a9>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
test   $0x80,%sil
jne    1371 <main+0x1c1>
lea    0xd41(%rip),%rdi
jmp    137e <main+0x1ce>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x10(%rbx),%rcx
lea    0xd51(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd4c(%rip),%rsi
jmp    1298 <main+0xe8>
shl    $0x9,%esi
movzwl %si,%esi
lea    0xccf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

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 = [31 x i8] c"%s: not an UZI binary format.\0A\00"
@.str.5 = [21 x i8] c"classic UZI binary.\0A\00"
@.str.6 = [35 x i8] c"chmem UZI binary set at %d bytes.\0A\00"
@.str.7 = [38 x i8] c"UZI binary with unknown tail byte %d\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 [8 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %11, %2
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %7
br label %34
29: ; preds = %21
%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** %7
br label %34
34: ; preds = %29, %24
%35 = load i32*, i32** %7
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @perror(i8* %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %34
%44 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%45 = load i32*, i32** %7
%46 = call i32 @fread(i8* %44, i32 8, i32 1, i32* %45)
%47 = icmp ne i32 %46, 1
br i1 %47, label %48, label %55
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 0
%52 = load i8*, i8** %51
%53 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %43
%56 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = icmp ne i32 %58, 195
br i1 %59, label %70, label %60
60: ; preds = %55
%61 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 3
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = icmp ne i32 %63, 85
br i1 %64, label %70, label %65
65: ; preds = %60
%66 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 4
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = icmp ne i32 %68, 90
br i1 %69, label %70, label %77
70: ; preds = %65, %60, %55
%71 = load i32, i32* @stderr
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %74)
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %65
%78 = load i32, i32* %4
%79 = icmp eq i32 %78, 2
br i1 %79, label %80, label %108
80: ; preds = %77
%81 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 5
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = icmp eq i32 %83, 73
br i1 %84, label %85, label %87
85: ; preds = %80
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %106
87: ; preds = %80
%88 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 5
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = and i32 %90, 128
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %100
93: ; preds = %87
%94 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 5
%95 = load i8, i8* %94
%96 = zext i8 %95 to i32
%97 = and i32 %96, 127
%98 = shl i32 %97, 9
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %98)
br label %105
100: ; preds = %87
%101 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 5
%102 = load i8, i8* %101
%103 = zext i8 %102 to i32
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %103)
br label %105
105: ; preds = %100, %93
br label %106
106: ; preds = %105, %85
%107 = call i32 @exit(i32 0)
unreachable
108: ; preds = %77
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 2
%111 = load i8*, i8** %110
%112 = call i32 @sscanf(i8* %111, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %6)
%113 = icmp ne i32 %112, 1
br i1 %113, label %120, label %114
114: ; preds = %108
%115 = load i32, i32* %6
%116 = icmp slt i32 %115, 0
br i1 %116, label %120, label %117
117: ; preds = %114
%118 = load i32, i32* %6
%119 = icmp sgt i32 %118, 65536
br i1 %119, label %120, label %130
120: ; preds = %117, %114, %108
%121 = load i32, i32* @stderr
%122 = load i8**, i8*** %5
%123 = getelementptr inbounds i8*, i8** %122, i64 0
%124 = load i8*, i8** %123
%125 = load i8**, i8*** %5
%126 = getelementptr inbounds i8*, i8** %125, i64 2
%127 = load i8*, i8** %126
%128 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %124, i8* %127)
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %117
%131 = load i32, i32* %6
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %135
133: ; preds = %130
%134 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 5
store i8 73, i8* %134
br label %142
135: ; preds = %130
%136 = load i32, i32* %6
%137 = add nsw i32 %136, 511
%138 = ashr i32 %137, 9
%139 = or i32 %138, 128
%140 = trunc i32 %139 to i8
%141 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 5
store i8 %140, i8* %141
br label %142
142: ; preds = %135, %133
%143 = load i32*, i32** %7
%144 = call i32 @rewind(i32* %143)
%145 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%146 = load i32*, i32** %7
%147 = call i32 @fwrite(i8* %145, i32 8, i32 1, i32* %146)
%148 = icmp ne i32 %147, 1
br i1 %148, label %149, label %156
149: ; preds = %142
%150 = load i32, i32* @stderr
%151 = load i8**, i8*** %5
%152 = getelementptr inbounds i8*, i8** %151, i64 0
%153 = load i8*, i8** %152
%154 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %153)
%155 = call i32 @exit(i32 1)
unreachable
156: ; preds = %142
%157 = load i32*, i32** %7
%158 = call i32 @fclose(i32* %157)
%159 = 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 = [31 x i8] c"%s: not an UZI binary format.\0A\00"
@.str.6 = [35 x i8] c"chmem UZI binary set at %d bytes.\0A\00"
@.str.7 = [38 x i8] c"UZI binary with unknown tail byte %d\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"
@str = [20 x i8] c"classic UZI binary.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [8 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = and i32 %0, -2
%8 = icmp eq i32 %7, 2
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = icmp eq i32 %0, 2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = select i1 %15, 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)
%19 = tail call i32* @fopen(i8* %17, i8* %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %26
21: ; preds = %14
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32 @perror(i8* %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %14
%27 = call i32 @fread(i8* %6, i32 8, i32 1, i32* %19)
%28 = icmp eq i32 %27, 1
br i1 %28, label %34, label %29
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %1
%32 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %26
%35 = load i8, i8* %6
%36 = icmp ne i8 %35, -61
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 3
%38 = load i8, i8* %37
%39 = icmp ne i8 %38, 85
%40 = select i1 %36, i1 true, i1 %39
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 4
%42 = load i8, i8* %41
%43 = icmp ne i8 %42, 90
%44 = select i1 %40, i1 true, i1 %43
br i1 %44, label %45, label %51
45: ; preds = %34
%46 = load i32, i32* @stderr
%47 = getelementptr inbounds i8*, i8** %1, i64 1
%48 = load i8*, i8** %47
%49 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = tail call i32 @exit(i32 1)
unreachable
51: ; preds = %34
br i1 %15, label %52, label %70
52: ; preds = %51
%53 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 5
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = icmp eq i8 %54, 73
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %68
59: ; preds = %52
%60 = and i32 %55, 128
%61 = icmp eq i32 %60, 0
br i1 %61, label %66, label %62
62: ; preds = %59
%63 = shl nuw nsw i32 %55, 9
%64 = and i32 %63, 65024
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %64)
br label %68
66: ; preds = %59
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %55)
br label %68
68: ; preds = %62, %66, %57
%69 = tail call i32 @exit(i32 0)
unreachable
70: ; preds = %51
%71 = getelementptr inbounds i8*, i8** %1, i64 2
%72 = load i8*, i8** %71
%73 = call i32 @sscanf(i8* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%74 = icmp ne i32 %73, 1
%75 = load i32, i32* %3
%76 = icmp slt i32 %75, 0
%77 = select i1 %74, i1 true, i1 %76
%78 = icmp sgt i32 %75, 65536
%79 = select i1 %77, i1 true, i1 %78
br i1 %79, label %80, label %86
80: ; preds = %70
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %1
%83 = load i8*, i8** %71
%84 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %82, i8* %83)
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %70
%87 = icmp eq i32 %75, 0
%88 = add nuw nsw i32 %75, 511
%89 = lshr i32 %88, 9
%90 = trunc i32 %89 to i8
%91 = or i8 %90, -128
%92 = select i1 %87, i8 73, i8 %91
%93 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 5
store i8 %92, i8* %93
%94 = call i32 @rewind(i32* %19)
%95 = call i32 @fwrite(i8* %6, i32 8, i32 1, i32* %19)
%96 = icmp eq i32 %95, 1
br i1 %96, label %102, label %97
97: ; preds = %86
%98 = load i32, i32* @stderr
%99 = load i8*, i8** %1
%100 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %99)
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %86
%103 = call i32 @fclose(i32* %19)
%104 = call i32 @exit(i32 0)
unreachable
}