#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 ssize_t;
typedef void *off_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int O_CREAT;
int O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
void *atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ isprint(unsigned char);
int lseek(int, void *, int /*<<< orphan*/);
char *malloc(size_t);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, size_t);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int fd, i, j;
  size_t len;
  ssize_t num_read, num_written;
  char *buf;
  off_t offset;
  if (argc < 3 || strncmp(argv[1], "--help", 6) == 0) {
    fprintf(stderr, "Usage: %s <filename> [r|R|w!s]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if ((fd = open(argv[1], O_RDWR | O_CREAT,
                 (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
                  S_IWOTH))) == -1) {
    fprintf(stderr, "Err. open(%s): %s\n", argv[1], strerror(errno));
    exit(EXIT_FAILURE);
  }
  for (i = 2; i < argc; i++) {
    switch (argv[i][0]) {
    case 'r':
    case 'R':
      len = atoi(argv[1]);
      if ((buf = malloc(len)) == NULL) {
        fprintf(stderr, "Err. malloc()\n");
        exit(EXIT_FAILURE);
      }
      if ((num_read = read(fd, buf, len)) == -1) {
        fprintf(stderr, "Err. read()\n");
        exit(EXIT_FAILURE);
      }
      if (num_read == 0) {
        printf("%s: EOF\n", argv[i]);
      } else {
        printf("%s: ", argv[i]);
        for (j = 0; j < num_read; j++) {
          if (argv[i][0] == 'r')
            printf("%c", isprint((unsigned char)buf[j]) ? buf[j] : '?');
          else
            printf("%02x ", (unsigned int)buf[j]);
        }
        printf("\n");
      }
      free(buf);
      break;
    case 'w':
      num_written = write(fd, &argv[i][1], strlen(&argv[i][1]));
      if (num_written == -1) {
        fprintf(stderr, "Err. write()\n");
        exit(EXIT_FAILURE);
      }
      printf("%s: wrote %ld bytes\n", argv[i], (long)num_written);
      break;
    case 's':
      offset = atoi(argv[1]);
      if (lseek(fd, offset, SEEK_SET) == -1) {
        fprintf(stderr, "Err. lseek()\n");
        exit(EXIT_FAILURE);
      }
      printf("%s: seek succeeded\n", argv[i]);
      break;
    default:
      printf("aio\n");
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1223 <main+0x43>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe89(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    124f <main+0x6f>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d82(%rip),%rax
mov    (%rax),%esi
mov    0x2d91(%rip),%rax
or     (%rax),%esi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
mov    0x2d57(%rip),%rax
or     (%rax),%edx
mov    0x2d26(%rip),%rax
or     (%rax),%edx
mov    0x2d4d(%rip),%rax
or     (%rax),%edx
mov    0x2d0c(%rip),%rax
or     (%rax),%edx
mov    0x2cdb(%rip),%rax
or     (%rax),%edx
call   10d0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12fc <main+0x11c>
mov    0x2d09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1600 <main+0x420>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
add    $0xffffffae,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x25,%eax
ja     15df <main+0x3ff>
mov    -0x58(%rbp),%rax
lea    0xcc5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1391 <main+0x1b1>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
lea    0xd56(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c0e(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1090 <read@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    13d2 <main+0x1f2>
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2bcd(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    13fb <main+0x21b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xcff(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14cc <main+0x2ec>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xce9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    14be <main+0x2de>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x72,%eax
jne    1491 <main+0x2b1>
mov    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   10c0 <isprint@plt>
cmp    $0x0,%eax
je     146e <main+0x28e>
mov    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x5c(%rbp)
jmp    147b <main+0x29b>
mov    $0x3f,%eax
mov    %eax,-0x5c(%rbp)
jmp    147b <main+0x29b>
mov    -0x5c(%rbp),%esi
lea    0xc77(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14ab <main+0x2cb>
mov    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14b0 <main+0x2d0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    141c <main+0x23c>
lea    0xc1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    15ed <main+0x40d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x1,%rdi
call   1060 <strlen@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    1549 <main+0x369>
mov    0x2a95(%rip),%rax
mov    (%rax),%edi
lea    0xbd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2a56(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x30(%rbp),%rdx
lea    0xbb3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15ed <main+0x40d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    0x2a25(%rip),%rax
mov    (%rax),%edx
call   1080 <lseek@plt>
cmp    $0xffffffff,%eax
jne    15c0 <main+0x3e0>
mov    0x2a1e(%rip),%rax
mov    (%rax),%edi
lea    0xb7d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x29df(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xb63(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15ed <main+0x40d>
lea    0xb64(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15f2 <main+0x412>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1303 <main+0x123>
mov    0x2981(%rip),%rax
mov    (%rax),%eax
add    $0x70,%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    $0x3,%edi
jl     14db <main+0x2db>
mov    %edi,%ebp
mov    0x8(%rbx),%rdi
lea    0xe71(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     14db <main+0x2db>
mov    0x2d9f(%rip),%rax
mov    0x2db0(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d3d(%rip),%rax
mov    0x2d76(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d43(%rip),%rax
or     (%rax),%edx
mov    0x2d6a(%rip),%rax
or     (%rax),%edx
mov    0x2d29(%rip),%rax
or     (%rax),%edx
mov    0x8(%rbx),%rdi
mov    0x2cf4(%rip),%rax
or     (%rax),%edx
call   10f0 <open@plt>
cmp    $0xffffffff,%eax
je     14f7 <main+0x2f7>
mov    %eax,%r14d
mov    %ebp,%r15d
mov    $0x2,%r13d
lea    0xd59(%rip),%r12
mov    %eax,0xc(%rsp)
mov    %r15,0x10(%rsp)
jmp    12d9 <main+0xd9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe80(%rip),%rdi
call   1060 <puts@plt>
add    $0x1,%r13
cmp    %r15,%r13
je     1468 <main+0x268>
mov    (%rbx,%r13,8),%rbp
movsbl 0x0(%rbp),%eax
add    $0xffffffae,%eax
cmp    $0x25,%eax
ja     12c0 <main+0xc0>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x8(%rbx),%rdi
call   1100 <atoi@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   10d0 <malloc@plt>
test   %rax,%rax
je     1480 <main+0x280>
mov    %rax,%r12
mov    %r14d,%edi
mov    %rax,%rsi
mov    %rbp,%rdx
call   10b0 <read@plt>
test   %eax,%eax
je     142c <main+0x22c>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     1492 <main+0x292>
mov    (%rbx,%r13,8),%rsi
lea    0xdb9(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
test   %ebp,%ebp
jle    1440 <main+0x240>
mov    %ebp,%r15d
xor    %r14d,%r14d
jmp    137d <main+0x17d>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xd95(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r15
je     1440 <main+0x240>
mov    (%rbx,%r13,8),%rax
cmpb   $0x72,(%rax)
movsbl (%r12,%r14,1),%ebp
jne    1360 <main+0x160>
movzbl %bpl,%edi
call   10e0 <isprint@plt>
test   %eax,%eax
mov    $0x3f,%eax
cmove  %eax,%ebp
mov    %ebp,%edi
call   1040 <putchar@plt>
jmp    1370 <main+0x170>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rbx),%rdi
call   1100 <atoi@plt>
mov    0x2bf0(%rip),%rcx
mov    (%rcx),%edx
mov    %r14d,%edi
mov    %rax,%rsi
call   10a0 <lseek@plt>
cmp    $0xffffffff,%eax
je     14a4 <main+0x2a4>
mov    (%rbx,%r13,8),%rsi
lea    0xd52(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    12cc <main+0xcc>
nopl   (%rax)
add    $0x1,%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1070 <write@plt>
cmp    $0xffffffff,%eax
je     14b6 <main+0x2b6>
mov    (%rbx,%r13,8),%rsi
movslq %eax,%rdx
lea    0xcf0(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    12cc <main+0xcc>
mov    (%rbx,%r13,8),%rsi
lea    0xcb7(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1454 <main+0x254>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0xc(%rsp),%r14d
mov    0x10(%rsp),%r15
mov    %r12,%rdi
call   1030 <free@plt>
lea    0xb9d(%rip),%r12
jmp    12cc <main+0xcc>
mov    0x2b19(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
lea    0xc42(%rip),%rsi
jmp    14c6 <main+0x2c6>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
lea    0xc3f(%rip),%rsi
jmp    14c6 <main+0x2c6>
mov    0x2b15(%rip),%rax
mov    (%rax),%edi
lea    0xc71(%rip),%rsi
jmp    14c6 <main+0x2c6>
mov    0x2b03(%rip),%rax
mov    (%rax),%edi
lea    0xc3c(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x2ac4(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    0x2ade(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xbb1(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14cd <main+0x2cd>
mov    0x2ac2(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    0x2aad(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xba6(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14cd <main+0x2cd>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Usage: %s <filename> [r|R|w!s]\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@.str.2 = [19 x i8] c"Err. open(%s): %s\0A\00"
@errno = global i32 0
@.str.3 = [15 x i8] c"Err. malloc()\0A\00"
@.str.4 = [13 x i8] c"Err. read()\0A\00"
@.str.5 = [9 x i8] c"%s: EOF\0A\00"
@.str.6 = [5 x i8] c"%s: \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [6 x i8] c"%02x \00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [14 x i8] c"Err. write()\0A\00"
@.str.11 = [21 x i8] c"%s: wrote %ld bytes\0A\00"
@SEEK_SET = global i32 0
@.str.12 = [14 x i8] c"Err. lseek()\0A\00"
@.str.13 = [20 x i8] c"%s: seek succeeded\0A\00"
@.str.14 = [5 x i8] c"aio\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %22, label %16
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strncmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %16, %2
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %16
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i32, i32* @O_RDWR
%35 = load i32, i32* @O_CREAT
%36 = or i32 %34, %35
%37 = load i32, i32* @S_IRUSR
%38 = load i32, i32* @S_IWUSR
%39 = or i32 %37, %38
%40 = load i32, i32* @S_IRGRP
%41 = or i32 %39, %40
%42 = load i32, i32* @S_IWGRP
%43 = or i32 %41, %42
%44 = load i32, i32* @S_IROTH
%45 = or i32 %43, %44
%46 = load i32, i32* @S_IWOTH
%47 = or i32 %45, %46
%48 = call i32 @open(i8* %33, i32 %36, i32 %47)
store i32 %48, i32* %6
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %60
50: ; preds = %30
%51 = load i32, i32* @stderr
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = load i32, i32* @errno
%56 = call i8* @strerror(i32 %55)
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %54, i8* %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %30
store i32 2, i32* %7
br label %61
61: ; preds = %223, %60
%62 = load i32, i32* %7
%63 = load i32, i32* %4
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %226
65: ; preds = %61
%66 = load i8**, i8*** %5
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = getelementptr inbounds i8, i8* %70, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
switch i32 %73, label %220 [
i32 114, label %74
i32 82, label %74
i32 119, label %166
i32 115, label %198
]
74: ; preds = %65, %65
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i8* @atoi(i8* %77)
%79 = ptrtoint i8* %78 to i64
store i64 %79, i64* %9
%80 = load i64, i64* %9
%81 = call i8* @malloc(i64 %80)
store i8* %81, i8** %12
%82 = icmp eq i8* %81, null
br i1 %82, label %83, label %88
83: ; preds = %74
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %74
%89 = load i32, i32* %6
%90 = load i8*, i8** %12
%91 = load i64, i64* %9
%92 = call i32 @read(i32 %89, i8* %90, i64 %91)
store i32 %92, i32* %10
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %99
94: ; preds = %88
%95 = load i32, i32* @stderr
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %88
%100 = load i32, i32* %10
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %109
102: ; preds = %99
%103 = load i8**, i8*** %5
%104 = load i32, i32* %7
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8*, i8** %103, i64 %105
%107 = load i8*, i8** %106
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %107)
br label %163
109: ; preds = %99
%110 = load i8**, i8*** %5
%111 = load i32, i32* %7
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8*, i8** %110, i64 %112
%114 = load i8*, i8** %113
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %114)
store i32 0, i32* %8
br label %116
116: ; preds = %158, %109
%117 = load i32, i32* %8
%118 = load i32, i32* %10
%119 = icmp slt i32 %117, %118
br i1 %119, label %120, label %161
120: ; preds = %116
%121 = load i8**, i8*** %5
%122 = load i32, i32* %7
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8*, i8** %121, i64 %123
%125 = load i8*, i8** %124
%126 = getelementptr inbounds i8, i8* %125, i64 0
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp eq i32 %128, 114
br i1 %129, label %130, label %149
130: ; preds = %120
%131 = load i8*, i8** %12
%132 = load i32, i32* %8
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i8, i8* %131, i64 %133
%135 = load i8, i8* %134
%136 = call i32 @isprint(i8 zeroext %135)
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %145
138: ; preds = %130
%139 = load i8*, i8** %12
%140 = load i32, i32* %8
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %139, i64 %141
%143 = load i8, i8* %142
%144 = sext i8 %143 to i32
br label %146
145: ; preds = %130
br label %146
146: ; preds = %145, %138
%147 = phi i32 [ %144, %138 ], [ 63, %145 ]
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %147)
br label %157
149: ; preds = %120
%150 = load i8*, i8** %12
%151 = load i32, i32* %8
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8, i8* %150, i64 %152
%154 = load i8, i8* %153
%155 = sext i8 %154 to i32
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %155)
br label %157
157: ; preds = %149, %146
br label %158
158: ; preds = %157
%159 = load i32, i32* %8
%160 = add nsw i32 %159, 1
store i32 %160, i32* %8
br label %116
161: ; preds = %116
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %163
163: ; preds = %161, %102
%164 = load i8*, i8** %12
%165 = call i32 @free(i8* %164)
br label %222
166: ; preds = %65
%167 = load i32, i32* %6
%168 = load i8**, i8*** %5
%169 = load i32, i32* %7
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i8*, i8** %168, i64 %170
%172 = load i8*, i8** %171
%173 = getelementptr inbounds i8, i8* %172, i64 1
%174 = load i8**, i8*** %5
%175 = load i32, i32* %7
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds i8*, i8** %174, i64 %176
%178 = load i8*, i8** %177
%179 = getelementptr inbounds i8, i8* %178, i64 1
%180 = call i32 @strlen(i8* %179)
%181 = call i32 @write(i32 %167, i8* %173, i32 %180)
store i32 %181, i32* %11
%182 = load i32, i32* %11
%183 = icmp eq i32 %182, -1
br i1 %183, label %184, label %189
184: ; preds = %166
%185 = load i32, i32* @stderr
%186 = call i32 (i32, i8*, ...) @fprintf(i32 %185, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%187 = load i32, i32* @EXIT_FAILURE
%188 = call i32 @exit(i32 %187)
unreachable
189: ; preds = %166
%190 = load i8**, i8*** %5
%191 = load i32, i32* %7
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds i8*, i8** %190, i64 %192
%194 = load i8*, i8** %193
%195 = load i32, i32* %11
%196 = sext i32 %195 to i64
%197 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %194, i64 %196)
br label %222
198: ; preds = %65
%199 = load i8**, i8*** %5
%200 = getelementptr inbounds i8*, i8** %199, i64 1
%201 = load i8*, i8** %200
%202 = call i8* @atoi(i8* %201)
store i8* %202, i8** %13
%203 = load i32, i32* %6
%204 = load i8*, i8** %13
%205 = load i32, i32* @SEEK_SET
%206 = call i32 @lseek(i32 %203, i8* %204, i32 %205)
%207 = icmp eq i32 %206, -1
br i1 %207, label %208, label %213
208: ; preds = %198
%209 = load i32, i32* @stderr
%210 = call i32 (i32, i8*, ...) @fprintf(i32 %209, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
%211 = load i32, i32* @EXIT_FAILURE
%212 = call i32 @exit(i32 %211)
unreachable
213: ; preds = %198
%214 = load i8**, i8*** %5
%215 = load i32, i32* %7
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds i8*, i8** %214, i64 %216
%218 = load i8*, i8** %217
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %218)
br label %222
220: ; preds = %65
%221 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %222
222: ; preds = %220, %213, %189, %163
br label %223
223: ; preds = %222
%224 = load i32, i32* %7
%225 = add nsw i32 %224, 1
store i32 %225, i32* %7
br label %61
226: ; preds = %61
%227 = load i32, i32* @EXIT_SUCCESS
ret i32 %227
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Usage: %s <filename> [r|R|w!s]\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@.str.2 = [19 x i8] c"Err. open(%s): %s\0A\00"
@errno = global i32 0
@.str.3 = [15 x i8] c"Err. malloc()\0A\00"
@.str.4 = [13 x i8] c"Err. read()\0A\00"
@.str.5 = [9 x i8] c"%s: EOF\0A\00"
@.str.6 = [5 x i8] c"%s: \00"
@.str.8 = [6 x i8] c"%02x \00"
@.str.10 = [14 x i8] c"Err. write()\0A\00"
@.str.11 = [21 x i8] c"%s: wrote %ld bytes\0A\00"
@SEEK_SET = global i32 0
@.str.12 = [14 x i8] c"Err. lseek()\0A\00"
@.str.13 = [20 x i8] c"%s: seek succeeded\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [4 x i8] c"aio\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %4, %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %4
%16 = load i8*, i8** %5
%17 = load i32, i32* @O_RDWR
%18 = load i32, i32* @O_CREAT
%19 = or i32 %18, %17
%20 = load i32, i32* @S_IRUSR
%21 = load i32, i32* @S_IWUSR
%22 = or i32 %21, %20
%23 = load i32, i32* @S_IRGRP
%24 = or i32 %22, %23
%25 = load i32, i32* @S_IWGRP
%26 = or i32 %24, %25
%27 = load i32, i32* @S_IROTH
%28 = or i32 %26, %27
%29 = load i32, i32* @S_IWOTH
%30 = or i32 %28, %29
%31 = tail call i32 @open(i8* %16, i32 %19, i32 %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %35, label %33
33: ; preds = %15
%34 = zext i32 %0 to i64
br label %43
35: ; preds = %15
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %5
%38 = load i32, i32* @errno
%39 = tail call i8* @strerror(i32 %38)
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %37, i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = tail call i32 @exit(i32 %41)
unreachable
43: ; preds = %33, %129
%44 = phi i64 [ 2, %33 ], [ %130, %129 ]
%45 = getelementptr inbounds i8*, i8** %1, i64 %44
%46 = load i8*, i8** %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
switch i32 %48, label %127 [
i32 114, label %49
i32 82, label %49
i32 119, label %99
i32 115, label %113
]
49: ; preds = %43, %43
%50 = load i8*, i8** %5
%51 = tail call i8* @atoi(i8* %50)
%52 = ptrtoint i8* %51 to i64
%53 = tail call i8* @malloc(i64 %52)
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %60
55: ; preds = %49
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = tail call i32 @exit(i32 %58)
unreachable
60: ; preds = %49
%61 = tail call i32 @read(i32 %31, i8* %53, i64 %52)
switch i32 %61, label %70 [
i32 -1, label %62
i32 0, label %67
]
62: ; preds = %60
%63 = load i32, i32* @stderr
%64 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = tail call i32 @exit(i32 %65)
unreachable
67: ; preds = %60
%68 = load i8*, i8** %45
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %68)
br label %97
70: ; preds = %60
%71 = load i8*, i8** %45
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %71)
%73 = icmp sgt i32 %61, 0
br i1 %73, label %74, label %95
74: ; preds = %70
%75 = zext i32 %61 to i64
br label %76
76: ; preds = %74, %92
%77 = phi i64 [ 0, %74 ], [ %93, %92 ]
%78 = load i8*, i8** %45
%79 = load i8, i8* %78
%80 = icmp eq i8 %79, 114
%81 = getelementptr inbounds i8, i8* %53, i64 %77
%82 = load i8, i8* %81
br i1 %80, label %83, label %89
83: ; preds = %76
%84 = tail call i32 @isprint(i8 zeroext %82)
%85 = icmp eq i32 %84, 0
%86 = sext i8 %82 to i32
%87 = select i1 %85, i32 63, i32 %86
%88 = tail call i32 @putchar(i32 %87)
br label %92
89: ; preds = %76
%90 = sext i8 %82 to i32
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %83, %89
%93 = add nuw nsw i64 %77, 1
%94 = icmp eq i64 %93, %75
br i1 %94, label %95, label %76
95: ; preds = %92, %70
%96 = tail call i32 @putchar(i32 10)
br label %97
97: ; preds = %95, %67
%98 = tail call i32 @free(i8* %53)
br label %129
99: ; preds = %43
%100 = getelementptr inbounds i8, i8* %46, i64 1
%101 = tail call i32 @strlen(i8* %100)
%102 = tail call i32 @write(i32 %31, i8* %100, i32 %101)
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %109
104: ; preds = %99
%105 = load i32, i32* @stderr
%106 = tail call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%107 = load i32, i32* @EXIT_FAILURE
%108 = tail call i32 @exit(i32 %107)
unreachable
109: ; preds = %99
%110 = load i8*, i8** %45
%111 = sext i32 %102 to i64
%112 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %110, i64 %111)
br label %129
113: ; preds = %43
%114 = load i8*, i8** %5
%115 = tail call i8* @atoi(i8* %114)
%116 = load i32, i32* @SEEK_SET
%117 = tail call i32 @lseek(i32 %31, i8* %115, i32 %116)
%118 = icmp eq i32 %117, -1
br i1 %118, label %119, label %124
119: ; preds = %113
%120 = load i32, i32* @stderr
%121 = tail call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
%122 = load i32, i32* @EXIT_FAILURE
%123 = tail call i32 @exit(i32 %122)
unreachable
124: ; preds = %113
%125 = load i8*, i8** %45
%126 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %125)
br label %129
127: ; preds = %43
%128 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %129
129: ; preds = %97, %109, %124, %127
%130 = add nuw nsw i64 %44, 1
%131 = icmp eq i64 %130, %34
br i1 %131, label %132, label %43
132: ; preds = %129
%133 = load i32, i32* @EXIT_SUCCESS
ret i32 %133
}