#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 */

/* Variables and functions */
int MAP_ANONYMOUS;
char *MAP_FAILED;
int MAP_GROWSDOWN;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ errno;
char *mmap(char *, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, int);
int /*<<< orphan*/ test_daemon();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int main(int argc, char **argv) {
  char *start_addr, *addr1, *addr2;
  test_init(argc, argv);
  start_addr = mmap(NULL, 4096 * 10, PROT_READ | PROT_WRITE,
                    MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
  if (start_addr == MAP_FAILED) {
    test_msg("ERR: %s:%d: "
             "Can't mal a new region"
             " (errno = %d (%m))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/kawamuray/criu/refs/heads/master/test/"
             "zdtm/live/static/grow_map03.c",
             24, errno);
    return 1;
  }
  munmap(start_addr, 4096 * 10);
  addr1 = mmap(start_addr + 4096 * 5, 4096, PROT_READ | PROT_WRITE,
               MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0);
  addr2 = mmap(start_addr + 4096 * 3, 4096, PROT_READ | PROT_WRITE,
               MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0);
  test_msg("ERR: %s:%d: "
           "%p %p\n"
           " (errno = %d (%m))\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/kawamuray/criu/refs/heads/master/test/"
           "zdtm/live/static/grow_map03.c",
           32, addr1, addr2, errno);
  test_daemon();
  test_waitsig();
  test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
mov    0x2e36(%rip),%rax
or     (%rax),%edx
mov    0x2e45(%rip),%rax
mov    (%rax),%ecx
mov    0x2e1c(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2dec(%rip),%rcx
cmp    (%rcx),%rax
jne    1204 <main+0xa4>
mov    0x2df4(%rip),%rax
mov    (%rax),%ecx
lea    0xe1b(%rip),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x18,%edx
mov    $0x0,%al
call   1060 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ff <main+0x19f>
mov    -0x18(%rbp),%rdi
mov    $0xa000,%esi
call   1080 <munmap@plt>
mov    -0x18(%rbp),%rdi
add    $0x5000,%rdi
mov    0x2dd4(%rip),%rax
mov    (%rax),%edx
mov    0x2d9b(%rip),%rax
or     (%rax),%edx
mov    0x2daa(%rip),%rax
mov    (%rax),%ecx
mov    0x2d81(%rip),%rax
or     (%rax),%ecx
mov    0x2d68(%rip),%rax
or     (%rax),%ecx
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x3000,%rdi
mov    0x2d85(%rip),%rax
mov    (%rax),%edx
mov    0x2d4c(%rip),%rax
or     (%rax),%edx
mov    0x2d5b(%rip),%rax
mov    (%rax),%ecx
mov    0x2d32(%rip),%rax
or     (%rax),%ecx
mov    0x2d19(%rip),%rax
or     (%rax),%ecx
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    0x2d11(%rip),%rax
mov    (%rax),%r9d
lea    0xe0b(%rip),%rdi
lea    0xd66(%rip),%rsi
mov    $0x20,%edx
mov    $0x0,%al
call   1060 <test_msg@plt>
mov    $0x0,%al
call   1050 <test_daemon@plt>
mov    $0x0,%al
call   1070 <test_waitsig@plt>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1030 <test_init@plt>
mov    0x2e81(%rip),%rbp
mov    0x2e4a(%rip),%r14
mov    (%r14),%edx
or     0x0(%rbp),%edx
mov    0x2e55(%rip),%r13
mov    0x2e2e(%rip),%r12
mov    (%r12),%ecx
or     0x0(%r13),%ecx
xor    %edi,%edi
mov    $0xa000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbx
mov    0x2dff(%rip),%rax
cmp    (%rax),%rbx
je     1282 <main+0x122>
mov    %rbx,%rdi
mov    $0xa000,%esi
call   1080 <munmap@plt>
mov    (%r14),%edx
or     0x0(%rbp),%edx
mov    (%r12),%ecx
or     0x0(%r13),%ecx
lea    0x5000(%rbx),%rdi
mov    0x2dc5(%rip),%rbp
or     0x0(%rbp),%ecx
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r15
add    $0x3000,%rbx
mov    (%r14),%edx
mov    0x2de3(%rip),%rax
or     (%rax),%edx
mov    (%r12),%ecx
or     0x0(%r13),%ecx
or     0x0(%rbp),%ecx
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    0x2d8f(%rip),%rcx
mov    (%rcx),%r9d
lea    0xe89(%rip),%rdi
lea    0xde4(%rip),%rsi
mov    $0x20,%edx
mov    %r15,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <test_msg@plt>
xor    %eax,%eax
call   1050 <test_daemon@plt>
xor    %eax,%eax
call   1070 <test_waitsig@plt>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1060 <test_msg@plt>
jmp    12aa <main+0x14a>
mov    0x2d47(%rip),%rax
mov    (%rax),%ecx
lea    0xd6e(%rip),%rdi
lea    0xd9d(%rip),%rsi
mov    $0x18,%edx
xor    %eax,%eax
call   1060 <test_msg@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str = [54 x i8] c"ERR: %s:%d: Can't mal a new region (errno = %d (%m))\0A\00"
@.str.1 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kawamuray/criu/refs/heads/master/test/zdtm/live/static/grow_map03.c\00"
@errno = global i32 0
@MAP_GROWSDOWN = global i32 0
@.str.2 = [38 x i8] c"ERR: %s:%d: %p %p\0A (errno = %d (%m))\0A\00"
@.str.3 = [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 i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @test_init(i32 %9, i8** %10)
%12 = load i32, i32* @PROT_READ
%13 = load i32, i32* @PROT_WRITE
%14 = or i32 %12, %13
%15 = load i32, i32* @MAP_ANONYMOUS
%16 = load i32, i32* @MAP_PRIVATE
%17 = or i32 %15, %16
%18 = call i8* @mmap(i8* null, i32 40960, i32 %14, i32 %17, i32 -1, i32 0)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = load i8*, i8** @MAP_FAILED
%21 = icmp eq i8* %19, %20
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* @errno
%24 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.1, i64 0, i64 0), i32 24, i32 %23)
store i32 1, i32* %3
br label %57
25: ; preds = %2
%26 = load i8*, i8** %6
%27 = call i32 @munmap(i8* %26, i32 40960)
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 20480
%30 = load i32, i32* @PROT_READ
%31 = load i32, i32* @PROT_WRITE
%32 = or i32 %30, %31
%33 = load i32, i32* @MAP_ANONYMOUS
%34 = load i32, i32* @MAP_PRIVATE
%35 = or i32 %33, %34
%36 = load i32, i32* @MAP_GROWSDOWN
%37 = or i32 %35, %36
%38 = call i8* @mmap(i8* %29, i32 4096, i32 %32, i32 %37, i32 -1, i32 0)
store i8* %38, i8** %7
%39 = load i8*, i8** %6
%40 = getelementptr inbounds i8, i8* %39, i64 12288
%41 = load i32, i32* @PROT_READ
%42 = load i32, i32* @PROT_WRITE
%43 = or i32 %41, %42
%44 = load i32, i32* @MAP_ANONYMOUS
%45 = load i32, i32* @MAP_PRIVATE
%46 = or i32 %44, %45
%47 = load i32, i32* @MAP_GROWSDOWN
%48 = or i32 %46, %47
%49 = call i8* @mmap(i8* %40, i32 4096, i32 %43, i32 %48, i32 -1, i32 0)
store i8* %49, i8** %8
%50 = load i8*, i8** %7
%51 = load i8*, i8** %8
%52 = load i32, i32* @errno
%53 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.1, i64 0, i64 0), i32 32, i8* %50, i8* %51, i32 %52)
%54 = call i32 (...) @test_daemon()
%55 = call i32 (...) @test_waitsig()
%56 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %57
57: ; preds = %25, %22
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str = [54 x i8] c"ERR: %s:%d: Can't mal a new region (errno = %d (%m))\0A\00"
@.str.1 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kawamuray/criu/refs/heads/master/test/zdtm/live/static/grow_map03.c\00"
@errno = global i32 0
@MAP_GROWSDOWN = global i32 0
@.str.2 = [38 x i8] c"ERR: %s:%d: %p %p\0A (errno = %d (%m))\0A\00"
@.str.3 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @test_init(i32 %0, i8** %1)
%4 = load i32, i32* @PROT_READ
%5 = load i32, i32* @PROT_WRITE
%6 = or i32 %5, %4
%7 = load i32, i32* @MAP_ANONYMOUS
%8 = load i32, i32* @MAP_PRIVATE
%9 = or i32 %8, %7
%10 = tail call i8* @mmap(i8* null, i32 40960, i32 %6, i32 %9, i32 -1, i32 0)
%11 = load i8*, i8** @MAP_FAILED
%12 = icmp eq i8* %10, %11
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @errno
%15 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.1, i64 0, i64 0), i32 24, i32 %14)
br label %43
16: ; preds = %2
%17 = tail call i32 @munmap(i8* %10, i32 40960)
%18 = getelementptr inbounds i8, i8* %10, i64 20480
%19 = load i32, i32* @PROT_READ
%20 = load i32, i32* @PROT_WRITE
%21 = or i32 %20, %19
%22 = load i32, i32* @MAP_ANONYMOUS
%23 = load i32, i32* @MAP_PRIVATE
%24 = or i32 %23, %22
%25 = load i32, i32* @MAP_GROWSDOWN
%26 = or i32 %24, %25
%27 = tail call i8* @mmap(i8* %18, i32 4096, i32 %21, i32 %26, i32 -1, i32 0)
%28 = getelementptr inbounds i8, i8* %10, i64 12288
%29 = load i32, i32* @PROT_READ
%30 = load i32, i32* @PROT_WRITE
%31 = or i32 %30, %29
%32 = load i32, i32* @MAP_ANONYMOUS
%33 = load i32, i32* @MAP_PRIVATE
%34 = or i32 %33, %32
%35 = load i32, i32* @MAP_GROWSDOWN
%36 = or i32 %34, %35
%37 = tail call i8* @mmap(i8* %28, i32 4096, i32 %31, i32 %36, i32 -1, i32 0)
%38 = load i32, i32* @errno
%39 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.1, i64 0, i64 0), i32 32, i8* %27, i8* %37, i32 %38)
%40 = tail call i32 (...) @test_daemon()
%41 = tail call i32 (...) @test_waitsig()
%42 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %16, %13
%44 = phi i32 [ 1, %13 ], [ 0, %16 ]
ret i32 %44
}