#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;
int /*<<< orphan*/ memcpy(void volatile *, void volatile *, 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);
int sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int main() {
  int fd, i, j;
  int16_t value[2];
  volatile uint32_t *slcr, *axi_hp0;
  volatile void *cfg, *sts, *dac, *adc;
  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);
  dac = mmap(NULL, 16 * sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE,
             MAP_SHARED, fd, 0x40010000);
  adc = 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 + 4)) = 3052;
  *((uint16_t *)(cfg + 6)) = 24416 - 1;
  *((uint16_t *)(cfg + 0)) &= ~2;
  *((uint16_t *)(cfg + 0)) |= 2;
  *((uint16_t *)(cfg + 0)) &= ~1;
  *((uint32_t *)(cfg + 8)) = 4098 * 512 - 1;
  *((uint16_t *)(cfg + 0)) |= 1;
  while (*((uint32_t *)(sts + 0)) < 32) {
    usleep(500);
  }
  for (i = 0; i <= 8176; i += 16) {
    while (*((uint32_t *)(sts + 4)) > 15000) {
      usleep(10000);
    }
    for (j = 0; j <= 8176; j += 16) {
      value[0] = j;
      value[1] = i;
      memcpy(dac, value, 4);
    }
    i += 16;
    for (j = 8176; j >= 0; j -= 16) {
      value[0] = j;
      value[1] = i;
      memcpy(dac, value, 4);
    }
  }
  for (i = 0; i < 3; ++i) {
    value[0] = 0;
    value[1] = 8176;
    memcpy(dac, value, 4);
  }
  while (*((uint32_t *)(sts + 0)) < 2049 * 512) {
    usleep(10000);
  }
  for (i = 0; i < 4 * 4098 * 512; i += 4) {
    memcpy(value, adc + i, 4);
    printf("%8d %8d\n", value[0], value[1]);
  }
  munmap(cfg, sysconf(_SC_PAGESIZE));
  munmap(sts, sysconf(_SC_PAGESIZE));
  munmap(dac, sysconf(_SC_PAGESIZE));
  munmap(adc, sysconf(_SC_PAGESIZE));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11c8 <main+0x48>
lea    0xe52(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1601 <main+0x481>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1090 <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   1090 <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   1090 <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   1090 <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   1090 <sysconf@plt>
mov    %eax,%esi
shl    $0x4,%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    $0x40010000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x40(%rbp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    %eax,%esi
shl    $0xd,%esi
mov    0x2cc9(%rip),%rax
mov    (%rax),%edx
mov    0x2c88(%rip),%rax
or     (%rax),%edx
mov    0x2ca7(%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    -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
movl   $0xbec,0x4(%rax)
mov    -0x30(%rbp),%rax
movl   $0x5f5f,0x6(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x2003ff,0x8(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
cmpl   $0x20,(%rax)
jge    13f4 <main+0x274>
mov    $0x1f4,%edi
call   10a0 <usleep@plt>
jmp    13d8 <main+0x258>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1ff0,-0xc(%rbp)
jg     14c6 <main+0x346>
jmp    140d <main+0x28d>
mov    -0x38(%rbp),%rax
cmpl   $0x3a98,0x4(%rax)
jle    142d <main+0x2ad>
mov    $0x2710,%edi
call   10a0 <usleep@plt>
jmp    140d <main+0x28d>
movl   $0x0,-0x10(%rbp)
cmpl   $0x1ff0,-0x10(%rbp)
jg     146d <main+0x2ed>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1434 <main+0x2b4>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
movl   $0x1ff0,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     14b3 <main+0x333>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    147d <main+0x2fd>
jmp    14b8 <main+0x338>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
jmp    13fb <main+0x27b>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1505 <main+0x385>
movl   $0x0,-0x18(%rbp)
movl   $0x1ff0,-0x14(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    14cd <main+0x34d>
jmp    150a <main+0x38a>
mov    -0x38(%rbp),%rax
cmpl   $0x100200,(%rax)
jge    1529 <main+0x3a9>
mov    $0x2710,%edi
call   10a0 <usleep@plt>
jmp    150a <main+0x38a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x801000,-0xc(%rbp)
jge    1576 <main+0x3f6>
lea    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xaab(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    1530 <main+0x3b0>
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2a4b(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2a2a(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2a09(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x29e8(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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    0x2e43(%rip),%rax
mov    (%rax),%esi
lea    0xe62(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     1512 <main+0x392>
mov    %eax,%ebp
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    %rax,%r12
call   1090 <sysconf@plt>
mov    0x2e33(%rip),%rbx
mov    0x2df4(%rip),%rsi
mov    (%rsi),%edx
mov    %rsi,%r15
or     (%rbx),%edx
mov    0x2e0e(%rip),%rsi
mov    (%rsi),%ecx
mov    %rsi,%r13
xor    %r14d,%r14d
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0xf8000000,%r9d
call   1030 <mmap@plt>
mov    %rax,0x10(%rsp)
mov    (%r12),%edi
call   1090 <sysconf@plt>
mov    (%r15),%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   1090 <sysconf@plt>
mov    (%r15),%edx
or     (%rbx),%edx
mov    0x0(%r13),%ecx
mov    %r13,%r12
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40000000,%r9d
call   1030 <mmap@plt>
mov    %rax,%r13
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    (%r15),%edx
or     (%rbx),%edx
mov    (%r12),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40001000,%r9d
call   1030 <mmap@plt>
mov    %rax,%r15
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
shl    $0x4,%eax
mov    0x2d30(%rip),%rcx
mov    (%rcx),%edx
or     (%rbx),%edx
mov    (%r12),%ecx
mov    %r12,%rbx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40010000,%r9d
call   1030 <mmap@plt>
mov    %rax,%r12
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
shl    $0xd,%eax
mov    0x2cf8(%rip),%rcx
mov    (%rcx),%edx
mov    0x2d27(%rip),%rcx
or     (%rcx),%edx
mov    (%rbx),%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)
movl   $0xbec,0x4(%r13)
movl   $0x5f5f,0x6(%r13)
movl   $0x2003ff,0x8(%r13)
mov    %r13,0x10(%rsp)
orb    $0x3,0x0(%r13)
mov    %rax,0x8(%rsp)
cmpl   $0x1f,(%r15)
jg     1350 <main+0x1d0>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1f4,%edi
call   10a0 <usleep@plt>
cmpl   $0x20,(%r15)
jl     1340 <main+0x1c0>
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpl   $0x3a99,0x4(%r15)
jl     1384 <main+0x204>
nopw   0x0(%rax,%rax,1)
mov    $0x2710,%edi
call   10a0 <usleep@plt>
cmpl   $0x3a98,0x4(%r15)
jg     1370 <main+0x1f0>
mov    $0xfffffff0,%ebx
nopl   0x0(%rax)
add    $0x10,%ebx
mov    %ebx,(%rsp)
mov    %r14d,0x4(%rsp)
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
cmp    $0x1fe1,%ebx
jb     1390 <main+0x210>
mov    %r14d,%ebx
or     $0x10,%ebx
mov    $0x1ff0,%ebp
xchg   %ax,%ax
mov    %ebp,(%rsp)
mov    %ebx,0x4(%rsp)
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
add    $0xfffffff0,%ebp
cmp    $0xfffffff0,%ebp
jne    13c0 <main+0x240>
lea    0x20(%r14),%eax
cmp    $0x1fd1,%r14d
mov    %eax,%r14d
jb     1360 <main+0x1e0>
movabs $0x1ff000000000,%rbx
mov    %rbx,(%rsp)
mov    %rsp,%rbp
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    %rbx,(%rsp)
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    %rbx,(%rsp)
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
cmpl   $0x1001ff,(%r15)
jg     1463 <main+0x2e3>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2710,%edi
call   10a0 <usleep@plt>
cmpl   $0x100200,(%r15)
jl     1450 <main+0x2d0>
mov    $0xfffffffffffffffc,%rbp
mov    %rsp,%r13
lea    0xb9a(%rip),%r14
mov    0x8(%rsp),%rbx
nopl   0x0(%rax)
lea    (%rbx,%rbp,1),%rsi
add    $0x4,%rsi
mov    %r13,%rdi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x4,%rbp
cmp    $0x800ffc,%rbp
jb     1480 <main+0x300>
mov    %rbx,%rbp
mov    0x2b15(%rip),%rbx
mov    (%rbx),%edi
call   1090 <sysconf@plt>
mov    0x10(%rsp),%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
mov    (%rbx),%edi
call   1090 <sysconf@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
mov    (%rbx),%edi
call   1090 <sysconf@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
mov    (%rbx),%edi
call   1090 <sysconf@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1060 <munmap@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xaf0(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    1503 <main+0x383>

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"%8d %8d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%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 %230
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** %6
%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** %7
%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** %8
%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** %9
%52 = load i32, i32* @_SC_PAGESIZE
%53 = call i32 @sysconf(i32 %52)
%54 = mul nsw i32 16, %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 1073807360)
store i8* %60, i8** %10
%61 = load i32, i32* @_SC_PAGESIZE
%62 = call i32 @sysconf(i32 %61)
%63 = mul nsw i32 8192, %62
%64 = load i32, i32* @PROT_READ
%65 = load i32, i32* @PROT_WRITE
%66 = or i32 %64, %65
%67 = load i32, i32* @MAP_SHARED
%68 = load i32, i32* %2
%69 = call i8* @mmap(i32* null, i32 %63, i32 %66, i32 %67, i32 %68, i32 503316480)
store i8* %69, i8** %11
%70 = load i32*, i32** %6
%71 = getelementptr inbounds i32, i32* %70, i64 2
store volatile i32 57101, i32* %71
%72 = load i32*, i32** %6
%73 = getelementptr inbounds i32, i32* %72, i64 144
store volatile i32 0, i32* %73
%74 = load i32*, i32** %7
%75 = getelementptr inbounds i32, i32* %74, i64 0
%76 = load volatile i32, i32* %75
%77 = and i32 %76, -2
store volatile i32 %77, i32* %75
%78 = load i32*, i32** %7
%79 = getelementptr inbounds i32, i32* %78, i64 5
%80 = load volatile i32, i32* %79
%81 = and i32 %80, -2
store volatile i32 %81, i32* %79
%82 = load i8*, i8** %8
%83 = getelementptr i8, i8* %82, i64 4
%84 = bitcast i8* %83 to i32*
store i32 3052, i32* %84
%85 = load i8*, i8** %8
%86 = getelementptr i8, i8* %85, i64 6
%87 = bitcast i8* %86 to i32*
store i32 24415, i32* %87
%88 = load i8*, i8** %8
%89 = getelementptr i8, i8* %88, i64 0
%90 = bitcast i8* %89 to i32*
%91 = load i32, i32* %90
%92 = and i32 %91, -3
store i32 %92, i32* %90
%93 = load i8*, i8** %8
%94 = getelementptr i8, i8* %93, i64 0
%95 = bitcast i8* %94 to i32*
%96 = load i32, i32* %95
%97 = or i32 %96, 2
store i32 %97, i32* %95
%98 = load i8*, i8** %8
%99 = getelementptr i8, i8* %98, i64 0
%100 = bitcast i8* %99 to i32*
%101 = load i32, i32* %100
%102 = and i32 %101, -2
store i32 %102, i32* %100
%103 = load i8*, i8** %8
%104 = getelementptr i8, i8* %103, i64 8
%105 = bitcast i8* %104 to i32*
store i32 2098175, i32* %105
%106 = load i8*, i8** %8
%107 = getelementptr i8, i8* %106, i64 0
%108 = bitcast i8* %107 to i32*
%109 = load i32, i32* %108
%110 = or i32 %109, 1
store i32 %110, i32* %108
br label %111
111: ; preds = %117, %17
%112 = load i8*, i8** %9
%113 = getelementptr i8, i8* %112, i64 0
%114 = bitcast i8* %113 to i32*
%115 = load i32, i32* %114
%116 = icmp slt i32 %115, 32
br i1 %116, label %117, label %119
117: ; preds = %111
%118 = call i32 @usleep(i32 500)
br label %111
119: ; preds = %111
store i32 0, i32* %3
br label %120
120: ; preds = %167, %119
%121 = load i32, i32* %3
%122 = icmp sle i32 %121, 8176
br i1 %122, label %123, label %170
123: ; preds = %120
br label %124
124: ; preds = %130, %123
%125 = load i8*, i8** %9
%126 = getelementptr i8, i8* %125, i64 4
%127 = bitcast i8* %126 to i32*
%128 = load i32, i32* %127
%129 = icmp sgt i32 %128, 15000
br i1 %129, label %130, label %132
130: ; preds = %124
%131 = call i32 @usleep(i32 10000)
br label %124
132: ; preds = %124
store i32 0, i32* %4
br label %133
133: ; preds = %145, %132
%134 = load i32, i32* %4
%135 = icmp sle i32 %134, 8176
br i1 %135, label %136, label %148
136: ; preds = %133
%137 = load i32, i32* %4
%138 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %137, i32* %138
%139 = load i32, i32* %3
%140 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %139, i32* %140
%141 = load i8*, i8** %10
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%143 = bitcast i32* %142 to i8*
%144 = call i32 @memcpy(i8* %141, i8* %143, i32 4)
br label %145
145: ; preds = %136
%146 = load i32, i32* %4
%147 = add nsw i32 %146, 16
store i32 %147, i32* %4
br label %133
148: ; preds = %133
%149 = load i32, i32* %3
%150 = add nsw i32 %149, 16
store i32 %150, i32* %3
store i32 8176, i32* %4
br label %151
151: ; preds = %163, %148
%152 = load i32, i32* %4
%153 = icmp sge i32 %152, 0
br i1 %153, label %154, label %166
154: ; preds = %151
%155 = load i32, i32* %4
%156 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %155, i32* %156
%157 = load i32, i32* %3
%158 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %157, i32* %158
%159 = load i8*, i8** %10
%160 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%161 = bitcast i32* %160 to i8*
%162 = call i32 @memcpy(i8* %159, i8* %161, i32 4)
br label %163
163: ; preds = %154
%164 = load i32, i32* %4
%165 = sub nsw i32 %164, 16
store i32 %165, i32* %4
br label %151
166: ; preds = %151
br label %167
167: ; preds = %166
%168 = load i32, i32* %3
%169 = add nsw i32 %168, 16
store i32 %169, i32* %3
br label %120
170: ; preds = %120
store i32 0, i32* %3
br label %171
171: ; preds = %181, %170
%172 = load i32, i32* %3
%173 = icmp slt i32 %172, 3
br i1 %173, label %174, label %184
174: ; preds = %171
%175 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 0, i32* %175
%176 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 8176, i32* %176
%177 = load i8*, i8** %10
%178 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%179 = bitcast i32* %178 to i8*
%180 = call i32 @memcpy(i8* %177, i8* %179, i32 4)
br label %181
181: ; preds = %174
%182 = load i32, i32* %3
%183 = add nsw i32 %182, 1
store i32 %183, i32* %3
br label %171
184: ; preds = %171
br label %185
185: ; preds = %191, %184
%186 = load i8*, i8** %9
%187 = getelementptr i8, i8* %186, i64 0
%188 = bitcast i8* %187 to i32*
%189 = load i32, i32* %188
%190 = icmp slt i32 %189, 1049088
br i1 %190, label %191, label %193
191: ; preds = %185
%192 = call i32 @usleep(i32 10000)
br label %185
193: ; preds = %185
store i32 0, i32* %3
br label %194
194: ; preds = %210, %193
%195 = load i32, i32* %3
%196 = icmp slt i32 %195, 8392704
br i1 %196, label %197, label %213
197: ; preds = %194
%198 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%199 = bitcast i32* %198 to i8*
%200 = load i8*, i8** %11
%201 = load i32, i32* %3
%202 = sext i32 %201 to i64
%203 = getelementptr i8, i8* %200, i64 %202
%204 = call i32 @memcpy(i8* %199, i8* %203, i32 4)
%205 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%206 = load i32, i32* %205
%207 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%208 = load i32, i32* %207
%209 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %206, i32 %208)
br label %210
210: ; preds = %197
%211 = load i32, i32* %3
%212 = add nsw i32 %211, 4
store i32 %212, i32* %3
br label %194
213: ; preds = %194
%214 = load i8*, i8** %8
%215 = load i32, i32* @_SC_PAGESIZE
%216 = call i32 @sysconf(i32 %215)
%217 = call i32 @munmap(i8* %214, i32 %216)
%218 = load i8*, i8** %9
%219 = load i32, i32* @_SC_PAGESIZE
%220 = call i32 @sysconf(i32 %219)
%221 = call i32 @munmap(i8* %218, i32 %220)
%222 = load i8*, i8** %10
%223 = load i32, i32* @_SC_PAGESIZE
%224 = call i32 @sysconf(i32 %223)
%225 = call i32 @munmap(i8* %222, i32 %224)
%226 = load i8*, i8** %11
%227 = load i32, i32* @_SC_PAGESIZE
%228 = call i32 @sysconf(i32 %227)
%229 = call i32 @munmap(i8* %226, i32 %228)
store i32 0, i32* %1
br label %230
230: ; preds = %213, %15
%231 = load i32, i32* %1
ret i32 %231
}

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"%8d %8d\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %142
8: ; preds = %0
%9 = load i32, i32* @_SC_PAGESIZE
%10 = tail call i32 @sysconf(i32 %9)
%11 = load i32, i32* @PROT_READ
%12 = load i32, i32* @PROT_WRITE
%13 = or i32 %12, %11
%14 = load i32, i32* @MAP_SHARED
%15 = tail call i8* @mmap(i32* null, i32 %10, i32 %13, i32 %14, i32 %4, i32 -134217728)
%16 = load i32, i32* @_SC_PAGESIZE
%17 = tail call i32 @sysconf(i32 %16)
%18 = load i32, i32* @PROT_READ
%19 = load i32, i32* @PROT_WRITE
%20 = or i32 %19, %18
%21 = load i32, i32* @MAP_SHARED
%22 = tail call i8* @mmap(i32* null, i32 %17, i32 %20, i32 %21, i32 %4, i32 -134184960)
%23 = bitcast i8* %22 to i32*
%24 = load i32, i32* @_SC_PAGESIZE
%25 = tail call i32 @sysconf(i32 %24)
%26 = load i32, i32* @PROT_READ
%27 = load i32, i32* @PROT_WRITE
%28 = or i32 %27, %26
%29 = load i32, i32* @MAP_SHARED
%30 = tail call i8* @mmap(i32* null, i32 %25, i32 %28, i32 %29, i32 %4, i32 1073741824)
%31 = load i32, i32* @_SC_PAGESIZE
%32 = tail call i32 @sysconf(i32 %31)
%33 = load i32, i32* @PROT_READ
%34 = load i32, i32* @PROT_WRITE
%35 = or i32 %34, %33
%36 = load i32, i32* @MAP_SHARED
%37 = tail call i8* @mmap(i32* null, i32 %32, i32 %35, i32 %36, i32 %4, i32 1073745920)
%38 = load i32, i32* @_SC_PAGESIZE
%39 = tail call i32 @sysconf(i32 %38)
%40 = shl nsw i32 %39, 4
%41 = load i32, i32* @PROT_READ
%42 = load i32, i32* @PROT_WRITE
%43 = or i32 %42, %41
%44 = load i32, i32* @MAP_SHARED
%45 = tail call i8* @mmap(i32* null, i32 %40, i32 %43, i32 %44, i32 %4, i32 1073807360)
%46 = load i32, i32* @_SC_PAGESIZE
%47 = tail call i32 @sysconf(i32 %46)
%48 = shl nsw i32 %47, 13
%49 = load i32, i32* @PROT_READ
%50 = load i32, i32* @PROT_WRITE
%51 = or i32 %50, %49
%52 = load i32, i32* @MAP_SHARED
%53 = tail call i8* @mmap(i32* null, i32 %48, i32 %51, i32 %52, i32 %4, i32 503316480)
%54 = getelementptr inbounds i8, i8* %15, i64 8
%55 = bitcast i8* %54 to i32*
store volatile i32 57101, i32* %55
%56 = getelementptr inbounds i8, i8* %15, i64 576
%57 = bitcast i8* %56 to i32*
store volatile i32 0, i32* %57
%58 = load volatile i32, i32* %23
%59 = and i32 %58, -2
store volatile i32 %59, i32* %23
%60 = getelementptr inbounds i8, i8* %22, i64 20
%61 = bitcast i8* %60 to i32*
%62 = load volatile i32, i32* %61
%63 = and i32 %62, -2
store volatile i32 %63, i32* %61
%64 = getelementptr i8, i8* %30, i64 4
%65 = bitcast i8* %64 to i32*
store i32 3052, i32* %65
%66 = getelementptr i8, i8* %30, i64 6
%67 = bitcast i8* %66 to i32*
store i32 24415, i32* %67
%68 = bitcast i8* %30 to i32*
%69 = load i32, i32* %68
%70 = getelementptr i8, i8* %30, i64 8
%71 = bitcast i8* %70 to i32*
store i32 2098175, i32* %71
%72 = or i32 %69, 3
store i32 %72, i32* %68
%73 = bitcast i8* %37 to i32*
%74 = load i32, i32* %73
%75 = icmp slt i32 %74, 32
br i1 %75, label %81, label %76
76: ; preds = %81, %8
%77 = getelementptr i8, i8* %37, i64 4
%78 = bitcast i8* %77 to i32*
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
br label %85
81: ; preds = %8, %81
%82 = tail call i32 @usleep(i32 500)
%83 = load i32, i32* %73
%84 = icmp slt i32 %83, 32
br i1 %84, label %81, label %76
85: ; preds = %76, %112
%86 = phi i32 [ 0, %76 ], [ %113, %112 ]
%87 = load i32, i32* %78
%88 = icmp sgt i32 %87, 15000
br i1 %88, label %95, label %99
89: ; preds = %112
store i32 0, i32* %79
store i32 8176, i32* %80
%90 = call i32 @memcpy(i8* %45, i8* %2, i32 4)
store i32 0, i32* %79
store i32 8176, i32* %80
%91 = call i32 @memcpy(i8* %45, i8* %2, i32 4)
store i32 0, i32* %79
store i32 8176, i32* %80
%92 = call i32 @memcpy(i8* %45, i8* %2, i32 4)
%93 = load i32, i32* %73
%94 = icmp slt i32 %93, 1049088
br i1 %94, label %115, label %119
95: ; preds = %85, %95
%96 = call i32 @usleep(i32 10000)
%97 = load i32, i32* %78
%98 = icmp sgt i32 %97, 15000
br i1 %98, label %95, label %99
99: ; preds = %95, %85
br label %100
100: ; preds = %99, %100
%101 = phi i32 [ %103, %100 ], [ 0, %99 ]
store i32 %101, i32* %79
store i32 %86, i32* %80
%102 = call i32 @memcpy(i8* %45, i8* %2, i32 4)
%103 = add nuw nsw i32 %101, 16
%104 = icmp ult i32 %101, 8161
br i1 %104, label %100, label %105
105: ; preds = %100
%106 = or i32 %86, 16
br label %107
107: ; preds = %105, %107
%108 = phi i32 [ 8176, %105 ], [ %110, %107 ]
store i32 %108, i32* %79
store i32 %106, i32* %80
%109 = call i32 @memcpy(i8* %45, i8* %2, i32 4)
%110 = add nsw i32 %108, -16
%111 = icmp eq i32 %108, 0
br i1 %111, label %112, label %107
112: ; preds = %107
%113 = add nuw nsw i32 %86, 32
%114 = icmp ult i32 %86, 8145
br i1 %114, label %85, label %89
115: ; preds = %89, %115
%116 = call i32 @usleep(i32 10000)
%117 = load i32, i32* %73
%118 = icmp slt i32 %117, 1049088
br i1 %118, label %115, label %119
119: ; preds = %115, %89
br label %120
120: ; preds = %119, %120
%121 = phi i64 [ %127, %120 ], [ 0, %119 ]
%122 = getelementptr i8, i8* %53, i64 %121
%123 = call i32 @memcpy(i8* %2, i8* %122, i32 4)
%124 = load i32, i32* %79
%125 = load i32, i32* %80
%126 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %124, i32 %125)
%127 = add nuw nsw i64 %121, 4
%128 = icmp ult i64 %121, 8392700
br i1 %128, label %120, label %129
129: ; preds = %120
%130 = load i32, i32* @_SC_PAGESIZE
%131 = call i32 @sysconf(i32 %130)
%132 = call i32 @munmap(i8* %30, i32 %131)
%133 = load i32, i32* @_SC_PAGESIZE
%134 = call i32 @sysconf(i32 %133)
%135 = call i32 @munmap(i8* %37, i32 %134)
%136 = load i32, i32* @_SC_PAGESIZE
%137 = call i32 @sysconf(i32 %136)
%138 = call i32 @munmap(i8* %45, i32 %137)
%139 = load i32, i32* @_SC_PAGESIZE
%140 = call i32 @sysconf(i32 %139)
%141 = call i32 @munmap(i8* %53, i32 %140)
br label %142
142: ; preds = %129, %6
%143 = phi i32 [ 1, %6 ], [ 0, %129 ]
ret i32 %143
}