#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ lseek(int, long, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
long tell(int);
int write(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  int fd;
  long fsize;
  unsigned char b1, b2, b3, bfr[14];
  if (argc != 2) {
    fprintf(stderr, "usage: %s filename\n", argv[0]);
    return 1;
  }
  fd = open(argv[1], O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "%s: can't open file %s\n", argv[0], argv[1]);
    return 1;
  }
  if (read(fd, bfr, 3) != 3) {
    fprintf(stderr, "%s: read error from %s\n", argv[0], argv[1]);
    return 1;
  }
  b1 = bfr[0];
  b2 = bfr[1];
  b3 = bfr[2];
  if (b1 == 0xc3) {
    printf("%s: no patch needed\n", argv[0]);
    close(fd);
    return 0;
  }
  lseek(fd, 0L, SEEK_END);
  fsize = tell(fd);
  bfr[0] = 0x21;
  bfr[1] = 0x00;
  bfr[2] = 0x01;
  bfr[3] = 0x36;
  bfr[4] = b1;
  bfr[5] = 0x23;
  bfr[6] = 0x36;
  bfr[7] = b2;
  bfr[8] = 0x23;
  bfr[9] = 0x36;
  bfr[10] = b3;
  bfr[11] = 0xc3;
  bfr[12] = 0x00;
  bfr[13] = 0x01;
  if (write(fd, bfr, 14) != 14) {
    fprintf(stderr, "%s: file write error\n", argv[0]);
    return -1;
  }
  lseek(fd, 0L, SEEK_SET);
  if (tell(fd) != 0L) {
    fprintf(stderr, "%s: seek error\n", argv[0]);
    return -1;
  }
  bfr[0] = 0xc3;
  bfr[1] = (fsize + 0x100) & 0xff;
  bfr[2] = ((fsize + 0x100) >> 8) & 0xff;
  if (write(fd, bfr, 3) != 3) {
    fprintf(stderr, "%s: file write error\n", argv[0]);
    return -1;
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ca <main+0x4a>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1428 <main+0x2a8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    121f <main+0x9f>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1428 <main+0x2a8>
mov    -0x14(%rbp),%edi
lea    -0x31(%rbp),%rsi
mov    $0x3,%edx
call   1070 <read@plt>
cmp    $0x3,%eax
je     126b <main+0xeb>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1428 <main+0x2a8>
mov    -0x31(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x30(%rbp),%al
mov    %al,-0x22(%rbp)
mov    -0x2f(%rbp),%al
mov    %al,-0x23(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0xc3,%eax
jne    12b3 <main+0x133>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdaa(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1428 <main+0x2a8>
mov    -0x14(%rbp),%edi
mov    0x2d23(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <lseek@plt>
mov    -0x14(%rbp),%edi
call   1090 <tell@plt>
mov    %rax,-0x20(%rbp)
movb   $0x21,-0x31(%rbp)
movb   $0x0,-0x30(%rbp)
movb   $0x1,-0x2f(%rbp)
movb   $0x36,-0x2e(%rbp)
mov    -0x21(%rbp),%al
mov    %al,-0x2d(%rbp)
movb   $0x23,-0x2c(%rbp)
movb   $0x36,-0x2b(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x2a(%rbp)
movb   $0x23,-0x29(%rbp)
movb   $0x36,-0x28(%rbp)
mov    -0x23(%rbp),%al
mov    %al,-0x27(%rbp)
movb   $0xc3,-0x26(%rbp)
movb   $0x0,-0x25(%rbp)
movb   $0x1,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x31(%rbp),%rsi
mov    $0xe,%edx
call   1030 <write@plt>
cmp    $0xe,%eax
je     1356 <main+0x1d6>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd16(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1428 <main+0x2a8>
mov    -0x14(%rbp),%edi
mov    0x2c68(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <lseek@plt>
mov    -0x14(%rbp),%edi
call   1090 <tell@plt>
cmp    $0x0,%rax
je     13a7 <main+0x227>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcdb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1428 <main+0x2a8>
movb   $0xc3,-0x31(%rbp)
mov    -0x20(%rbp),%rax
add    $0x100,%rax
and    $0xff,%rax
mov    %al,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    $0x100,%rax
sar    $0x8,%rax
and    $0xff,%rax
mov    %al,-0x2f(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x31(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
cmp    $0x3,%eax
je     1419 <main+0x299>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc53(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1428 <main+0x2a8>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11ed <main+0x6d>
mov    0x8(%rbx),%rdi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
test   %eax,%eax
js     1209 <main+0x89>
mov    %eax,%ebp
lea    0xa(%rsp),%rsi
mov    %eax,%edi
mov    $0x3,%edx
call   1070 <read@plt>
cmp    $0x3,%eax
jne    1222 <main+0xa2>
mov    0xa(%rsp),%r15b
cmp    $0xc3,%r15b
jne    1254 <main+0xd4>
mov    (%rbx),%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    %ebp,%edi
call   1060 <close@plt>
xor    %eax,%eax
jmp    1245 <main+0xc5>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe00(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1240 <main+0xc0>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x8(%rbx),%rcx
lea    0xdf4(%rip),%rsi
jmp    1239 <main+0xb9>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x8(%rbx),%rcx
lea    0xdf3(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0xb(%rsp),%r12b
mov    0xc(%rsp),%r13b
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %ebp,%edi
call   1090 <tell@plt>
mov    %rax,%r14
movl   $0x36010021,0xa(%rsp)
36
mov    %r15b,0xe(%rsp)
movw   $0x3623,0xf(%rsp)
mov    %r12b,0x11(%rsp)
movw   $0x3623,0x12(%rsp)
mov    %r13b,0x14(%rsp)
movw   $0xc3,0x15(%rsp)
movb   $0x1,0x17(%rsp)
lea    0xa(%rsp),%rsi
mov    %ebp,%edi
mov    $0xe,%edx
call   1030 <write@plt>
cmp    $0xe,%eax
jne    1323 <main+0x1a3>
mov    0x2d00(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %ebp,%edi
call   1090 <tell@plt>
test   %rax,%rax
je     12f4 <main+0x174>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd7d(%rip),%rsi
jmp    1336 <main+0x1b6>
movb   $0xc3,0xa(%rsp)
lea    0x100(%r14),%eax
mov    %r14b,0xb(%rsp)
mov    %ah,0xc(%rsp)
lea    0xa(%rsp),%rsi
mov    %ebp,%edi
mov    $0x3,%edx
call   1030 <write@plt>
cmp    $0x3,%eax
je     11e2 <main+0x62>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd23(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1245 <main+0xc5>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"usage: %s filename\0A\00"
@O_RDWR = global i32 0
@.str.1 = [24 x i8] c"%s: can't open file %s\0A\00"
@.str.2 = [24 x i8] c"%s: read error from %s\0A\00"
@.str.3 = [21 x i8] c"%s: no patch needed\0A\00"
@SEEK_END = global i32 0
@.str.4 = [22 x i8] c"%s: file write error\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [16 x i8] c"%s: seek error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca [14 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %20
14: ; preds = %2
%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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %140
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDWR
%25 = call i32 @open(i8* %23, i32 %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %20
%29 = load i32, i32* @stderr
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %35)
store i32 1, i32* %3
br label %140
37: ; preds = %20
%38 = load i32, i32* %6
%39 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
%40 = call i32 @read(i32 %38, i8* %39, i32 3)
%41 = icmp ne i32 %40, 3
br i1 %41, label %42, label %51
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* %49)
store i32 1, i32* %3
br label %140
51: ; preds = %37
%52 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
%53 = load i8, i8* %52
store i8 %53, i8* %8
%54 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 1
%55 = load i8, i8* %54
store i8 %55, i8* %9
%56 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 2
%57 = load i8, i8* %56
store i8 %57, i8* %10
%58 = load i8, i8* %8
%59 = zext i8 %58 to i32
%60 = icmp eq i32 %59, 195
br i1 %60, label %61, label %68
61: ; preds = %51
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %64)
%66 = load i32, i32* %6
%67 = call i32 @close(i32 %66)
store i32 0, i32* %3
br label %140
68: ; preds = %51
%69 = load i32, i32* %6
%70 = load i32, i32* @SEEK_END
%71 = call i32 @lseek(i32 %69, i64 0, i32 %70)
%72 = load i32, i32* %6
%73 = call i64 @tell(i32 %72)
store i64 %73, i64* %7
%74 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
store i8 33, i8* %74
%75 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 1
store i8 0, i8* %75
%76 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 2
store i8 1, i8* %76
%77 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 3
store i8 54, i8* %77
%78 = load i8, i8* %8
%79 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 4
store i8 %78, i8* %79
%80 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 5
store i8 35, i8* %80
%81 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 6
store i8 54, i8* %81
%82 = load i8, i8* %9
%83 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 7
store i8 %82, i8* %83
%84 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 8
store i8 35, i8* %84
%85 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 9
store i8 54, i8* %85
%86 = load i8, i8* %10
%87 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 10
store i8 %86, i8* %87
%88 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 11
store i8 -61, i8* %88
%89 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 12
store i8 0, i8* %89
%90 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 13
store i8 1, i8* %90
%91 = load i32, i32* %6
%92 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
%93 = call i32 @write(i32 %91, i8* %92, i32 14)
%94 = icmp ne i32 %93, 14
br i1 %94, label %95, label %101
95: ; preds = %68
%96 = load i32, i32* @stderr
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 0
%99 = load i8*, i8** %98
%100 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %99)
store i32 -1, i32* %3
br label %140
101: ; preds = %68
%102 = load i32, i32* %6
%103 = load i32, i32* @SEEK_SET
%104 = call i32 @lseek(i32 %102, i64 0, i32 %103)
%105 = load i32, i32* %6
%106 = call i64 @tell(i32 %105)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %114
108: ; preds = %101
%109 = load i32, i32* @stderr
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 0
%112 = load i8*, i8** %111
%113 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %112)
store i32 -1, i32* %3
br label %140
114: ; preds = %101
%115 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
store i8 -61, i8* %115
%116 = load i64, i64* %7
%117 = add nsw i64 %116, 256
%118 = and i64 %117, 255
%119 = trunc i64 %118 to i8
%120 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 1
store i8 %119, i8* %120
%121 = load i64, i64* %7
%122 = add nsw i64 %121, 256
%123 = ashr i64 %122, 8
%124 = and i64 %123, 255
%125 = trunc i64 %124 to i8
%126 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 2
store i8 %125, i8* %126
%127 = load i32, i32* %6
%128 = getelementptr inbounds [14 x i8], [14 x i8]* %11, i64 0, i64 0
%129 = call i32 @write(i32 %127, i8* %128, i32 3)
%130 = icmp ne i32 %129, 3
br i1 %130, label %131, label %137
131: ; preds = %114
%132 = load i32, i32* @stderr
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 0
%135 = load i8*, i8** %134
%136 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %135)
store i32 -1, i32* %3
br label %140
137: ; preds = %114
%138 = load i32, i32* %6
%139 = call i32 @close(i32 %138)
store i32 0, i32* %3
br label %140
140: ; preds = %137, %131, %108, %95, %61, %42, %28, %14
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"usage: %s filename\0A\00"
@O_RDWR = global i32 0
@.str.1 = [24 x i8] c"%s: can't open file %s\0A\00"
@.str.2 = [24 x i8] c"%s: read error from %s\0A\00"
@.str.3 = [21 x i8] c"%s: no patch needed\0A\00"
@SEEK_END = global i32 0
@.str.4 = [22 x i8] c"%s: file write error\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [16 x i8] c"%s: seek error\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [14 x i8]
%4 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %83
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDWR
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = load i8*, i8** %11
%20 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19)
br label %83
21: ; preds = %10
%22 = call i32 @read(i32 %14, i8* %4, i32 3)
%23 = icmp eq i32 %22, 3
br i1 %23, label %29, label %24
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %1
%27 = load i8*, i8** %11
%28 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %27)
br label %83
29: ; preds = %21
%30 = load i8, i8* %4
%31 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 1
%32 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 2
%33 = icmp eq i8 %30, -61
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i8*, i8** %1
%36 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%37 = tail call i32 @close(i32 %14)
br label %83
38: ; preds = %29
%39 = load i8, i8* %32
%40 = load i8, i8* %31
%41 = load i32, i32* @SEEK_END
%42 = tail call i32 @lseek(i32 %14, i64 0, i32 %41)
%43 = tail call i64 @tell(i32 %14)
store i8 33, i8* %4
store i8 0, i8* %31
store i8 1, i8* %32
%44 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 3
store i8 54, i8* %44
%45 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 4
store i8 %30, i8* %45
%46 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 5
store i8 35, i8* %46
%47 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 6
store i8 54, i8* %47
%48 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 7
store i8 %40, i8* %48
%49 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 8
store i8 35, i8* %49
%50 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 9
store i8 54, i8* %50
%51 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 10
store i8 %39, i8* %51
%52 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 11
store i8 -61, i8* %52
%53 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 12
store i8 0, i8* %53
%54 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 13
store i8 1, i8* %54
%55 = call i32 @write(i32 %14, i8* %4, i32 14)
%56 = icmp eq i32 %55, 14
br i1 %56, label %61, label %57
57: ; preds = %38
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %1
%60 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %59)
br label %83
61: ; preds = %38
%62 = load i32, i32* @SEEK_SET
%63 = tail call i32 @lseek(i32 %14, i64 0, i32 %62)
%64 = tail call i64 @tell(i32 %14)
%65 = icmp eq i64 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %61
%67 = load i32, i32* @stderr
%68 = load i8*, i8** %1
%69 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %68)
br label %83
70: ; preds = %61
store i8 -61, i8* %4
%71 = add nsw i64 %43, 256
%72 = trunc i64 %43 to i8
store i8 %72, i8* %31
%73 = lshr i64 %71, 8
%74 = trunc i64 %73 to i8
store i8 %74, i8* %32
%75 = call i32 @write(i32 %14, i8* %4, i32 3)
%76 = icmp eq i32 %75, 3
br i1 %76, label %81, label %77
77: ; preds = %70
%78 = load i32, i32* @stderr
%79 = load i8*, i8** %1
%80 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %79)
br label %83
81: ; preds = %70
%82 = tail call i32 @close(i32 %14)
br label %83
83: ; preds = %81, %77, %66, %57, %34, %24, %16, %6
%84 = phi i32 [ 1, %6 ], [ 1, %16 ], [ 1, %24 ], [ 0, %34 ], [ -1, %57 ], [ -1, %66 ], [ -1, %77 ], [ 0, %81 ]
ret i32 %84
}