#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 */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
void *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int, unsigned int);
int open(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
unsigned int strtoul(char *, int /*<<< orphan*/, int);
int usage();
int r_main(int argc, char *argv[]) {
  int width = 4, set = 0, fd;
  unsigned addr, value;
  void *page;
  if (argc < 2)
    return usage();
  if (!strcmp(argv[1], "-b")) {
    width = 1;
    argc--;
    argv++;
  } else if (!strcmp(argv[1], "-s")) {
    width = 2;
    argc--;
    argv++;
  }
  if (argc < 2)
    return usage();
  addr = strtoul(argv[1], 0, 16);
  if (argc > 2) {
    set = 1;
    value = strtoul(argv[2], 0, 16);
  }
  fd = open("/dev/mem", O_RDWR | O_SYNC);
  if (fd < 0) {
    fprintf(stderr, "cannot open /dev/mem\n");
    return -1;
  }
  page = mmap(0, 8192, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & (~4095));
  if (page == MAP_FAILED) {
    fprintf(stderr, "cannot mmap region\n");
    return -1;
  }
  switch (width) {
  case 4: {
    unsigned *x = (unsigned *)(((unsigned)page) + (addr & 4095));
    if (set)
      *x = value;
    fprintf(stderr, "%08x: %08x\n", addr, *x);
    break;
  }
  case 2: {
    unsigned short *x = (unsigned short *)(((unsigned)page) + (addr & 4095));
    if (set)
      *x = value;
    fprintf(stderr, "%08x: %04x\n", addr, *x);
    break;
  }
  case 1: {
    unsigned char *x = (unsigned char *)(((unsigned)page) + (addr & 4095));
    if (set)
      *x = value;
    fprintf(stderr, "%08x: %02x\n", addr, *x);
    break;
  }
  }
  return 0;
}


x86 assembly (clang, -O0):
<r_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1196 <r_main+0x36>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1450 <r_main+0x2f0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d4 <r_main+0x74>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1212 <r_main+0xb2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe20(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    120d <r_main+0xad>
movl   $0x2,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1212 <r_main+0xb2>
cmpl   $0x2,-0x8(%rbp)
jge    122b <r_main+0xcb>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1450 <r_main+0x2f0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    126a <r_main+0x10a>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
mov    0x2d56(%rip),%rax
or     (%rax),%esi
lea    0xd83(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12b8 <r_main+0x158>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1450 <r_main+0x2f0>
mov    0x2d39(%rip),%rax
mov    (%rax),%edx
mov    0x2cf0(%rip),%rax
or     (%rax),%edx
mov    0x2d17(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
and    $0xfffff000,%r9d
xor    %edi,%edi
mov    $0x2000,%esi
call   1030 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    0x2cb3(%rip),%rcx
cmp    (%rcx),%rax
jne    1329 <r_main+0x1c9>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
lea    0xd0f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1450 <r_main+0x2f0>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x1,%eax
je     13fe <r_main+0x29e>
jmp    133d <r_main+0x1dd>
mov    -0x4c(%rbp),%eax
sub    $0x2,%eax
je     13ac <r_main+0x24c>
jmp    134e <r_main+0x1ee>
mov    -0x4c(%rbp),%eax
sub    $0x4,%eax
jne    1449 <r_main+0x2e9>
jmp    135f <r_main+0x1ff>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
and    $0xfff,%ecx
add    %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1387 <r_main+0x227>
mov    -0x24(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
lea    0xc99(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1449 <r_main+0x2e9>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
and    $0xfff,%ecx
add    %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     13d8 <r_main+0x278>
mov    -0x24(%rbp),%eax
mov    %ax,%cx
mov    -0x40(%rbp),%rax
mov    %cx,(%rax)
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0x40(%rbp),%rax
movzwl (%rax),%ecx
lea    0xc53(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1449 <r_main+0x2e9>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
and    $0xfff,%ecx
add    %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1428 <r_main+0x2c8>
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %cl,(%rax)
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0x48(%rbp),%rax
movzbl (%rax),%ecx
lea    0xc0f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    11be <r_main+0x5e>
mov    %rsi,%rbp
mov    %edi,%r12d
mov    0x8(%rsi),%rbx
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ae <r_main+0x4e>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x4,%r13d
test   %eax,%eax
jne    11db <r_main+0x7b>
mov    $0x2,%r13d
jmp    11b4 <r_main+0x54>
mov    $0x1,%r13d
add    $0xffffffff,%r12d
cmp    $0x2,%r12d
jae    11d3 <r_main+0x73>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <usage@plt>
mov    0x10(%rbp),%rbx
add    $0x8,%rbp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,%r15d
cmp    $0x2,%r12d
je     1206 <r_main+0xa6>
mov    0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,%r14d
mov    0x2dcb(%rip),%rax
mov    0x2dbc(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xde7(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     1296 <r_main+0x136>
mov    0x2dc9(%rip),%rcx
mov    0x2d82(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2da7(%rip),%rcx
mov    (%rcx),%ecx
mov    %r15d,%r9d
and    $0xfffff000,%r9d
xor    %ebp,%ebp
xor    %edi,%edi
mov    $0x2000,%esi
mov    %eax,%r8d
call   1030 <mmap@plt>
mov    0x2d4b(%rip),%rcx
cmp    (%rcx),%rax
je     12a8 <r_main+0x148>
cmp    $0x1,%r13d
je     12c9 <r_main+0x169>
cmp    $0x2,%r13d
je     12df <r_main+0x17f>
cmp    $0x4,%r13d
jne    1350 <r_main+0x1f0>
mov    %r15d,%ecx
and    $0xfff,%ecx
add    %eax,%ecx
cmp    $0x2,%r12d
jne    12f6 <r_main+0x196>
mov    (%rcx),%r14d
jmp    12f9 <r_main+0x199>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
lea    0xd69(%rip),%rsi
jmp    12b8 <r_main+0x158>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1350 <r_main+0x1f0>
mov    %r15d,%ecx
and    $0xfff,%ecx
add    %eax,%ecx
cmp    $0x2,%r12d
jne    1313 <r_main+0x1b3>
mov    (%rcx),%r14b
jmp    1316 <r_main+0x1b6>
mov    %r15d,%ecx
and    $0xfff,%ecx
add    %eax,%ecx
cmp    $0x2,%r12d
jne    132c <r_main+0x1cc>
movzwl (%rcx),%r14d
jmp    1330 <r_main+0x1d0>
mov    %r14d,(%rcx)
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
lea    0xd30(%rip),%rsi
xor    %ebp,%ebp
mov    %r15d,%edx
mov    %r14d,%ecx
jmp    1349 <r_main+0x1e9>
mov    %r14b,(%rcx)
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
movzbl %r14b,%ecx
lea    0xd27(%rip),%rsi
jmp    1344 <r_main+0x1e4>
mov    %r14w,(%rcx)
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
movzwl %r14w,%ecx
lea    0xd01(%rip),%rsi
xor    %ebp,%ebp
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-b\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@stderr = global i32 0
@.str.3 = [22 x i8] c"cannot open /dev/mem\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [20 x i8] c"cannot mmap region\0A\00"
@.str.5 = [12 x i8] c"%08x: %08x\0A\00"
@.str.6 = [12 x i8] c"%08x: %04x\0A\00"
@.str.7 = [12 x i8] c"%08x: %02x\0A\00"
define i32 @r_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 i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i16*
%14 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 4, i32* %6
store i32 0, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (...) @usage()
store i32 %18, i32* %3
br label %148
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %19
store i32 1, i32* %6
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
store i32 %27, i32* %4
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i32 1
store i8** %29, i8*** %5
br label %42
30: ; preds = %19
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %30
store i32 2, i32* %6
%37 = load i32, i32* %4
%38 = add nsw i32 %37, -1
store i32 %38, i32* %4
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i32 1
store i8** %40, i8*** %5
br label %41
41: ; preds = %36, %30
br label %42
42: ; preds = %41, %25
%43 = load i32, i32* %4
%44 = icmp slt i32 %43, 2
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 (...) @usage()
store i32 %46, i32* %3
br label %148
47: ; preds = %42
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 @strtoul(i8* %50, i32 0, i32 16)
store i32 %51, i32* %9
%52 = load i32, i32* %4
%53 = icmp sgt i32 %52, 2
br i1 %53, label %54, label %59
54: ; preds = %47
store i32 1, i32* %7
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i32 @strtoul(i8* %57, i32 0, i32 16)
store i32 %58, i32* %10
br label %59
59: ; preds = %54, %47
%60 = load i32, i32* @O_RDWR
%61 = load i32, i32* @O_SYNC
%62 = or i32 %60, %61
%63 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %62)
store i32 %63, i32* %8
%64 = load i32, i32* %8
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %148
69: ; preds = %59
%70 = load i32, i32* @PROT_READ
%71 = load i32, i32* @PROT_WRITE
%72 = or i32 %70, %71
%73 = load i32, i32* @MAP_SHARED
%74 = load i32, i32* %8
%75 = load i32, i32* %9
%76 = and i32 %75, -4096
%77 = call i8* @mmap(i32 0, i32 8192, i32 %72, i32 %73, i32 %74, i32 %76)
store i8* %77, i8** %11
%78 = load i8*, i8** %11
%79 = load i8*, i8** @MAP_FAILED
%80 = icmp eq i8* %78, %79
br i1 %80, label %81, label %84
81: ; preds = %69
%82 = load i32, i32* @stderr
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %148
84: ; preds = %69
%85 = load i32, i32* %6
switch i32 %85, label %147 [
i32 4, label %86
i32 2, label %105
i32 1, label %126
]
86: ; preds = %84
%87 = load i8*, i8** %11
%88 = ptrtoint i8* %87 to i32
%89 = load i32, i32* %9
%90 = and i32 %89, 4095
%91 = add i32 %88, %90
%92 = zext i32 %91 to i64
%93 = inttoptr i64 %92 to i32*
store i32* %93, i32** %12
%94 = load i32, i32* %7
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %86
%97 = load i32, i32* %10
%98 = load i32*, i32** %12
store i32 %97, i32* %98
br label %99
99: ; preds = %96, %86
%100 = load i32, i32* @stderr
%101 = load i32, i32* %9
%102 = load i32*, i32** %12
%103 = load i32, i32* %102
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %101, i32 %103)
br label %147
105: ; preds = %84
%106 = load i8*, i8** %11
%107 = ptrtoint i8* %106 to i32
%108 = load i32, i32* %9
%109 = and i32 %108, 4095
%110 = add i32 %107, %109
%111 = zext i32 %110 to i64
%112 = inttoptr i64 %111 to i16*
store i16* %112, i16** %13
%113 = load i32, i32* %7
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %119
115: ; preds = %105
%116 = load i32, i32* %10
%117 = trunc i32 %116 to i16
%118 = load i16*, i16** %13
store i16 %117, i16* %118
br label %119
119: ; preds = %115, %105
%120 = load i32, i32* @stderr
%121 = load i32, i32* %9
%122 = load i16*, i16** %13
%123 = load i16, i16* %122
%124 = zext i16 %123 to i32
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %121, i32 %124)
br label %147
126: ; preds = %84
%127 = load i8*, i8** %11
%128 = ptrtoint i8* %127 to i32
%129 = load i32, i32* %9
%130 = and i32 %129, 4095
%131 = add i32 %128, %130
%132 = zext i32 %131 to i64
%133 = inttoptr i64 %132 to i8*
store i8* %133, i8** %14
%134 = load i32, i32* %7
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %140
136: ; preds = %126
%137 = load i32, i32* %10
%138 = trunc i32 %137 to i8
%139 = load i8*, i8** %14
store i8 %138, i8* %139
br label %140
140: ; preds = %136, %126
%141 = load i32, i32* @stderr
%142 = load i32, i32* %9
%143 = load i8*, i8** %14
%144 = load i8, i8* %143
%145 = zext i8 %144 to i32
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %142, i32 %145)
br label %147
147: ; preds = %84, %140, %119, %99
store i32 0, i32* %3
br label %148
148: ; preds = %147, %81, %66, %45, %17
%149 = load i32, i32* %3
ret i32 %149
}

LLVM IR (-O2):
@.str = [3 x i8] c"-b\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@stderr = global i32 0
@.str.3 = [22 x i8] c"cannot open /dev/mem\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.4 = [20 x i8] c"cannot mmap region\0A\00"
@.str.5 = [12 x i8] c"%08x: %08x\0A\00"
@.str.6 = [12 x i8] c"%08x: %04x\0A\00"
@.str.7 = [12 x i8] c"%08x: %02x\0A\00"
define i32 @r_main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %103
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %11, %6
%15 = phi i32 [ 1, %6 ], [ 2, %11 ]
%16 = add nsw i32 %0, -1
%17 = icmp ult i32 %16, 2
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
br label %23
21: ; preds = %14
%22 = tail call i32 (...) @usage()
br label %103
23: ; preds = %18, %11
%24 = phi i8* [ %20, %18 ], [ %8, %11 ]
%25 = phi i32 [ %16, %18 ], [ %0, %11 ]
%26 = phi i8** [ %7, %18 ], [ %1, %11 ]
%27 = phi i32 [ %15, %18 ], [ 4, %11 ]
%28 = tail call i32 @strtoul(i8* %24, i32 0, i32 16)
%29 = icmp eq i32 %25, 2
br i1 %29, label %34, label %30
30: ; preds = %23
%31 = getelementptr inbounds i8*, i8** %26, i64 2
%32 = load i8*, i8** %31
%33 = tail call i32 @strtoul(i8* %32, i32 0, i32 16)
br label %34
34: ; preds = %30, %23
%35 = phi i32 [ %33, %30 ], [ undef, %23 ]
%36 = load i32, i32* @O_RDWR
%37 = load i32, i32* @O_SYNC
%38 = or i32 %37, %36
%39 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %34
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %103
44: ; preds = %34
%45 = load i32, i32* @PROT_READ
%46 = load i32, i32* @PROT_WRITE
%47 = or i32 %46, %45
%48 = load i32, i32* @MAP_SHARED
%49 = and i32 %28, -4096
%50 = tail call i8* @mmap(i32 0, i32 8192, i32 %47, i32 %48, i32 %39, i32 %49)
%51 = load i8*, i8** @MAP_FAILED
%52 = icmp eq i8* %50, %51
br i1 %52, label %53, label %56
53: ; preds = %44
%54 = load i32, i32* @stderr
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %103
56: ; preds = %44
switch i32 %27, label %103 [
i32 4, label %57
i32 2, label %71
i32 1, label %87
]
57: ; preds = %56
%58 = ptrtoint i8* %50 to i64
%59 = trunc i64 %58 to i32
%60 = and i32 %28, 4095
%61 = add i32 %60, %59
%62 = zext i32 %61 to i64
%63 = inttoptr i64 %62 to i32*
br i1 %29, label %64, label %66
64: ; preds = %57
%65 = load i32, i32* %63
br label %67
66: ; preds = %57
store i32 %35, i32* %63
br label %67
67: ; preds = %64, %66
%68 = phi i32 [ %65, %64 ], [ %35, %66 ]
%69 = load i32, i32* @stderr
%70 = tail call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %28, i32 %68)
br label %103
71: ; preds = %56
%72 = ptrtoint i8* %50 to i64
%73 = trunc i64 %72 to i32
%74 = and i32 %28, 4095
%75 = add i32 %74, %73
%76 = zext i32 %75 to i64
%77 = inttoptr i64 %76 to i16*
br i1 %29, label %78, label %80
78: ; preds = %71
%79 = load i16, i16* %77
br label %82
80: ; preds = %71
%81 = trunc i32 %35 to i16
store i16 %81, i16* %77
br label %82
82: ; preds = %78, %80
%83 = phi i16 [ %79, %78 ], [ %81, %80 ]
%84 = load i32, i32* @stderr
%85 = zext i16 %83 to i32
%86 = tail call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %28, i32 %85)
br label %103
87: ; preds = %56
%88 = ptrtoint i8* %50 to i64
%89 = trunc i64 %88 to i32
%90 = and i32 %28, 4095
%91 = add i32 %90, %89
%92 = zext i32 %91 to i64
%93 = inttoptr i64 %92 to i8*
br i1 %29, label %94, label %96
94: ; preds = %87
%95 = load i8, i8* %93
br label %98
96: ; preds = %87
%97 = trunc i32 %35 to i8
store i8 %97, i8* %93
br label %98
98: ; preds = %94, %96
%99 = phi i8 [ %95, %94 ], [ %97, %96 ]
%100 = load i32, i32* @stderr
%101 = zext i8 %99 to i32
%102 = tail call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %28, i32 %101)
br label %103
103: ; preds = %67, %82, %98, %56, %53, %41, %21, %4
%104 = phi i32 [ %5, %4 ], [ %22, %21 ], [ -1, %41 ], [ -1, %53 ], [ 0, %56 ], [ 0, %98 ], [ 0, %82 ], [ 0, %67 ]
ret i32 %104
}