#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 int32_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _SC_PAGESIZE;
scalar_t__ floor(int);
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 sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int main() {
  int fd, i;
  uint32_t start, offset;
  int32_t value;
  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;
  *((uint32_t *)(cfg + 4)) =
      (uint32_t)floor(13560000 / 125.0e6 * (1 << 30) + 0.5);
  *((uint32_t *)(cfg + 8)) = 10;
  *((uint16_t *)(cfg + 2)) = 1;
  *((int32_t *)(cfg + 12)) = 10000;
  *((uint32_t *)(cfg + 16)) = 1024 - 1;
  *((uint32_t *)(cfg + 20)) = 8 * 1024 * 1024 - 1;
  *((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 < 8 * 1024 * 1024; ++i) {
    offset = ((start + i) & 0x007FFFFF) * 4;
    value = *((int32_t *)(ram + offset));
    printf("%10d\n", value);
  }
  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    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11c8 <main+0x48>
lea    0xe52(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14b3 <main+0x333>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2e19(%rip),%rax
mov    (%rax),%edx
mov    0x2dd8(%rip),%rax
or     (%rax),%edx
mov    0x2df7(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0xf8000000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2dd7(%rip),%rax
mov    (%rax),%edx
mov    0x2d96(%rip),%rax
or     (%rax),%edx
mov    0x2db5(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0xf8008000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
mov    0x2d54(%rip),%rax
or     (%rax),%edx
mov    0x2d73(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40000000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
mov    0x2d53(%rip),%rax
mov    (%rax),%edx
mov    0x2d12(%rip),%rax
or     (%rax),%edx
mov    0x2d31(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40001000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
shl    $0xd,%esi
mov    0x2d0e(%rip),%rax
mov    (%rax),%edx
mov    0x2ccd(%rip),%rax
or     (%rax),%edx
mov    0x2cec(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1e000000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movl   $0xdf0d,0x8(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,0x240(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,0x14(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    $0x6f15619,%edi
call   1090 <floor@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x30(%rbp),%rax
movl   $0xa,0x8(%rax)
mov    -0x30(%rbp),%rax
movl   $0x1,0x2(%rax)
mov    -0x30(%rbp),%rax
movl   $0x2710,0xc(%rax)
mov    -0x30(%rbp),%rax
movl   $0x3ff,0x10(%rax)
mov    -0x30(%rbp),%rax
movl   $0x7fffff,0x14(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     13dd <main+0x25d>
mov    $0x3e8,%edi
call   10a0 <usleep@plt>
jmp    13bc <main+0x23c>
mov    -0x38(%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   $0x800000,-0xc(%rbp)
jge    1449 <main+0x2c9>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
and    $0x7fffff,%eax
shl    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xbd8(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1400 <main+0x280>
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2b78(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2b57(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    -0x48(%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    0x2e43(%rip),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     139d <main+0x21d>
mov    %eax,%ebp
mov    0x2e1c(%rip),%r12
mov    (%r12),%edi
call   1080 <sysconf@plt>
mov    0x2e34(%rip),%rbx
mov    0x2df5(%rip),%rsi
mov    (%rsi),%edx
mov    %rsi,%r14
or     (%rbx),%edx
mov    0x2e0f(%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    0x2d7e(%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    0x2d51(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
shl    $0xd,%eax
mov    (%r12),%edx
or     (%rbx),%edx
mov    0x2d52(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x1e000000,%r9d
call   1030 <mmap@plt>
mov    0x10(%rsp),%rcx
movl   $0xdf0d,0x8(%rcx)
movl   $0x0,0x240(%rcx)
mov    0x8(%rsp),%rcx
andl   $0xfffffffe,(%rcx)
andl   $0xfffffffe,0x14(%rcx)
mov    %rax,%r12
orb    $0x1,(%r14)
mov    $0x6f15619,%edi
call   1090 <floor@plt>
mov    %eax,0x4(%r14)
movl   $0x1,0x2(%r14)
movaps 0xd10(%rip),%xmm0
movups %xmm0,0x8(%r14)
andb   $0xfd,(%r14)
nopl   0x0(%rax)
mov    0x0(%r13),%eax
test   $0x1,%al
je     1314 <main+0x194>
mov    $0x3e8,%edi
call   10a0 <usleep@plt>
jmp    1300 <main+0x180>
and    $0xfffffe,%eax
lea    (%rax,%rax,1),%ebp
add    $0x1fff000,%ebp
and    $0x1ffff00,%ebp
lea    0xcef(%rip),%rbx
nop
lea    (%r15,%rbp,1),%eax
and    $0x1fffffc,%eax
mov    (%r12,%rax,1),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
add    $0x4,%r15d
cmp    $0x2000000,%r15d
jne    1330 <main+0x1b0>
mov    0x2c77(%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    %r12,%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    0xc75(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
jmp    138e <main+0x20e>

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 = [6 x i8] c"%10d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca 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 %164
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 = call i64 @floor(i32 116479513)
%84 = trunc i64 %83 to i32
%85 = load i8*, i8** %9
%86 = getelementptr i8, i8* %85, i64 4
%87 = bitcast i8* %86 to i32*
store i32 %84, i32* %87
%88 = load i8*, i8** %9
%89 = getelementptr i8, i8* %88, i64 8
%90 = bitcast i8* %89 to i32*
store i32 10, i32* %90
%91 = load i8*, i8** %9
%92 = getelementptr i8, i8* %91, i64 2
%93 = bitcast i8* %92 to i32*
store i32 1, i32* %93
%94 = load i8*, i8** %9
%95 = getelementptr i8, i8* %94, i64 12
%96 = bitcast i8* %95 to i32*
store i32 10000, i32* %96
%97 = load i8*, i8** %9
%98 = getelementptr i8, i8* %97, i64 16
%99 = bitcast i8* %98 to i32*
store i32 1023, i32* %99
%100 = load i8*, i8** %9
%101 = getelementptr i8, i8* %100, i64 20
%102 = bitcast i8* %101 to i32*
store i32 8388607, i32* %102
%103 = load i8*, i8** %9
%104 = getelementptr i8, i8* %103, i64 0
%105 = bitcast i8* %104 to i32*
%106 = load i32, i32* %105
%107 = or i32 %106, 2
store i32 %107, i32* %105
%108 = load i8*, i8** %9
%109 = getelementptr i8, i8* %108, i64 0
%110 = bitcast i8* %109 to i32*
%111 = load i32, i32* %110
%112 = and i32 %111, -3
store i32 %112, i32* %110
br label %113
113: ; preds = %120, %17
%114 = load i8*, i8** %10
%115 = getelementptr i8, i8* %114, i64 0
%116 = bitcast i8* %115 to i32*
%117 = load i32, i32* %116
%118 = and i32 %117, 1
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %122
120: ; preds = %113
%121 = call i32 @usleep(i32 1000)
br label %113
122: ; preds = %113
%123 = load i8*, i8** %10
%124 = getelementptr i8, i8* %123, i64 0
%125 = bitcast i8* %124 to i32*
%126 = load i32, i32* %125
%127 = ashr i32 %126, 1
store i32 %127, i32* %4
%128 = load i32, i32* %4
%129 = sub nsw i32 %128, 1024
%130 = and i32 %129, 8388544
store i32 %130, i32* %4
store i32 0, i32* %3
br label %131
131: ; preds = %148, %122
%132 = load i32, i32* %3
%133 = icmp slt i32 %132, 8388608
br i1 %133, label %134, label %151
134: ; preds = %131
%135 = load i32, i32* %4
%136 = load i32, i32* %3
%137 = add nsw i32 %135, %136
%138 = and i32 %137, 8388607
%139 = mul nsw i32 %138, 4
store i32 %139, i32* %5
%140 = load i8*, i8** %11
%141 = load i32, i32* %5
%142 = sext i32 %141 to i64
%143 = getelementptr i8, i8* %140, i64 %142
%144 = bitcast i8* %143 to i32*
%145 = load i32, i32* %144
store i32 %145, i32* %6
%146 = load i32, i32* %6
%147 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %146)
br label %148
148: ; preds = %134
%149 = load i32, i32* %3
%150 = add nsw i32 %149, 1
store i32 %150, i32* %3
br label %131
151: ; preds = %131
%152 = load i8*, i8** %9
%153 = load i32, i32* @_SC_PAGESIZE
%154 = call i32 @sysconf(i32 %153)
%155 = call i32 @munmap(i8* %152, i32 %154)
%156 = load i8*, i8** %10
%157 = load i32, i32* @_SC_PAGESIZE
%158 = call i32 @sysconf(i32 %157)
%159 = call i32 @munmap(i8* %156, i32 %158)
%160 = load i8*, i8** %11
%161 = load i32, i32* @_SC_PAGESIZE
%162 = call i32 @sysconf(i32 %161)
%163 = call i32 @munmap(i8* %160, i32 %162)
store i32 0, i32* %1
br label %164
164: ; preds = %151, %15
%165 = load i32, i32* %1
ret i32 %165
}

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 = [6 x i8] c"%10d\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 %103
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 = tail call i64 @floor(i32 116479513)
%58 = trunc i64 %57 to i32
%59 = getelementptr i8, i8* %28, i64 4
%60 = bitcast i8* %59 to i32*
store i32 %58, i32* %60
%61 = getelementptr i8, i8* %28, i64 8
%62 = getelementptr i8, i8* %28, i64 2
%63 = bitcast i8* %62 to i32*
store i32 1, i32* %63
%64 = bitcast i8* %61 to <4 x i32>*
store <4 x i32> <i32 10, i32 10000, i32 1023, i32 8388607>, <4 x i32>* %64
%65 = load i32, i32* %54
%66 = and i32 %65, -3
store i32 %66, i32* %54
%67 = bitcast i8* %35 to i32*
%68 = load i32, i32* %67
%69 = and i32 %68, 1
%70 = icmp eq i32 %69, 0
br i1 %70, label %76, label %71
71: ; preds = %6, %71
%72 = tail call i32 @usleep(i32 1000)
%73 = load i32, i32* %67
%74 = and i32 %73, 1
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %71
76: ; preds = %71, %6
%77 = phi i32 [ %68, %6 ], [ %73, %71 ]
%78 = lshr i32 %77, 1
%79 = add nuw i32 %78, 8387584
%80 = and i32 %79, 8388544
br label %81
81: ; preds = %76, %81
%82 = phi i32 [ 0, %76 ], [ %91, %81 ]
%83 = add nuw nsw i32 %82, %80
%84 = shl i32 %83, 2
%85 = and i32 %84, 33554428
%86 = zext i32 %85 to i64
%87 = getelementptr i8, i8* %43, i64 %86
%88 = bitcast i8* %87 to i32*
%89 = load i32, i32* %88
%90 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %89)
%91 = add nuw nsw i32 %82, 1
%92 = icmp eq i32 %91, 8388608
br i1 %92, label %93, label %81
93: ; preds = %81
%94 = load i32, i32* @_SC_PAGESIZE
%95 = tail call i32 @sysconf(i32 %94)
%96 = tail call i32 @munmap(i8* %28, i32 %95)
%97 = load i32, i32* @_SC_PAGESIZE
%98 = tail call i32 @sysconf(i32 %97)
%99 = tail call i32 @munmap(i8* %35, i32 %98)
%100 = load i32, i32* @_SC_PAGESIZE
%101 = tail call i32 @sysconf(i32 %100)
%102 = tail call i32 @munmap(i8* %43, i32 %101)
br label %103
103: ; preds = %93, %4
%104 = phi i32 [ 1, %4 ], [ 0, %93 ]
ret i32 %104
}