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

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
          int /*<<< orphan*/);
int /*<<< orphan*/ munmap(int *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncmp(char *, char *, int);
int strtoul(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int memfd, i;
  __u32 addr = 0;
  __u32 len = 0x01000000;
  __u32 randval;
  __u32 *memspace;
  if (argc > 3 || (argc >= 2 && !strncmp(argv[1], "--help", 6))) {
    printf("Randomizes all or part of TL880 registers (careful!!!)\n");
    printf("Usage: %s [addr [len]]\n", argv[0]);
    return -1;
  }
  if (argc >= 2) {
    addr = strtoul(argv[1], NULL, 16);
  }
  if (argc == 3) {
    len = strtoul(argv[2], NULL, 16);
  }
  addr &= 0xfffffffc;
  len &= 0xfffffffc;
  if (addr >= 0x0100000) {
    addr = 0;
  }
  if (addr + len >= 0x0100000) {
    len = 0x0100000 - addr;
  }
  if ((memfd = open("/dev/tl880/reg0", O_RDWR)) < 0) {
    perror("Unable to open /dev/tl880/reg0");
    return -1;
  }
  printf("Mapping memory space\n");
  if (!(memspace = mmap(0, 0x01000000, PROT_READ | PROT_WRITE, MAP_SHARED,
                        memfd, 0))) {
    perror("Failed to mmap region 1 (mem)");
    close(memfd);
    return -1;
  }
  printf("Writing random values\n");
  srand(time(0));
  for (i = addr; i < addr + len; i += 4) {
    randval = rand();
    if (i % 64 == 0) {
      fprintf(stderr, "u__u32 mem[%x] = %08x\r", i, randval);
    }
    memspace[i / 4] = randval;
  }
  fprintf(stderr, "\n");
  printf("Unmapping memory space\n");
  munmap(memspace, 0x01000000);
  close(memfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1000000,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jg     121a <main+0x5a>
cmpl   $0x2,-0x8(%rbp)
jl     1249 <main+0x89>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1249 <main+0x89>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    145b <main+0x29b>
cmpl   $0x2,-0x8(%rbp)
jl     126c <main+0xac>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10d0 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    128f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10d0 <strtoul@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xfffffffc,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
and    $0xfffffffc,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x100000,-0x1c(%rbp)
jl     12b5 <main+0xf5>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    $0x100000,%eax
jl     12d1 <main+0x111>
mov    $0x100000,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
lea    0xd85(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    130a <main+0x14a>
lea    0xd5e(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    145b <main+0x29b>
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edx
mov    0x2c98(%rip),%rax
or     (%rax),%edx
mov    0x2cb7(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x1000000,%esi
mov    %r9d,%edi
call   1040 <mmap@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1375 <main+0x1b5>
lea    0xd30(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    145b <main+0x29b>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    1419 <main+0x259>
mov    $0x0,%al
call   10e0 <rand@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13e3 <main+0x223>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xce5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x3c(%rbp),%edx
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    1397 <main+0x1d7>
mov    0x2ba8(%rip),%rax
mov    (%rax),%edi
lea    0xc14(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1000000,%esi
call   10a0 <munmap@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x3,%edi
jle    120a <main+0x3a>
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
mov    (%r14),%rsi
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%eax
jmp    13a6 <main+0x1d6>
mov    %edi,%ebp
cmp    $0x2,%edi
jl     126d <main+0x9d>
mov    0x8(%r14),%rdi
lea    0xde4(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11e3 <main+0x13>
mov    0x8(%r14),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x10,%edx
call   10e0 <strtoul@plt>
mov    %eax,%r15d
and    $0xfffffffc,%r15d
mov    $0x1000000,%eax
cmp    $0x3,%ebp
jne    1260 <main+0x90>
mov    0x10(%r14),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10e0 <strtoul@plt>
and    $0xfffffffc,%eax
cmp    $0x100000,%r15d
cmovl  %r15d,%ebx
jmp    1274 <main+0xa4>
xor    %ebx,%ebx
mov    $0x1000000,%eax
lea    (%rbx,%rax,1),%ecx
mov    $0x100000,%r14d
sub    %ebx,%r14d
cmp    $0x100000,%ecx
cmovl  %eax,%r14d
mov    0x2d47(%rip),%rax
mov    (%rax),%esi
lea    0xd94(%rip),%rdi
call   10c0 <open@plt>
test   %eax,%eax
js     13b5 <main+0x1e5>
mov    %eax,%ebp
lea    0xdc3(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d3c(%rip),%rax
mov    0x2cfd(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d1a(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x1000000,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
test   %rax,%rax
je     13c8 <main+0x1f8>
mov    %rax,%r13
mov    %ebp,0x4(%rsp)
lea    0xd8f(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
test   %r14d,%r14d
jle    136b <main+0x19b>
add    %ebx,%r14d
mov    0x2cad(%rip),%r15
lea    0xd3a(%rip),%r12
jmp    134a <main+0x17a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
sar    $0x2,%eax
cltq
mov    %ebp,0x0(%r13,%rax,4)
add    $0x4,%ebx
cmp    %r14d,%ebx
jge    136b <main+0x19b>
xor    %eax,%eax
call   10f0 <rand@plt>
mov    %eax,%ebp
test   $0x3c,%bl
jne    1330 <main+0x160>
mov    (%r15),%edi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1330 <main+0x160>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
lea    0xca2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xd15(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    $0x1000000,%esi
call   10b0 <munmap@plt>
mov    0x4(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc63(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%eax
jmp    13a6 <main+0x1d6>
lea    0xc6f(%rip),%rdi
call   10d0 <perror@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    $0xffffffff,%eax
jmp    13a6 <main+0x1d6>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [56 x i8] c"Randomizes all or part of TL880 registers (careful!!!)\0A\00"
@.str.2 = [24 x i8] c"Usage: %s [addr [len]]\0A\00"
@.str.3 = [16 x i8] c"/dev/tl880/reg0\00"
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"Unable to open /dev/tl880/reg0\00"
@.str.5 = [22 x i8] c"Mapping memory space\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [30 x i8] c"Failed to mmap region 1 (mem)\00"
@.str.7 = [23 x i8] c"Writing random values\0A\00"
@stderr = global i32 0
@.str.8 = [23 x i8] c"u__u32 mem[%x] = %08x\0D\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [24 x i8] c"Unmapping memory space\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 16777216, i32* %9
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 3
br i1 %13, label %23, label %14
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 2
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%22 = icmp ne i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %17, %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %27)
store i32 -1, i32* %3
br label %119
29: ; preds = %17, %14
%30 = load i32, i32* %4
%31 = icmp sge i32 %30, 2
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strtoul(i8* %35, i32* null, i32 16)
store i32 %36, i32* %8
br label %37
37: ; preds = %32, %29
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 3
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @strtoul(i8* %43, i32* null, i32 16)
store i32 %44, i32* %9
br label %45
45: ; preds = %40, %37
%46 = load i32, i32* %8
%47 = and i32 %46, -4
store i32 %47, i32* %8
%48 = load i32, i32* %9
%49 = and i32 %48, -4
store i32 %49, i32* %9
%50 = load i32, i32* %8
%51 = icmp sge i32 %50, 1048576
br i1 %51, label %52, label %53
52: ; preds = %45
store i32 0, i32* %8
br label %53
53: ; preds = %52, %45
%54 = load i32, i32* %8
%55 = load i32, i32* %9
%56 = add nsw i32 %54, %55
%57 = icmp sge i32 %56, 1048576
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = load i32, i32* %8
%60 = sub nsw i32 1048576, %59
store i32 %60, i32* %9
br label %61
61: ; preds = %58, %53
%62 = load i32, i32* @O_RDWR
%63 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %62)
store i32 %63, i32* %6
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %119
67: ; preds = %61
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%69 = load i32, i32* @PROT_READ
%70 = load i32, i32* @PROT_WRITE
%71 = or i32 %69, %70
%72 = load i32, i32* @MAP_SHARED
%73 = load i32, i32* %6
%74 = call i32* @mmap(i32 0, i32 16777216, i32 %71, i32 %72, i32 %73, i32 0)
store i32* %74, i32** %11
%75 = icmp ne i32* %74, null
br i1 %75, label %80, label %76
76: ; preds = %67
%77 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* %6
%79 = call i32 @close(i32 %78)
store i32 -1, i32* %3
br label %119
80: ; preds = %67
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%82 = call i32 @time(i32 0)
%83 = call i32 @srand(i32 %82)
%84 = load i32, i32* %8
store i32 %84, i32* %7
br label %85
85: ; preds = %108, %80
%86 = load i32, i32* %7
%87 = load i32, i32* %8
%88 = load i32, i32* %9
%89 = add nsw i32 %87, %88
%90 = icmp slt i32 %86, %89
br i1 %90, label %91, label %111
91: ; preds = %85
%92 = call i32 (...) @rand()
store i32 %92, i32* %10
%93 = load i32, i32* %7
%94 = srem i32 %93, 64
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %101
96: ; preds = %91
%97 = load i32, i32* @stderr
%98 = load i32, i32* %7
%99 = load i32, i32* %10
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %98, i32 %99)
br label %101
101: ; preds = %96, %91
%102 = load i32, i32* %10
%103 = load i32*, i32** %11
%104 = load i32, i32* %7
%105 = sdiv i32 %104, 4
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i32, i32* %103, i64 %106
store i32 %102, i32* %107
br label %108
108: ; preds = %101
%109 = load i32, i32* %7
%110 = add nsw i32 %109, 4
store i32 %110, i32* %7
br label %85
111: ; preds = %85
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%115 = load i32*, i32** %11
%116 = call i32 @munmap(i32* %115, i32 16777216)
%117 = load i32, i32* %6
%118 = call i32 @close(i32 %117)
store i32 0, i32* %3
br label %119
119: ; preds = %111, %76, %65, %23
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.2 = [24 x i8] c"Usage: %s [addr [len]]\0A\00"
@.str.3 = [16 x i8] c"/dev/tl880/reg0\00"
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"Unable to open /dev/tl880/reg0\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [30 x i8] c"Failed to mmap region 1 (mem)\00"
@stderr = global i32 0
@.str.8 = [23 x i8] c"u__u32 mem[%x] = %08x\0D\00"
@.str.9 = [2 x i8] c"\0A\00"
@str = [21 x i8] c"Mapping memory space\00"
@str.11 = [22 x i8] c"Writing random values\00"
@str.12 = [23 x i8] c"Unmapping memory space\00"
@str.13 = [55 x i8] c"Randomizes all or part of TL880 registers (careful!!!)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 3
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %29
6: ; preds = %4
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %6, %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.13, i64 0, i64 0))
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %78
15: ; preds = %6
%16 = load i8*, i8** %7
%17 = tail call i32 @strtoul(i8* nocapture %16, i32* null, i32 16)
%18 = and i32 %17, -4
%19 = icmp eq i32 %0, 3
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32 @strtoul(i8* nocapture %22, i32* null, i32 16)
%24 = and i32 %23, -4
br label %25
25: ; preds = %20, %15
%26 = phi i32 [ %24, %20 ], [ 16777216, %15 ]
%27 = icmp sgt i32 %18, 1048575
%28 = select i1 %27, i32 0, i32 %18
br label %29
29: ; preds = %25, %4
%30 = phi i32 [ 16777216, %4 ], [ %26, %25 ]
%31 = phi i32 [ 0, %4 ], [ %28, %25 ]
%32 = add nsw i32 %31, %30
%33 = icmp sgt i32 %32, 1048575
%34 = sub nsw i32 1048576, %31
%35 = select i1 %33, i32 %34, i32 %30
%36 = load i32, i32* @O_RDWR
%37 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %29
%40 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %78
41: ; preds = %29
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%43 = load i32, i32* @PROT_READ
%44 = load i32, i32* @PROT_WRITE
%45 = or i32 %44, %43
%46 = load i32, i32* @MAP_SHARED
%47 = tail call i32* @mmap(i32 0, i32 16777216, i32 %45, i32 %46, i32 %37, i32 0)
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %52
49: ; preds = %41
%50 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%51 = tail call i32 @close(i32 %37)
br label %78
52: ; preds = %41
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%54 = tail call i32 @time(i32 0)
%55 = tail call i32 @srand(i32 %54)
%56 = add nsw i32 %35, %31
%57 = icmp sgt i32 %35, 0
br i1 %57, label %58, label %72
58: ; preds = %52, %66
%59 = phi i32 [ %70, %66 ], [ %31, %52 ]
%60 = tail call i32 (...) @rand()
%61 = and i32 %59, 60
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = load i32, i32* @stderr
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %59, i32 %60)
br label %66
66: ; preds = %63, %58
%67 = sdiv i32 %59, 4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %47, i64 %68
store i32 %60, i32* %69
%70 = add nsw i32 %59, 4
%71 = icmp slt i32 %70, %56
br i1 %71, label %58, label %72
72: ; preds = %66, %52
%73 = load i32, i32* @stderr
%74 = tail call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0))
%76 = tail call i32 @munmap(i32* %47, i32 16777216)
%77 = tail call i32 @close(i32 %37)
br label %78
78: ; preds = %72, %49, %39, %11
%79 = phi i32 [ -1, %11 ], [ -1, %39 ], [ 0, %72 ], [ -1, %49 ]
ret i32 %79
}