#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 scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ getenv(char *);
void *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int, scalar_t__);
int open(char *, int);
int /*<<< orphan*/ printf(char *, scalar_t__, ...);
scalar_t__ spec_get_base();
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ strtol(char *, char **, int);
int main(int argc, char **argv) {
  int i, fd;
  uint32_t base, *ptr;
  uint32_t uarg[3];
  void *map_base;
  char *end;
  if (argc < 2 || argc > 3) {
    fprintf(stderr, "Use: \"%s <offset> [<value>]\" (I/O is 32 bits)\n",
            argv[0]);
    exit(1);
  }
  if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) < 0) {
    fprintf(stderr, "%s: open(/dev/mem): %s\n", argv[0], strerror(errno));
    exit(1);
  }
  base = spec_get_base();
  if (base == (typeof(base))-1) {
    fprintf(stderr, "%s: spec_get_base(): %s\n", argv[0], strerror(errno));
    exit(1);
  }
  map_base = mmap(0, 1024 * 1024, PROT_READ | PROT_WRITE, MAP_SHARED, fd, base);
  if (map_base == (void *)-1) {
    fprintf(stderr, "%s: mmap(/dev/mem): %s\n", argv[0], strerror(errno));
    exit(1);
  }
  for (i = 1; i < argc; i++) {
    uarg[i] = strtol(argv[i], &end, 16);
    if (end && *end) {
      fprintf(stderr, "%s: \"%s\" is not an hex number\n", argv[0], argv[i]);
      exit(1);
    }
  }
  if (uarg[1] & 3) {
    fprintf(stderr, "%s: address \"%s\" not multiple of 4\n", argv[0], argv[1]);
    exit(1);
  }
  ptr = map_base + uarg[1];
  if (argc == 2) {
    uarg[2] = *ptr;
    if (!getenv("VERBOSE"))
      printf("%08x\n", uarg[2]);
  } else {
    *ptr = uarg[2];
  }
  if (getenv("VERBOSE")) {
    if (argc == 2)
      printf("%08x == %08x\n", uarg[1], uarg[2]);
    else
      printf("%08x := %08x\n", uarg[1], uarg[2]);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11bd <main+0x2d>
cmpl   $0x3,-0x8(%rbp)
jle    11e5 <main+0x55>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
mov    0x2ddb(%rip),%rax
or     (%rax),%esi
lea    0xe31(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1256 <main+0xc6>
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1080 <spec_get_base@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    12b3 <main+0x123>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edx
mov    0x2ced(%rip),%rax
or     (%rax),%edx
mov    0x2d1c(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x20(%rbp),%r9
xor    %edi,%edi
mov    $0x100000,%esi
call   1040 <mmap@plt>
mov    %rax,-0x48(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x48(%rbp)
jne    133e <main+0x1ae>
mov    0x2cc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x78(%rbp)
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    %rax,%rcx
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13d9 <main+0x249>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x10,%edx
call   1070 <strtol@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0x40(%rbp,%rax,8)
cmpq   $0x0,-0x50(%rbp)
je     13c6 <main+0x236>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13c6 <main+0x236>
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    13cb <main+0x23b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1345 <main+0x1b5>
mov    -0x38(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
je     141b <main+0x28b>
mov    0x2bce(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xc96(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x48(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1469 <main+0x2d9>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
lea    0xc81(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
jne    1464 <main+0x2d4>
mov    -0x30(%rbp),%rsi
lea    0xc85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1474 <main+0x2e4>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
lea    0xc49(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     14ca <main+0x33a>
cmpl   $0x2,-0x8(%rbp)
jne    14af <main+0x31f>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xc29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14c5 <main+0x335>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xc1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ca <main+0x33a>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
mov    %edi,%r14d
lea    -0x4(%r14),%eax
cmp    $0xfffffffd,%eax
ja     11d2 <main+0x42>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0xe3f(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2dff(%rip),%rax
mov    0x2df0(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe44(%rip),%rdi
call   1090 <open@plt>
test   %eax,%eax
jns    121b <main+0x8b>
mov    0x2dc5(%rip),%rax
mov    (%rax),%ebp
mov    0x0(%r13),%rbx
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe22(%rip),%rsi
jmp    12a3 <main+0x113>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <spec_get_base@plt>
cmp    $0xffffffffffffffff,%rax
jne    124e <main+0xbe>
mov    0x2d8f(%rip),%rax
mov    (%rax),%ebp
mov    0x0(%r13),%rbx
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe04(%rip),%rsi
jmp    12a3 <main+0x113>
mov    0x2da3(%rip),%rcx
mov    0x2d54(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d81(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    $0x100000,%esi
mov    %ebp,%r8d
mov    %rax,%r9
call   1040 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
jne    12bc <main+0x12c>
mov    0x2d38(%rip),%rax
mov    (%rax),%ebp
mov    0x0(%r13),%rbx
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xdc6(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    %rax,%r12
mov    %r14d,%ebp
mov    $0x1,%ebx
lea    0x8(%rsp),%r15
jmp    12d9 <main+0x149>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%rbp
je     131a <main+0x18a>
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1070 <strtol@plt>
mov    %rax,0x10(%rsp,%rbx,8)
mov    0x8(%rsp),%rax
test   %rax,%rax
je     12d0 <main+0x140>
cmpb   $0x0,(%rax)
je     12d0 <main+0x140>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
mov    0x0(%r13,%rbx,8),%rcx
lea    0xd69(%rip),%rsi
jmp    12ab <main+0x11b>
mov    0x18(%rsp),%r15
test   $0x3,%r15b
jne    1370 <main+0x1e0>
cmp    $0x2,%r14d
jne    138d <main+0x1fd>
mov    (%r12,%r15,1),%rbx
mov    %rbx,0x20(%rsp)
lea    0xd89(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1356 <main+0x1c6>
lea    0xd96(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd67(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     13bb <main+0x22b>
lea    0xd5e(%rip),%rdi
jmp    13ae <main+0x21e>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
mov    0x8(%r13),%rcx
lea    0xd18(%rip),%rsi
jmp    12ab <main+0x11b>
mov    0x20(%rsp),%rbx
mov    %rbx,(%r12,%r15,1)
lea    0xd27(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     13bb <main+0x22b>
lea    0xd2c(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [47 x i8] c"Use: \22%s <offset> [<value>]\22 (I/O is 32 bits)\0A\00"
@.str.1 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.2 = [24 x i8] c"%s: open(/dev/mem): %s\0A\00"
@errno = global i32 0
@.str.3 = [25 x i8] c"%s: spec_get_base(): %s\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.4 = [24 x i8] c"%s: mmap(/dev/mem): %s\0A\00"
@.str.5 = [31 x i8] c"%s: \22%s\22 is not an hex number\0A\00"
@.str.6 = [36 x i8] c"%s: address \22%s\22 not multiple of 4\0A\00"
@.str.7 = [8 x i8] c"VERBOSE\00"
@.str.8 = [6 x i8] c"%08x\0A\00"
@.str.9 = [14 x i8] c"%08x == %08x\0A\00"
@.str.10 = [14 x i8] c"%08x := %08x\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 i64
%9 = alloca i64*
%10 = alloca [3 x i64]
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 3
br i1 %17, label %18, label %25
18: ; preds = %15, %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15
%26 = load i32, i32* @O_RDWR
%27 = load i32, i32* @O_SYNC
%28 = or i32 %26, %27
%29 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %28)
store i32 %29, i32* %7
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %25
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %35, i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %25
%41 = call i64 (...) @spec_get_base()
store i64 %41, i64* %8
%42 = load i64, i64* %8
%43 = icmp eq i64 %42, -1
br i1 %43, label %44, label %53
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %48, i8* %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %40
%54 = load i32, i32* @PROT_READ
%55 = load i32, i32* @PROT_WRITE
%56 = or i32 %54, %55
%57 = load i32, i32* @MAP_SHARED
%58 = load i32, i32* %7
%59 = load i64, i64* %8
%60 = call i8* @mmap(i32 0, i32 1048576, i32 %56, i32 %57, i32 %58, i64 %59)
store i8* %60, i8** %11
%61 = load i8*, i8** %11
%62 = icmp eq i8* %61, inttoptr (i64 -1 to i8*)
br i1 %62, label %63, label %72
63: ; preds = %53
%64 = load i32, i32* @stderr
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 0
%67 = load i8*, i8** %66
%68 = load i32, i32* @errno
%69 = call i8* @strerror(i32 %68)
%70 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %67, i8* %69)
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %53
store i32 1, i32* %6
br label %73
73: ; preds = %107, %72
%74 = load i32, i32* %6
%75 = load i32, i32* %4
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %110
77: ; preds = %73
%78 = load i8**, i8*** %5
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = call i64 @strtol(i8* %82, i8** %12, i32 16)
%84 = load i32, i32* %6
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 %85
store i64 %83, i64* %86
%87 = load i8*, i8** %12
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %106
89: ; preds = %77
%90 = load i8*, i8** %12
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %106
94: ; preds = %89
%95 = load i32, i32* @stderr
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 0
%98 = load i8*, i8** %97
%99 = load i8**, i8*** %5
%100 = load i32, i32* %6
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %99, i64 %101
%103 = load i8*, i8** %102
%104 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %98, i8* %103)
%105 = call i32 @exit(i32 1)
unreachable
106: ; preds = %89, %77
br label %107
107: ; preds = %106
%108 = load i32, i32* %6
%109 = add nsw i32 %108, 1
store i32 %109, i32* %6
br label %73
110: ; preds = %73
%111 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 1
%112 = load i64, i64* %111
%113 = and i64 %112, 3
%114 = icmp ne i64 %113, 0
br i1 %114, label %115, label %125
115: ; preds = %110
%116 = load i32, i32* @stderr
%117 = load i8**, i8*** %5
%118 = getelementptr inbounds i8*, i8** %117, i64 0
%119 = load i8*, i8** %118
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 1
%122 = load i8*, i8** %121
%123 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %119, i8* %122)
%124 = call i32 @exit(i32 1)
unreachable
125: ; preds = %110
%126 = load i8*, i8** %11
%127 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 1
%128 = load i64, i64* %127
%129 = getelementptr i8, i8* %126, i64 %128
%130 = bitcast i8* %129 to i64*
store i64* %130, i64** %9
%131 = load i32, i32* %4
%132 = icmp eq i32 %131, 2
br i1 %132, label %133, label %144
133: ; preds = %125
%134 = load i64*, i64** %9
%135 = load i64, i64* %134
%136 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 2
store i64 %135, i64* %136
%137 = call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%138 = icmp ne i64 %137, 0
br i1 %138, label %143, label %139
139: ; preds = %133
%140 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 2
%141 = load i64, i64* %140
%142 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i64 %141)
br label %143
143: ; preds = %139, %133
br label %148
144: ; preds = %125
%145 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 2
%146 = load i64, i64* %145
%147 = load i64*, i64** %9
store i64 %146, i64* %147
br label %148
148: ; preds = %144, %143
%149 = call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%150 = icmp ne i64 %149, 0
br i1 %150, label %151, label %167
151: ; preds = %148
%152 = load i32, i32* %4
%153 = icmp eq i32 %152, 2
br i1 %153, label %154, label %160
154: ; preds = %151
%155 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 1
%156 = load i64, i64* %155
%157 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 2
%158 = load i64, i64* %157
%159 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i64 %156, i64 %158)
br label %166
160: ; preds = %151
%161 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 1
%162 = load i64, i64* %161
%163 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 0, i64 2
%164 = load i64, i64* %163
%165 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i64 %162, i64 %164)
br label %166
166: ; preds = %160, %154
br label %167
167: ; preds = %166, %148
%168 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [47 x i8] c"Use: \22%s <offset> [<value>]\22 (I/O is 32 bits)\0A\00"
@.str.1 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.2 = [24 x i8] c"%s: open(/dev/mem): %s\0A\00"
@errno = global i32 0
@.str.3 = [25 x i8] c"%s: spec_get_base(): %s\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.4 = [24 x i8] c"%s: mmap(/dev/mem): %s\0A\00"
@.str.5 = [31 x i8] c"%s: \22%s\22 is not an hex number\0A\00"
@.str.6 = [36 x i8] c"%s: address \22%s\22 not multiple of 4\0A\00"
@.str.7 = [8 x i8] c"VERBOSE\00"
@.str.8 = [6 x i8] c"%08x\0A\00"
@.str.9 = [14 x i8] c"%08x == %08x\0A\00"
@.str.10 = [14 x i8] c"%08x := %08x\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i64]
%4 = alloca i8*
%5 = bitcast [3 x i64]* %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = add i32 %0, -4
%8 = icmp ult i32 %7, -2
br i1 %8, label %9, label %14
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 ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i32, i32* @O_RDWR
%16 = load i32, i32* @O_SYNC
%17 = or i32 %16, %15
%18 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %1
%23 = load i32, i32* @errno
%24 = tail call i8* @strerror(i32 %23)
%25 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %24)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %14
%28 = tail call i64 (...) @spec_get_base()
%29 = icmp eq i64 %28, -1
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %1
%33 = load i32, i32* @errno
%34 = tail call i8* @strerror(i32 %33)
%35 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %32, i8* %34)
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %27
%38 = load i32, i32* @PROT_READ
%39 = load i32, i32* @PROT_WRITE
%40 = or i32 %39, %38
%41 = load i32, i32* @MAP_SHARED
%42 = tail call i8* @mmap(i32 0, i32 1048576, i32 %40, i32 %41, i32 %18, i64 %28)
%43 = icmp eq i8* %42, inttoptr (i64 -1 to i8*)
br i1 %43, label %46, label %44
44: ; preds = %37
%45 = zext i32 %0 to i64
br label %53
46: ; preds = %37
%47 = load i32, i32* @stderr
%48 = load i8*, i8** %1
%49 = load i32, i32* @errno
%50 = tail call i8* @strerror(i32 %49)
%51 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %48, i8* %50)
%52 = tail call i32 @exit(i32 1)
unreachable
53: ; preds = %44, %72
%54 = phi i64 [ 1, %44 ], [ %73, %72 ]
%55 = getelementptr inbounds i8*, i8** %1, i64 %54
%56 = load i8*, i8** %55
%57 = call i64 @strtol(i8* %56, i8** %4, i32 16)
%58 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 %54
store i64 %57, i64* %58
%59 = load i8*, i8** %4
%60 = icmp eq i8* %59, null
br i1 %60, label %72, label %61
61: ; preds = %53
%62 = load i8, i8* %59
%63 = icmp eq i8 %62, 0
br i1 %63, label %72, label %64
64: ; preds = %61
%65 = and i64 %54, 4294967295
%66 = getelementptr inbounds i8*, i8** %1, i64 %65
%67 = load i32, i32* @stderr
%68 = load i8*, i8** %1
%69 = load i8*, i8** %66
%70 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %68, i8* %69)
%71 = tail call i32 @exit(i32 1)
unreachable
72: ; preds = %53, %61
%73 = add nuw nsw i64 %54, 1
%74 = icmp eq i64 %73, %45
br i1 %74, label %75, label %53
75: ; preds = %72
%76 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 1
%77 = load i64, i64* %76
%78 = and i64 %77, 3
%79 = icmp eq i64 %78, 0
br i1 %79, label %87, label %80
80: ; preds = %75
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %1
%83 = getelementptr inbounds i8*, i8** %1, i64 1
%84 = load i8*, i8** %83
%85 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %82, i8* %84)
%86 = tail call i32 @exit(i32 1)
unreachable
87: ; preds = %75
%88 = getelementptr i8, i8* %42, i64 %77
%89 = bitcast i8* %88 to i64*
%90 = icmp eq i32 %0, 2
br i1 %90, label %91, label %101
91: ; preds = %87
%92 = load i64, i64* %89
%93 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 2
store i64 %92, i64* %93
%94 = tail call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %91
%97 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i64 %92)
br label %98
98: ; preds = %91, %96
%99 = tail call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %110, label %106
101: ; preds = %87
%102 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 2
%103 = load i64, i64* %102
store i64 %103, i64* %89
%104 = tail call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%105 = icmp eq i64 %104, 0
br i1 %105, label %110, label %106
106: ; preds = %101, %98
%107 = phi i64 [ %92, %98 ], [ %103, %101 ]
%108 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), %98 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), %101 ]
%109 = tail call i32 (i8*, i64, ...) @printf(i8* %108, i64 %77, i64 %107)
br label %110
110: ; preds = %106, %101, %98
%111 = tail call i32 @exit(i32 0)
unreachable
}