#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 */
struct timespec {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int MAP_ANON;
void *MAP_FAILED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _SC_PAGESIZE;
int /*<<< orphan*/ errno;
void *mmap(int /*<<< orphan*/ *, int, int, int, int /*<<< orphan*/,
           int /*<<< orphan*/);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int random();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
scalar_t__ sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ test_daemon();
scalar_t__ test_go();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  void *mem;
  int i, fail = 0;
  unsigned rover = 1;
  unsigned backup[16] = {};
  srand(time(NULL));
  test_init(argc, argv);
  mem = mmap(NULL, 16 * (unsigned int)(sysconf(_SC_PAGESIZE)),
             PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0);
  if (mem == MAP_FAILED)
    return 1;
  test_msg("mem %p backup %p\n", mem, backup);
  test_daemon();
  while (test_go()) {
    unsigned pfn;
    struct timespec req = {
        .tv_sec = 0,
        .tv_nsec = 100000,
    };
    pfn = random() % 16;
    *(unsigned *)(mem + pfn * (unsigned int)(sysconf(_SC_PAGESIZE))) = rover;
    backup[pfn] = rover;
    test_msg("t %u %u\n", pfn, rover);
    rover++;
    nanosleep(&req, NULL);
  }
  test_waitsig();
  test_msg("final rover %u\n", rover);
  for (i = 0; i < 16; i++)
    if (backup[i] !=
        *(unsigned *)(mem + i * (unsigned int)(sysconf(_SC_PAGESIZE)))) {
      test_msg("Page %u differs want %u has %u\n", i, backup[i],
               *(unsigned *)(mem + i * (unsigned int)(sysconf(_SC_PAGESIZE))));
      fail = 1;
    } else
      test_msg("Page %u matches %u\n", i, backup[i]);
  if (fail)
    test_msg("FAIL: %s:%d: "
             "Memory corruption\n"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/mem-touch.c",
             56, errno, strerror(errno));
  else
    test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    %eax,%esi
shl    $0x4,%esi
mov    0x2dbb(%rip),%rax
mov    (%rax),%edx
mov    0x2d82(%rip),%rax
or     (%rax),%edx
mov    0x2d69(%rip),%rax
mov    (%rax),%ecx
mov    0x2d68(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1040 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2d38(%rip),%rcx
cmp    (%rcx),%rax
jne    128d <main+0xbd>
movl   $0x1,-0x4(%rbp)
jmp    14de <main+0x30e>
mov    -0x18(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x0,%al
call   1050 <test_daemon@plt>
mov    $0x0,%al
call   10d0 <test_go@plt>
cmp    $0x0,%rax
je     135a <main+0x18a>
mov    0xe7e(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    $0x0,%al
call   10c0 <random@plt>
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x74(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    -0x90(%rbp),%ecx
mov    -0x8c(%rbp),%edx
mov    %rax,%rsi
mov    -0x88(%rbp),%rax
imul   %esi,%ecx
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,1)
mov    -0x24(%rbp),%ecx
mov    -0x74(%rbp),%eax
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x74(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
lea    -0x80(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <nanosleep@plt>
jmp    12aa <main+0xda>
mov    $0x0,%al
call   10a0 <test_waitsig@plt>
mov    -0x24(%rbp),%esi
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    147a <main+0x2aa>
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    -0xa4(%rbp),%edx
mov    -0xa0(%rbp),%rcx
mov    %rax,%rsi
mov    -0x94(%rbp),%eax
imul   %esi,%edx
mov    %edx,%edx
cmp    (%rcx,%rdx,1),%eax
je     144e <main+0x27e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0xb8(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    -0xbc(%rbp),%ecx
mov    -0xb8(%rbp),%esi
mov    -0xb4(%rbp),%edx
mov    %rax,%rdi
mov    -0xb0(%rbp),%rax
imul   %edi,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%ecx
lea    0xbf0(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
movl   $0x1,-0x20(%rbp)
jmp    1467 <main+0x297>
mov    -0x1c(%rbp),%esi
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edx
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
jmp    146c <main+0x29c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1379 <main+0x1a9>
cmpl   $0x0,-0x20(%rbp)
je     14c9 <main+0x2f9>
mov    0x2b45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc0(%rbp)
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xc0(%rbp),%ecx
mov    %eax,%r8d
lea    0xbae(%rip),%rdi
lea    0xbda(%rip),%rsi
mov    $0x38,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
jmp    14d7 <main+0x307>
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <test_init@plt>
mov    0x2dd7(%rip),%r13
mov    0x0(%r13),%edi
call   10d0 <sysconf@plt>
shl    $0x4,%eax
mov    0x2ddc(%rip),%rcx
mov    0x2da5(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d8a(%rip),%rsi
mov    0x2d8b(%rip),%rcx
mov    (%rcx),%ecx
or     (%rsi),%ecx
xor    %edi,%edi
mov    %eax,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r12
mov    0x2d5e(%rip),%rax
cmp    (%rax),%r12
je     13c1 <main+0x201>
lea    0xd9e(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <test_msg@plt>
xor    %eax,%eax
call   1050 <test_daemon@plt>
xor    %eax,%eax
call   10c0 <test_go@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     12fa <main+0x13a>
lea    0xd82(%rip),%r14
lea    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movq   $0x186a0,0x8(%rsp)
xor    %eax,%eax
call   10b0 <random@plt>
mov    %eax,%ebx
lea    0xf(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffff0,%eax
sub    %eax,%ebx
mov    0x0(%r13),%edi
call   10d0 <sysconf@plt>
imul   %ebx,%eax
mov    %ebp,(%r12,%rax,1)
mov    %ebp,0x10(%rsp,%rbx,4)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <test_msg@plt>
add    $0x1,%ebp
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <nanosleep@plt>
xor    %eax,%eax
call   10c0 <test_go@plt>
test   %rax,%rax
jne    12a0 <main+0xe0>
xor    %eax,%eax
call   1090 <test_waitsig@plt>
lea    0xd13(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <test_msg@plt>
mov    $0x1,%r14b
lea    0xd30(%rip),%r15
xor    %ebp,%ebp
mov    %r14d,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp,%rbp,4),%r14d
mov    0x0(%r13),%edi
call   10d0 <sysconf@plt>
imul   %ebp,%eax
mov    0x10(%rsp,%rbp,4),%ebx
cmp    (%r12,%rax,1),%r14d
jne    1370 <main+0x1b0>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <test_msg@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
jne    1330 <main+0x170>
jmp    13a8 <main+0x1e8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13),%edi
call   10d0 <sysconf@plt>
imul   %ebp,%eax
mov    (%r12,%rax,1),%ecx
xor    %r14d,%r14d
lea    0xca1(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <test_msg@plt>
lea    0x1(%rbp),%rax
cmp    $0xf,%rbp
mov    %rax,%rbp
jne    131d <main+0x15d>
jmp    13c8 <main+0x208>
testb  $0x1,0x4(%rsp)
je     13c8 <main+0x208>
lea    0xd82(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <test_msg@plt>
jmp    13f9 <main+0x239>
mov    $0x1,%ebx
jmp    13f9 <main+0x239>
mov    0x2c01(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xc80(%rip),%rdi
lea    0xcac(%rip),%rsi
xor    %ebx,%ebx
mov    $0x38,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <test_msg@plt>
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MAP_FAILED = global i8* null
@.str = [18 x i8] c"mem %p backup %p\0A\00"
@__const.main.req = %struct.timespec { i32 100000, i32 0 }
@.str.1 = [9 x i8] c"t %u %u\0A\00"
@.str.2 = [16 x i8] c"final rover %u\0A\00"
@.str.3 = [32 x i8] c"Page %u differs want %u has %u\0A\00"
@.str.4 = [20 x i8] c"Page %u matches %u\0A\00"
@.str.5 = [51 x i8] c"FAIL: %s:%d: Memory corruption\0A (errno = %d (%s))\0A\00"
@.str.6 = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/mem-touch.c\00"
@errno = global i32 0
@.str.7 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [16 x i32]
%11 = alloca i32
%12 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 1, i32* %9
%13 = bitcast [16 x i32]* %10 to i8*
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @test_init(i32 %16, i8** %17)
%19 = load i32, i32* @_SC_PAGESIZE
%20 = call i64 @sysconf(i32 %19)
%21 = trunc i64 %20 to i32
%22 = mul i32 16, %21
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @PROT_WRITE
%25 = or i32 %23, %24
%26 = load i32, i32* @MAP_PRIVATE
%27 = load i32, i32* @MAP_ANON
%28 = or i32 %26, %27
%29 = call i8* @mmap(i32* null, i32 %22, i32 %25, i32 %28, i32 0, i32 0)
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = load i8*, i8** @MAP_FAILED
%32 = icmp eq i8* %30, %31
br i1 %32, label %33, label %34
33: ; preds = %2
store i32 1, i32* %3
br label %128
34: ; preds = %2
%35 = load i8*, i8** %6
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 0
%37 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %35, i32* %36)
%38 = call i32 (...) @test_daemon()
br label %39
39: ; preds = %42, %34
%40 = call i64 (...) @test_go()
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %66
42: ; preds = %39
%43 = bitcast %struct.timespec* %12 to i8*
%44 = call i32 (...) @random()
%45 = srem i32 %44, 16
store i32 %45, i32* %11
%46 = load i32, i32* %9
%47 = load i8*, i8** %6
%48 = load i32, i32* %11
%49 = load i32, i32* @_SC_PAGESIZE
%50 = call i64 @sysconf(i32 %49)
%51 = trunc i64 %50 to i32
%52 = mul i32 %48, %51
%53 = zext i32 %52 to i64
%54 = getelementptr i8, i8* %47, i64 %53
%55 = bitcast i8* %54 to i32*
store i32 %46, i32* %55
%56 = load i32, i32* %9
%57 = load i32, i32* %11
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %58
store i32 %56, i32* %59
%60 = load i32, i32* %11
%61 = load i32, i32* %9
%62 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %61)
%63 = load i32, i32* %9
%64 = add i32 %63, 1
store i32 %64, i32* %9
%65 = call i32 @nanosleep(%struct.timespec* %12, i32* null)
br label %39
66: ; preds = %39
%67 = call i32 (...) @test_waitsig()
%68 = load i32, i32* %9
%69 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %68)
store i32 0, i32* %7
br label %70
70: ; preds = %114, %66
%71 = load i32, i32* %7
%72 = icmp slt i32 %71, 16
br i1 %72, label %73, label %117
73: ; preds = %70
%74 = load i32, i32* %7
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = load i8*, i8** %6
%79 = load i32, i32* %7
%80 = load i32, i32* @_SC_PAGESIZE
%81 = call i64 @sysconf(i32 %80)
%82 = trunc i64 %81 to i32
%83 = mul i32 %79, %82
%84 = zext i32 %83 to i64
%85 = getelementptr i8, i8* %78, i64 %84
%86 = bitcast i8* %85 to i32*
%87 = load i32, i32* %86
%88 = icmp ne i32 %77, %87
br i1 %88, label %89, label %106
89: ; preds = %73
%90 = load i32, i32* %7
%91 = load i32, i32* %7
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %92
%94 = load i32, i32* %93
%95 = load i8*, i8** %6
%96 = load i32, i32* %7
%97 = load i32, i32* @_SC_PAGESIZE
%98 = call i64 @sysconf(i32 %97)
%99 = trunc i64 %98 to i32
%100 = mul i32 %96, %99
%101 = zext i32 %100 to i64
%102 = getelementptr i8, i8* %95, i64 %101
%103 = bitcast i8* %102 to i32*
%104 = load i32, i32* %103
%105 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %90, i32 %94, i32 %104)
store i32 1, i32* %8
br label %113
106: ; preds = %73
%107 = load i32, i32* %7
%108 = load i32, i32* %7
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %109
%111 = load i32, i32* %110
%112 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %107, i32 %111)
br label %113
113: ; preds = %106, %89
br label %114
114: ; preds = %113
%115 = load i32, i32* %7
%116 = add nsw i32 %115, 1
store i32 %116, i32* %7
br label %70
117: ; preds = %70
%118 = load i32, i32* %8
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %117
%121 = load i32, i32* @errno
%122 = load i32, i32* @errno
%123 = call i32 @strerror(i32 %122)
%124 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.6, i64 0, i64 0), i32 56, i32 %121, i32 %123)
br label %127
125: ; preds = %117
%126 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %127
127: ; preds = %125, %120
store i32 0, i32* %3
br label %128
128: ; preds = %127, %33
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MAP_FAILED = global i8* null
@.str = [18 x i8] c"mem %p backup %p\0A\00"
@.str.1 = [9 x i8] c"t %u %u\0A\00"
@.str.2 = [16 x i8] c"final rover %u\0A\00"
@.str.3 = [32 x i8] c"Page %u differs want %u has %u\0A\00"
@.str.4 = [20 x i8] c"Page %u matches %u\0A\00"
@.str.5 = [51 x i8] c"FAIL: %s:%d: Memory corruption\0A (errno = %d (%s))\0A\00"
@.str.6 = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/mem-touch.c\00"
@errno = global i32 0
@.str.7 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [16 x i32]
%4 = alloca i64
%5 = bitcast i64* %4 to %struct.timespec*
%6 = bitcast [16 x i32]* %3 to i8*
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = tail call i32 @test_init(i32 %0, i8** %1)
%10 = load i32, i32* @_SC_PAGESIZE
%11 = tail call i64 @sysconf(i32 %10)
%12 = trunc i64 %11 to i32
%13 = shl i32 %12, 4
%14 = load i32, i32* @PROT_READ
%15 = load i32, i32* @PROT_WRITE
%16 = or i32 %15, %14
%17 = load i32, i32* @MAP_PRIVATE
%18 = load i32, i32* @MAP_ANON
%19 = or i32 %18, %17
%20 = tail call i8* @mmap(i32* null, i32 %13, i32 %16, i32 %19, i32 0, i32 0)
%21 = load i8*, i8** @MAP_FAILED
%22 = icmp eq i8* %20, %21
br i1 %22, label %93, label %23
23: ; preds = %2
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%25 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %20, i32* %24)
%26 = call i32 (...) @test_daemon()
%27 = call i64 (...) @test_go()
%28 = icmp eq i64 %27, 0
br i1 %28, label %49, label %29
29: ; preds = %23
%30 = bitcast i64* %4 to i8*
br label %31
31: ; preds = %29, %31
%32 = phi i32 [ 1, %29 ], [ %45, %31 ]
store i64 100000, i64* %4
%33 = call i32 (...) @random()
%34 = srem i32 %33, 16
%35 = load i32, i32* @_SC_PAGESIZE
%36 = call i64 @sysconf(i32 %35)
%37 = trunc i64 %36 to i32
%38 = mul i32 %34, %37
%39 = zext i32 %38 to i64
%40 = getelementptr i8, i8* %20, i64 %39
%41 = bitcast i8* %40 to i32*
store i32 %32, i32* %41
%42 = zext i32 %34 to i64
%43 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %42
store i32 %32, i32* %43
%44 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %32)
%45 = add i32 %32, 1
%46 = call i32 @nanosleep(%struct.timespec* %5, i32* null)
%47 = call i64 (...) @test_go()
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %31
49: ; preds = %31, %23
%50 = phi i32 [ 1, %23 ], [ %45, %31 ]
%51 = call i32 (...) @test_waitsig()
%52 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %50)
br label %53
53: ; preds = %74, %49
%54 = phi i64 [ %84, %74 ], [ 0, %49 ]
%55 = phi i1 [ false, %74 ], [ true, %49 ]
br label %56
56: ; preds = %53, %70
%57 = phi i64 [ %72, %70 ], [ %54, %53 ]
%58 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = load i32, i32* @_SC_PAGESIZE
%61 = call i64 @sysconf(i32 %60)
%62 = mul i64 %57, %61
%63 = and i64 %62, 4294967295
%64 = getelementptr i8, i8* %20, i64 %63
%65 = bitcast i8* %64 to i32*
%66 = load i32, i32* %65
%67 = icmp eq i32 %59, %66
%68 = trunc i64 %57 to i32
%69 = load i32, i32* %58
br i1 %67, label %70, label %74
70: ; preds = %56
%71 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %68, i32 %69)
%72 = add nuw nsw i64 %57, 1
%73 = icmp eq i64 %72, 16
br i1 %73, label %86, label %56
74: ; preds = %56
%75 = trunc i64 %57 to i32
%76 = load i32, i32* @_SC_PAGESIZE
%77 = call i64 @sysconf(i32 %76)
%78 = mul i64 %57, %77
%79 = and i64 %78, 4294967295
%80 = getelementptr i8, i8* %20, i64 %79
%81 = bitcast i8* %80 to i32*
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %75, i32 %69, i32 %82)
%84 = add nuw nsw i64 %57, 1
%85 = icmp eq i64 %84, 16
br i1 %85, label %87, label %53
86: ; preds = %70
br i1 %55, label %91, label %87
87: ; preds = %74, %86
%88 = load i32, i32* @errno
%89 = call i32 @strerror(i32 %88)
%90 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.6, i64 0, i64 0), i32 56, i32 %88, i32 %89)
br label %93
91: ; preds = %86
%92 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %93
93: ; preds = %87, %91, %2
%94 = phi i32 [ 1, %2 ], [ 0, %91 ], [ 0, %87 ]
ret i32 %94
}