main(argc, argv) int argc;
char *argv[];
{
  char *p;
  unsigned int n;
  int fd, separate;
  long lsize, olddynam, newdynam, newtot, overflow, header[8];
  p = argv[1];
  if (argc != 3)
    usage();
  if (*p != '=' && *p != '+' && *p != '-')
    usage();
  n = atoi(p + 1);
  lsize = n;
  if (n > 65520)
    stderr3("chmem: ", p + 1, " too large\n");
  fd = open(argv[2], 2);
  if (fd < 0)
    stderr3("chmem: can't open ", argv[2], "\n");
  if (read(fd, header, sizeof(header)) != sizeof(header))
    stderr3("chmem: ", argv[2], "bad header\n");
  if ((header[0] & 0xFFFF) != 0x0301)
    stderr3("chmem: ", argv[2], " not executable\n");
  separate = (header[0] & 0x00200000 ? 1 : 0);
  olddynam = header[6] - header[3] - header[4];
  if (separate == 0)
    olddynam -= header[2];
  if (*p == '=')
    newdynam = lsize;
  else if (*p == '+')
    newdynam = olddynam + lsize;
  else if (*p == '-')
    newdynam = olddynam - lsize;
  newtot = header[3] + header[4] + newdynam;
  overflow = (newtot > 65536L ? newtot - 65536L : 0);
  newdynam -= overflow;
  newtot -= overflow;
  if (separate == 0)
    newtot += header[2];
  lseek(fd, (long)24, 0);
  if (write(fd, &newtot, 4) < 0)
    stderr3("chmem: can't modify ", argv[2], "\n");
  printf("%s: Stack+malloc area changed from %D to %D bytes.\n", argv[2],
         olddynam, newdynam);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11c6 <main+0x36>
mov    $0x0,%al
call   1080 <usage@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
je     11fd <main+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     11fd <main+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11fd <main+0x6d>
mov    $0x0,%al
call   1080 <usage@plt>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    $0x0,%al
call   10a0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x30(%rbp)
cmpl   $0xfff0,-0x1c(%rbp)
jbe    1240 <main+0xb0>
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
lea    0xdce(%rip),%rdi
lea    0xdcf(%rip),%rdx
mov    $0x0,%al
call   1060 <stderr3@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    127e <main+0xee>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xda4(%rip),%rdi
lea    0xe14(%rip),%rdx
mov    $0x0,%al
call   1060 <stderr3@plt>
mov    -0x20(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x40,%edx
mov    $0x0,%al
call   1070 <read@plt>
cltq
cmp    $0x40,%rax
je     12bd <main+0x12d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd51(%rip),%rdi
lea    0xd71(%rip),%rdx
mov    $0x0,%al
call   1060 <stderr3@plt>
mov    -0x90(%rbp),%rax
and    $0xffff,%rax
cmp    $0x301,%rax
je     12f3 <main+0x163>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd1b(%rip),%rdi
lea    0xd47(%rip),%rdx
mov    $0x0,%al
call   1060 <stderr3@plt>
mov    -0x90(%rbp),%rdx
and    $0x200000,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x60(%rbp),%rax
sub    -0x78(%rbp),%rax
sub    -0x70(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    133b <main+0x1ab>
mov    -0x80(%rbp),%rcx
mov    -0x38(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    1358 <main+0x1c8>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    139f <main+0x20f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1379 <main+0x1e9>
mov    -0x38(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    139a <main+0x20a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1395 <main+0x205>
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    139a <main+0x20a>
jmp    139f <main+0x20f>
mov    -0x78(%rbp),%rax
add    -0x70(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x10000,-0x48(%rbp)
jle    13d3 <main+0x243>
mov    -0x48(%rbp),%rax
sub    $0x10000,%rax
mov    %rax,-0x98(%rbp)
jmp    13e1 <main+0x251>
xor    %eax,%eax
mov    %rax,-0x98(%rbp)
jmp    13e1 <main+0x251>
mov    -0x98(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rcx
mov    -0x40(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x50(%rbp),%rcx
mov    -0x48(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1420 <main+0x290>
mov    -0x80(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x18,%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <lseek@plt>
mov    -0x20(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    $0x0,%eax
jge    146a <main+0x2da>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xbe8(%rip),%rdi
lea    0xc28(%rip),%rdx
mov    $0x0,%al
call   1060 <stderr3@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xbd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r14
mov    0x8(%rsi),%r12
cmp    $0x3,%edi
je     11b1 <main+0x21>
xor    %eax,%eax
call   1080 <usage@plt>
movzbl (%r12),%eax
cmp    $0x3d,%rax
ja     11cc <main+0x3c>
movabs $0x2000280000000000,%rcx
bt     %rax,%rcx
jb     11d3 <main+0x43>
xor    %eax,%eax
call   1080 <usage@plt>
lea    0x1(%r12),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   10a0 <atoi@plt>
mov    %eax,%ebx
cmp    $0xfff1,%eax
jb     1203 <main+0x73>
lea    0xe0e(%rip),%rdi
lea    0xe0f(%rip),%rdx
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <stderr3@plt>
mov    0x10(%r14),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    1233 <main+0xa3>
mov    0x10(%r14),%rsi
lea    0xdef(%rip),%rdi
lea    0xe5f(%rip),%rdx
xor    %eax,%eax
call   1060 <stderr3@plt>
lea    0x10(%rsp),%rsi
mov    $0x40,%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <read@plt>
cmp    $0x40,%eax
je     1265 <main+0xd5>
mov    0x10(%r14),%rsi
lea    0xda9(%rip),%rdi
lea    0xdc9(%rip),%rdx
xor    %eax,%eax
call   1060 <stderr3@plt>
mov    0x10(%rsp),%rcx
movzwl %cx,%eax
cmp    $0x301,%eax
je     1292 <main+0x102>
mov    0x10(%r14),%rsi
lea    0xd81(%rip),%rdi
lea    0xdad(%rip),%rdx
xor    %eax,%eax
call   1060 <stderr3@plt>
mov    0x10(%rsp),%rcx
mov    %ebx,%ebx
mov    0x30(%rsp),%rax
mov    0x40(%rsp),%r13
add    0x28(%rsp),%rax
test   $0x200000,%ecx
jne    12b2 <main+0x122>
mov    0x20(%rsp),%rcx
jmp    12b4 <main+0x124>
xor    %ecx,%ecx
sub    %rax,%r13
sub    %rcx,%r13
mov    (%r12),%dl
cmp    $0x2d,%dl
je     12cd <main+0x13d>
cmp    $0x2b,%dl
jne    12d6 <main+0x146>
add    %r13,%rbx
jmp    12d6 <main+0x146>
mov    %r13,%rdx
sub    %rbx,%rdx
mov    %rdx,%rbx
lea    (%rbx,%rax,1),%rdx
xor    %esi,%esi
cmp    $0x10001,%rdx
lea    -0x10000(%rbx,%rax,1),%rbp
ff
cmovl  %rsi,%rbp
sub    %rbp,%rdx
add    %rcx,%rdx
mov    %rdx,0x8(%rsp)
mov    $0x18,%esi
mov    %r15d,%edi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <lseek@plt>
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <write@plt>
test   %eax,%eax
jns    133c <main+0x1ac>
mov    0x10(%r14),%rsi
lea    0xd16(%rip),%rdi
lea    0xd56(%rip),%rdx
xor    %eax,%eax
call   1060 <stderr3@plt>
sub    %rbp,%rbx
mov    0x10(%r14),%rsi
lea    0xd0f(%rip),%rdi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"chmem: \00"
@.str.1 = [12 x i8] c" too large\0A\00"
@.str.2 = [19 x i8] c"chmem: can't open \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [12 x i8] c"bad header\0A\00"
@.str.5 = [17 x i8] c" not executable\0A\00"
@.str.6 = [21 x i8] c"chmem: can't modify \00"
@.str.7 = [52 x i8] c"%s: Stack+malloc area changed from %D to %D bytes.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca [8 x i64]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %6
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 3
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (...) @usage()
br label %23
23: ; preds = %21, %2
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 61
br i1 %27, label %28, label %40
28: ; preds = %23
%29 = load i8*, i8** %6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 43
br i1 %32, label %33, label %40
33: ; preds = %28
%34 = load i8*, i8** %6
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 45
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 (...) @usage()
br label %40
40: ; preds = %38, %33, %28, %23
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %42)
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = zext i32 %44 to i64
store i64 %45, i64* %10
%46 = load i32, i32* %7
%47 = icmp ugt i32 %46, 65520
br i1 %47, label %48, label %52
48: ; preds = %40
%49 = load i8*, i8** %6
%50 = getelementptr inbounds i8, i8* %49, i64 1
%51 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %50, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %48, %40
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %55, i32 2)
store i32 %56, i32* %8
%57 = load i32, i32* %8
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %52
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %59, %52
%65 = load i32, i32* %8
%66 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 0
%67 = call i32 (i32, i64*, i64, ...) bitcast (i32 (...)* @read to i32 (i32, i64*, i64, ...)*)(i32 %65, i64* %66, i64 64)
%68 = sext i32 %67 to i64
%69 = icmp ne i64 %68, 64
br i1 %69, label %70, label %75
70: ; preds = %64
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %73, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %75
75: ; preds = %70, %64
%76 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 0
%77 = load i64, i64* %76
%78 = and i64 %77, 65535
%79 = icmp ne i64 %78, 769
br i1 %79, label %80, label %85
80: ; preds = %75
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 2
%83 = load i8*, i8** %82
%84 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %83, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %85
85: ; preds = %80, %75
%86 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 0
%87 = load i64, i64* %86
%88 = and i64 %87, 2097152
%89 = icmp ne i64 %88, 0
%90 = zext i1 %89 to i64
%91 = select i1 %89, i32 1, i32 0
store i32 %91, i32* %9
%92 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 6
%93 = load i64, i64* %92
%94 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 3
%95 = load i64, i64* %94
%96 = sub nsw i64 %93, %95
%97 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 4
%98 = load i64, i64* %97
%99 = sub nsw i64 %96, %98
store i64 %99, i64* %11
%100 = load i32, i32* %9
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %107
102: ; preds = %85
%103 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 2
%104 = load i64, i64* %103
%105 = load i64, i64* %11
%106 = sub nsw i64 %105, %104
store i64 %106, i64* %11
br label %107
107: ; preds = %102, %85
%108 = load i8*, i8** %6
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp eq i32 %110, 61
br i1 %111, label %112, label %114
112: ; preds = %107
%113 = load i64, i64* %10
store i64 %113, i64* %12
br label %134
114: ; preds = %107
%115 = load i8*, i8** %6
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp eq i32 %117, 43
br i1 %118, label %119, label %123
119: ; preds = %114
%120 = load i64, i64* %11
%121 = load i64, i64* %10
%122 = add nsw i64 %120, %121
store i64 %122, i64* %12
br label %133
123: ; preds = %114
%124 = load i8*, i8** %6
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = icmp eq i32 %126, 45
br i1 %127, label %128, label %132
128: ; preds = %123
%129 = load i64, i64* %11
%130 = load i64, i64* %10
%131 = sub nsw i64 %129, %130
store i64 %131, i64* %12
br label %132
132: ; preds = %128, %123
br label %133
133: ; preds = %132, %119
br label %134
134: ; preds = %133, %112
%135 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 3
%136 = load i64, i64* %135
%137 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 4
%138 = load i64, i64* %137
%139 = add nsw i64 %136, %138
%140 = load i64, i64* %12
%141 = add nsw i64 %139, %140
store i64 %141, i64* %13
%142 = load i64, i64* %13
%143 = icmp sgt i64 %142, 65536
br i1 %143, label %144, label %147
144: ; preds = %134
%145 = load i64, i64* %13
%146 = sub nsw i64 %145, 65536
br label %148
147: ; preds = %134
br label %148
148: ; preds = %147, %144
%149 = phi i64 [ %146, %144 ], [ 0, %147 ]
store i64 %149, i64* %14
%150 = load i64, i64* %14
%151 = load i64, i64* %12
%152 = sub nsw i64 %151, %150
store i64 %152, i64* %12
%153 = load i64, i64* %14
%154 = load i64, i64* %13
%155 = sub nsw i64 %154, %153
store i64 %155, i64* %13
%156 = load i32, i32* %9
%157 = icmp eq i32 %156, 0
br i1 %157, label %158, label %163
158: ; preds = %148
%159 = getelementptr inbounds [8 x i64], [8 x i64]* %15, i64 0, i64 2
%160 = load i64, i64* %159
%161 = load i64, i64* %13
%162 = add nsw i64 %161, %160
store i64 %162, i64* %13
br label %163
163: ; preds = %158, %148
%164 = load i32, i32* %8
%165 = call i32 (i32, i64, i32, ...) bitcast (i32 (...)* @lseek to i32 (i32, i64, i32, ...)*)(i32 %164, i64 24, i32 0)
%166 = load i32, i32* %8
%167 = call i32 (i32, i64*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i64*, i32, ...)*)(i32 %166, i64* %13, i32 4)
%168 = icmp slt i32 %167, 0
br i1 %168, label %169, label %174
169: ; preds = %163
%170 = load i8**, i8*** %5
%171 = getelementptr inbounds i8*, i8** %170, i64 2
%172 = load i8*, i8** %171
%173 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %172, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %174
174: ; preds = %169, %163
%175 = load i8**, i8*** %5
%176 = getelementptr inbounds i8*, i8** %175, i64 2
%177 = load i8*, i8** %176
%178 = load i64, i64* %11
%179 = load i64, i64* %12
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i8* %177, i64 %178, i64 %179)
unreachable
}

LLVM IR (-O2):
@.str = [8 x i8] c"chmem: \00"
@.str.1 = [12 x i8] c" too large\0A\00"
@.str.2 = [19 x i8] c"chmem: can't open \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [12 x i8] c"bad header\0A\00"
@.str.5 = [17 x i8] c" not executable\0A\00"
@.str.6 = [21 x i8] c"chmem: can't modify \00"
@.str.7 = [52 x i8] c"%s: Stack+malloc area changed from %D to %D bytes.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca [8 x i64]
%5 = bitcast i64* %3 to i8*
%6 = bitcast [8 x i64]* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i32 %0, 3
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 (...) @usage()
br label %12
12: ; preds = %10, %2
%13 = load i8, i8* %8
switch i8 %13, label %14 [
i8 61, label %16
i8 43, label %16
i8 45, label %16
]
14: ; preds = %12
%15 = tail call i32 (...) @usage()
br label %16
16: ; preds = %12, %12, %12, %14
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = tail call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %17)
%19 = zext i32 %18 to i64
%20 = icmp ugt i32 %18, 65520
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = tail call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %25, i32 2)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i8*, i8** %24
%30 = tail call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %28, %23
%32 = getelementptr inbounds [8 x i64], [8 x i64]* %4, i64 0, i64 0
%33 = call i32 (i32, i64*, i64, ...) bitcast (i32 (...)* @read to i32 (i32, i64*, i64, ...)*)(i32 %26, i64* %32, i64 64)
%34 = icmp eq i32 %33, 64
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = load i8*, i8** %24
%37 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %35, %31
%39 = load i64, i64* %32
%40 = and i64 %39, 65535
%41 = icmp eq i64 %40, 769
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i8*, i8** %24
%44 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%45 = load i64, i64* %32
br label %46
46: ; preds = %42, %38
%47 = phi i64 [ %45, %42 ], [ %39, %38 ]
%48 = getelementptr inbounds [8 x i64], [8 x i64]* %4, i64 0, i64 6
%49 = load i64, i64* %48
%50 = getelementptr inbounds [8 x i64], [8 x i64]* %4, i64 0, i64 3
%51 = load i64, i64* %50
%52 = getelementptr inbounds [8 x i64], [8 x i64]* %4, i64 0, i64 4
%53 = load i64, i64* %52
%54 = add i64 %53, %51
%55 = and i64 %47, 2097152
%56 = icmp eq i64 %55, 0
%57 = getelementptr inbounds [8 x i64], [8 x i64]* %4, i64 0, i64 2
%58 = load i64, i64* %57
%59 = select i1 %56, i64 %58, i64 0
%60 = add i64 %54, %59
%61 = sub i64 %49, %60
%62 = load i8, i8* %8
switch i8 %62, label %67 [
i8 45, label %65
i8 43, label %63
]
63: ; preds = %46
%64 = add nsw i64 %61, %19
br label %67
65: ; preds = %46
%66 = sub nsw i64 %61, %19
br label %67
67: ; preds = %46, %63, %65
%68 = phi i64 [ %64, %63 ], [ %66, %65 ], [ %19, %46 ]
%69 = add nsw i64 %68, %54
%70 = icmp sgt i64 %69, 65536
%71 = add nsw i64 %69, -65536
%72 = select i1 %70, i64 %71, i64 0
%73 = sub nsw i64 %69, %72
%74 = add nsw i64 %73, %59
store i64 %74, i64* %3
%75 = call i32 (i32, i64, i32, ...) bitcast (i32 (...)* @lseek to i32 (i32, i64, i32, ...)*)(i32 %26, i64 24, i32 0)
%76 = call i32 (i32, i64*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i64*, i32, ...)*)(i32 %26, i64* %3, i32 4)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %67
%79 = load i8*, i8** %24
%80 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @stderr3 to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %81
81: ; preds = %78, %67
%82 = sub nsw i64 %68, %72
%83 = load i8*, i8** %24
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i8* %83, i64 %61, i64 %82)
unreachable
}