#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 uint32_t;
typedef int uint16_t;
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _SC_PAGESIZE;
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ munmap(void volatile *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int);
int sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int main() {
  int fd, i;
  uint32_t start, offset;
  int16_t value[2];
  volatile uint32_t *slcr, *axi_hp0;
  volatile void *cfg, *sts, *ram;
  if ((fd = open("/dev/mem", O_RDWR)) < 0) {
    perror("open");
    return 1;
  }
  slcr = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_SHARED,
              fd, 0xF8000000);
  axi_hp0 = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE,
                 MAP_SHARED, fd, 0xF8008000);
  cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_SHARED,
             fd, 0x40000000);
  sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_SHARED,
             fd, 0x40001000);
  ram = mmap(NULL, 8192 * sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE,
             MAP_SHARED, fd, 0x1E000000);
  slcr[2] = 0xDF0D;
  slcr[144] = 0;
  axi_hp0[0] &= ~1;
  axi_hp0[5] &= ~1;
  *((uint16_t *)(cfg + 0)) &= ~1;
  *((uint16_t *)(cfg + 0)) |= 1;
  *((uint16_t *)(cfg + 2)) = 0;
  *((uint16_t *)(cfg + 4)) = 1;
  *((uint16_t *)(cfg + 6)) = 1;
  *((uint32_t *)(cfg + 8)) = 1024 - 1;
  *((uint32_t *)(cfg + 12)) = 1024 * 1024 - 1;
  *((uint16_t *)(cfg + 16)) = 5;
  *((uint16_t *)(cfg + 0)) |= 2;
  *((uint16_t *)(cfg + 0)) &= ~2;
  while (*((uint32_t *)(sts + 0)) & 1) {
    usleep(1000);
  }
  start = *((uint32_t *)(sts + 0)) >> 1;
  start = (start - 1024) & 0x007FFFC0;
  for (i = 0; i < 1024 * 1024; ++i) {
    offset = ((start + i) & 0x007FFFFF) * 4;
    value[0] = *((int16_t *)(ram + offset + 0));
    value[1] = *((int16_t *)(ram + offset + 2));
    printf("%5d %5d\n", value[0], value[1]);
  }
  munmap(cfg, sysconf(_SC_PAGESIZE));
  munmap(sts, sysconf(_SC_PAGESIZE));
  munmap(ram, sysconf(_SC_PAGESIZE));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
lea    0xe71(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11b8 <main+0x48>
lea    0xe62(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ad <main+0x33d>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
mov    0x2de8(%rip),%rax
or     (%rax),%edx
mov    0x2e07(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0xf8000000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2de7(%rip),%rax
mov    (%rax),%edx
mov    0x2da6(%rip),%rax
or     (%rax),%edx
mov    0x2dc5(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0xf8008000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2da5(%rip),%rax
mov    (%rax),%edx
mov    0x2d64(%rip),%rax
or     (%rax),%edx
mov    0x2d83(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40000000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2d63(%rip),%rax
mov    (%rax),%edx
mov    0x2d22(%rip),%rax
or     (%rax),%edx
mov    0x2d41(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40001000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x40(%rbp)
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
shl    $0xd,%esi
mov    0x2d1e(%rip),%rax
mov    (%rax),%edx
mov    0x2cdd(%rip),%rax
or     (%rax),%edx
mov    0x2cfc(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1e000000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movl   $0xdf0d,0x8(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,0x240(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x14(%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,0x14(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,0x2(%rax)
mov    -0x38(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x38(%rbp),%rax
movl   $0x1,0x6(%rax)
mov    -0x38(%rbp),%rax
movl   $0x3ff,0x8(%rax)
mov    -0x38(%rbp),%rax
movl   $0xfffff,0xc(%rax)
mov    -0x38(%rbp),%rax
movl   $0x5,0x10(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     13c5 <main+0x255>
mov    $0x3e8,%edi
call   1090 <usleep@plt>
jmp    13a4 <main+0x234>
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x400,%eax
and    $0x7fffc0,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x100000,-0xc(%rbp)
jge    1443 <main+0x2d3>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
and    $0x7fffff,%eax
shl    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    0x2(%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xbde(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    13e8 <main+0x278>
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2b5d(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2b3c(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%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    0x2e53(%rip),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     13a1 <main+0x231>
mov    %eax,%ebp
mov    0x2e2c(%rip),%r12
mov    (%r12),%edi
call   1080 <sysconf@plt>
mov    0x2e44(%rip),%rbx
mov    0x2e05(%rip),%rsi
mov    (%rsi),%edx
mov    %rsi,%r14
or     (%rbx),%edx
mov    0x2e1f(%rip),%rsi
mov    (%rsi),%ecx
mov    %rsi,%r13
xor    %r15d,%r15d
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0xf8000000,%r9d
call   1030 <mmap@plt>
mov    %rax,0x10(%rsp)
mov    (%r12),%edi
call   1080 <sysconf@plt>
mov    (%r14),%edx
or     (%rbx),%edx
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0xf8008000,%r9d
call   1030 <mmap@plt>
mov    %rax,0x8(%rsp)
mov    (%r12),%edi
call   1080 <sysconf@plt>
mov    (%r14),%edx
mov    %r14,%r12
or     (%rbx),%edx
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40000000,%r9d
call   1030 <mmap@plt>
mov    %rax,%r14
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    (%r12),%edx
or     (%rbx),%edx
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40001000,%r9d
call   1030 <mmap@plt>
mov    %rax,%r13
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
shl    $0xd,%eax
mov    (%r12),%edx
or     (%rbx),%edx
mov    0x2d62(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x1e000000,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%rax
movl   $0xdf0d,0x8(%rax)
movl   $0x0,0x240(%rax)
mov    0x8(%rsp),%rax
andl   $0xfffffffe,(%rax)
andl   $0xfffffffe,0x14(%rax)
mov    (%r14),%eax
or     $0x1,%eax
mov    %eax,(%r14)
movl   $0x0,0x2(%r14)
movl   $0x1,0x4(%r14)
movl   $0x1,0x6(%r14)
movl   $0x3ff,0x8(%r14)
movabs $0x5000fffff,%rcx
mov    %rcx,0xc(%r14)
and    $0xfd,%al
mov    %al,(%r14)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%eax
test   $0x1,%al
je     1314 <main+0x1a4>
mov    $0x3e8,%edi
call   1090 <usleep@plt>
jmp    1300 <main+0x190>
and    $0xfffffe,%eax
lea    (%rax,%rax,1),%ebx
add    $0x1fff000,%ebx
and    $0x1ffff00,%ebx
lea    0xcdf(%rip),%r12
nop
lea    (%rbx,%r15,1),%eax
and    $0x1fffffc,%eax
mov    0x0(%rbp,%rax,1),%esi
mov    0x2(%rbp,%rax,1),%edx
mov    %r12,%rdi
call   1040 <printf@plt>
add    $0x4,%r15d
cmp    $0x400000,%r15d
jne    1330 <main+0x1c0>
mov    0x2c73(%rip),%rbx
mov    (%rbx),%edi
call   1080 <sysconf@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    (%rbx),%edi
call   1080 <sysconf@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    (%rbx),%edi
call   1080 <sysconf@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc61(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
jmp    1392 <main+0x222>

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.2 = [9 x i8] c"%5d %5d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2 x i32]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %1
%12 = load i32, i32* @O_RDWR
%13 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 %13, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %175
17: ; preds = %0
%18 = load i32, i32* @_SC_PAGESIZE
%19 = call i32 @sysconf(i32 %18)
%20 = load i32, i32* @PROT_READ
%21 = load i32, i32* @PROT_WRITE
%22 = or i32 %20, %21
%23 = load i32, i32* @MAP_SHARED
%24 = load i32, i32* %2
%25 = call i8* @mmap(i32* null, i32 %19, i32 %22, i32 %23, i32 %24, i32 -134217728)
%26 = bitcast i8* %25 to i32*
store i32* %26, i32** %7
%27 = load i32, i32* @_SC_PAGESIZE
%28 = call i32 @sysconf(i32 %27)
%29 = load i32, i32* @PROT_READ
%30 = load i32, i32* @PROT_WRITE
%31 = or i32 %29, %30
%32 = load i32, i32* @MAP_SHARED
%33 = load i32, i32* %2
%34 = call i8* @mmap(i32* null, i32 %28, i32 %31, i32 %32, i32 %33, i32 -134184960)
%35 = bitcast i8* %34 to i32*
store i32* %35, i32** %8
%36 = load i32, i32* @_SC_PAGESIZE
%37 = call i32 @sysconf(i32 %36)
%38 = load i32, i32* @PROT_READ
%39 = load i32, i32* @PROT_WRITE
%40 = or i32 %38, %39
%41 = load i32, i32* @MAP_SHARED
%42 = load i32, i32* %2
%43 = call i8* @mmap(i32* null, i32 %37, i32 %40, i32 %41, i32 %42, i32 1073741824)
store i8* %43, i8** %9
%44 = load i32, i32* @_SC_PAGESIZE
%45 = call i32 @sysconf(i32 %44)
%46 = load i32, i32* @PROT_READ
%47 = load i32, i32* @PROT_WRITE
%48 = or i32 %46, %47
%49 = load i32, i32* @MAP_SHARED
%50 = load i32, i32* %2
%51 = call i8* @mmap(i32* null, i32 %45, i32 %48, i32 %49, i32 %50, i32 1073745920)
store i8* %51, i8** %10
%52 = load i32, i32* @_SC_PAGESIZE
%53 = call i32 @sysconf(i32 %52)
%54 = mul nsw i32 8192, %53
%55 = load i32, i32* @PROT_READ
%56 = load i32, i32* @PROT_WRITE
%57 = or i32 %55, %56
%58 = load i32, i32* @MAP_SHARED
%59 = load i32, i32* %2
%60 = call i8* @mmap(i32* null, i32 %54, i32 %57, i32 %58, i32 %59, i32 503316480)
store i8* %60, i8** %11
%61 = load i32*, i32** %7
%62 = getelementptr inbounds i32, i32* %61, i64 2
store volatile i32 57101, i32* %62
%63 = load i32*, i32** %7
%64 = getelementptr inbounds i32, i32* %63, i64 144
store volatile i32 0, i32* %64
%65 = load i32*, i32** %8
%66 = getelementptr inbounds i32, i32* %65, i64 0
%67 = load volatile i32, i32* %66
%68 = and i32 %67, -2
store volatile i32 %68, i32* %66
%69 = load i32*, i32** %8
%70 = getelementptr inbounds i32, i32* %69, i64 5
%71 = load volatile i32, i32* %70
%72 = and i32 %71, -2
store volatile i32 %72, i32* %70
%73 = load i8*, i8** %9
%74 = getelementptr i8, i8* %73, i64 0
%75 = bitcast i8* %74 to i32*
%76 = load i32, i32* %75
%77 = and i32 %76, -2
store i32 %77, i32* %75
%78 = load i8*, i8** %9
%79 = getelementptr i8, i8* %78, i64 0
%80 = bitcast i8* %79 to i32*
%81 = load i32, i32* %80
%82 = or i32 %81, 1
store i32 %82, i32* %80
%83 = load i8*, i8** %9
%84 = getelementptr i8, i8* %83, i64 2
%85 = bitcast i8* %84 to i32*
store i32 0, i32* %85
%86 = load i8*, i8** %9
%87 = getelementptr i8, i8* %86, i64 4
%88 = bitcast i8* %87 to i32*
store i32 1, i32* %88
%89 = load i8*, i8** %9
%90 = getelementptr i8, i8* %89, i64 6
%91 = bitcast i8* %90 to i32*
store i32 1, i32* %91
%92 = load i8*, i8** %9
%93 = getelementptr i8, i8* %92, i64 8
%94 = bitcast i8* %93 to i32*
store i32 1023, i32* %94
%95 = load i8*, i8** %9
%96 = getelementptr i8, i8* %95, i64 12
%97 = bitcast i8* %96 to i32*
store i32 1048575, i32* %97
%98 = load i8*, i8** %9
%99 = getelementptr i8, i8* %98, i64 16
%100 = bitcast i8* %99 to i32*
store i32 5, i32* %100
%101 = load i8*, i8** %9
%102 = getelementptr i8, i8* %101, i64 0
%103 = bitcast i8* %102 to i32*
%104 = load i32, i32* %103
%105 = or i32 %104, 2
store i32 %105, i32* %103
%106 = load i8*, i8** %9
%107 = getelementptr i8, i8* %106, i64 0
%108 = bitcast i8* %107 to i32*
%109 = load i32, i32* %108
%110 = and i32 %109, -3
store i32 %110, i32* %108
br label %111
111: ; preds = %118, %17
%112 = load i8*, i8** %10
%113 = getelementptr i8, i8* %112, i64 0
%114 = bitcast i8* %113 to i32*
%115 = load i32, i32* %114
%116 = and i32 %115, 1
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %111
%119 = call i32 @usleep(i32 1000)
br label %111
120: ; preds = %111
%121 = load i8*, i8** %10
%122 = getelementptr i8, i8* %121, i64 0
%123 = bitcast i8* %122 to i32*
%124 = load i32, i32* %123
%125 = ashr i32 %124, 1
store i32 %125, i32* %4
%126 = load i32, i32* %4
%127 = sub nsw i32 %126, 1024
%128 = and i32 %127, 8388544
store i32 %128, i32* %4
store i32 0, i32* %3
br label %129
129: ; preds = %159, %120
%130 = load i32, i32* %3
%131 = icmp slt i32 %130, 1048576
br i1 %131, label %132, label %162
132: ; preds = %129
%133 = load i32, i32* %4
%134 = load i32, i32* %3
%135 = add nsw i32 %133, %134
%136 = and i32 %135, 8388607
%137 = mul nsw i32 %136, 4
store i32 %137, i32* %5
%138 = load i8*, i8** %11
%139 = load i32, i32* %5
%140 = sext i32 %139 to i64
%141 = getelementptr i8, i8* %138, i64 %140
%142 = getelementptr i8, i8* %141, i64 0
%143 = bitcast i8* %142 to i32*
%144 = load i32, i32* %143
%145 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %144, i32* %145
%146 = load i8*, i8** %11
%147 = load i32, i32* %5
%148 = sext i32 %147 to i64
%149 = getelementptr i8, i8* %146, i64 %148
%150 = getelementptr i8, i8* %149, i64 2
%151 = bitcast i8* %150 to i32*
%152 = load i32, i32* %151
%153 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %152, i32* %153
%154 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%155 = load i32, i32* %154
%156 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%157 = load i32, i32* %156
%158 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %155, i32 %157)
br label %159
159: ; preds = %132
%160 = load i32, i32* %3
%161 = add nsw i32 %160, 1
store i32 %161, i32* %3
br label %129
162: ; preds = %129
%163 = load i8*, i8** %9
%164 = load i32, i32* @_SC_PAGESIZE
%165 = call i32 @sysconf(i32 %164)
%166 = call i32 @munmap(i8* %163, i32 %165)
%167 = load i8*, i8** %10
%168 = load i32, i32* @_SC_PAGESIZE
%169 = call i32 @sysconf(i32 %168)
%170 = call i32 @munmap(i8* %167, i32 %169)
%171 = load i8*, i8** %11
%172 = load i32, i32* @_SC_PAGESIZE
%173 = call i32 @sysconf(i32 %172)
%174 = call i32 @munmap(i8* %171, i32 %173)
store i32 0, i32* %1
br label %175
175: ; preds = %162, %15
%176 = load i32, i32* %1
ret i32 %176
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.2 = [9 x i8] c"%5d %5d\0A\00"
define i32 @main() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %110
6: ; preds = %0
%7 = load i32, i32* @_SC_PAGESIZE
%8 = tail call i32 @sysconf(i32 %7)
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %10, %9
%12 = load i32, i32* @MAP_SHARED
%13 = tail call i8* @mmap(i32* null, i32 %8, i32 %11, i32 %12, i32 %2, i32 -134217728)
%14 = load i32, i32* @_SC_PAGESIZE
%15 = tail call i32 @sysconf(i32 %14)
%16 = load i32, i32* @PROT_READ
%17 = load i32, i32* @PROT_WRITE
%18 = or i32 %17, %16
%19 = load i32, i32* @MAP_SHARED
%20 = tail call i8* @mmap(i32* null, i32 %15, i32 %18, i32 %19, i32 %2, i32 -134184960)
%21 = bitcast i8* %20 to i32*
%22 = load i32, i32* @_SC_PAGESIZE
%23 = tail call i32 @sysconf(i32 %22)
%24 = load i32, i32* @PROT_READ
%25 = load i32, i32* @PROT_WRITE
%26 = or i32 %25, %24
%27 = load i32, i32* @MAP_SHARED
%28 = tail call i8* @mmap(i32* null, i32 %23, i32 %26, i32 %27, i32 %2, i32 1073741824)
%29 = load i32, i32* @_SC_PAGESIZE
%30 = tail call i32 @sysconf(i32 %29)
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* @PROT_WRITE
%33 = or i32 %32, %31
%34 = load i32, i32* @MAP_SHARED
%35 = tail call i8* @mmap(i32* null, i32 %30, i32 %33, i32 %34, i32 %2, i32 1073745920)
%36 = load i32, i32* @_SC_PAGESIZE
%37 = tail call i32 @sysconf(i32 %36)
%38 = shl nsw i32 %37, 13
%39 = load i32, i32* @PROT_READ
%40 = load i32, i32* @PROT_WRITE
%41 = or i32 %40, %39
%42 = load i32, i32* @MAP_SHARED
%43 = tail call i8* @mmap(i32* null, i32 %38, i32 %41, i32 %42, i32 %2, i32 503316480)
%44 = getelementptr inbounds i8, i8* %13, i64 8
%45 = bitcast i8* %44 to i32*
store volatile i32 57101, i32* %45
%46 = getelementptr inbounds i8, i8* %13, i64 576
%47 = bitcast i8* %46 to i32*
store volatile i32 0, i32* %47
%48 = load volatile i32, i32* %21
%49 = and i32 %48, -2
store volatile i32 %49, i32* %21
%50 = getelementptr inbounds i8, i8* %20, i64 20
%51 = bitcast i8* %50 to i32*
%52 = load volatile i32, i32* %51
%53 = and i32 %52, -2
store volatile i32 %53, i32* %51
%54 = bitcast i8* %28 to i32*
%55 = load i32, i32* %54
%56 = or i32 %55, 1
store i32 %56, i32* %54
%57 = getelementptr i8, i8* %28, i64 2
%58 = bitcast i8* %57 to i32*
store i32 0, i32* %58
%59 = getelementptr i8, i8* %28, i64 4
%60 = bitcast i8* %59 to i32*
store i32 1, i32* %60
%61 = getelementptr i8, i8* %28, i64 6
%62 = bitcast i8* %61 to i32*
store i32 1, i32* %62
%63 = getelementptr i8, i8* %28, i64 8
%64 = bitcast i8* %63 to i32*
store i32 1023, i32* %64
%65 = getelementptr i8, i8* %28, i64 12
%66 = bitcast i8* %65 to i32*
store i32 1048575, i32* %66
%67 = getelementptr i8, i8* %28, i64 16
%68 = bitcast i8* %67 to i32*
store i32 5, i32* %68
%69 = load i32, i32* %54
%70 = and i32 %69, -3
store i32 %70, i32* %54
%71 = bitcast i8* %35 to i32*
%72 = load i32, i32* %71
%73 = and i32 %72, 1
%74 = icmp eq i32 %73, 0
br i1 %74, label %80, label %75
75: ; preds = %6, %75
%76 = tail call i32 @usleep(i32 1000)
%77 = load i32, i32* %71
%78 = and i32 %77, 1
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %75
80: ; preds = %75, %6
%81 = phi i32 [ %72, %6 ], [ %77, %75 ]
%82 = lshr i32 %81, 1
%83 = add nuw i32 %82, 8387584
%84 = and i32 %83, 8388544
br label %85
85: ; preds = %80, %85
%86 = phi i32 [ 0, %80 ], [ %98, %85 ]
%87 = add nuw nsw i32 %86, %84
%88 = shl i32 %87, 2
%89 = and i32 %88, 33554428
%90 = zext i32 %89 to i64
%91 = getelementptr i8, i8* %43, i64 %90
%92 = bitcast i8* %91 to i32*
%93 = load i32, i32* %92
%94 = getelementptr i8, i8* %91, i64 2
%95 = bitcast i8* %94 to i32*
%96 = load i32, i32* %95
%97 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %93, i32 %96)
%98 = add nuw nsw i32 %86, 1
%99 = icmp eq i32 %98, 1048576
br i1 %99, label %100, label %85
100: ; preds = %85
%101 = load i32, i32* @_SC_PAGESIZE
%102 = tail call i32 @sysconf(i32 %101)
%103 = tail call i32 @munmap(i8* %28, i32 %102)
%104 = load i32, i32* @_SC_PAGESIZE
%105 = tail call i32 @sysconf(i32 %104)
%106 = tail call i32 @munmap(i8* %35, i32 %105)
%107 = load i32, i32* @_SC_PAGESIZE
%108 = tail call i32 @sysconf(i32 %107)
%109 = tail call i32 @munmap(i8* %43, i32 %108)
br label %110
110: ; preds = %100, %4
%111 = phi i32 [ 1, %4 ], [ 0, %100 ]
ret i32 %111
}