#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 /*<<< orphan*/ PR_GET_DUMPABLE;
scalar_t__ errno;
int prctl(int /*<<< orphan*/);
int /*<<< orphan*/ strerror(scalar_t__);
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) {
  int save_dumpable;
  int dumpable;
  test_init(argc, argv);
  save_dumpable = prctl(PR_GET_DUMPABLE);
  if (save_dumpable < 0) {
    test_msg("ERR: %s:%d: "
             "error getting prctl(PR_GET_DUMPABLE) before dump"
             " (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/dumpable01.c",
             20, errno, strerror(errno));
    return 1;
  }
  test_daemon();
  test_waitsig();
  dumpable = prctl(PR_GET_DUMPABLE);
  if (dumpable < 0) {
    test_msg("ERR: %s:%d: "
             "error getting prctl(PR_GET_DUMPABLE) after restore"
             " (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/dumpable01.c",
             33, errno, strerror(errno));
    return 1;
  }
  if (dumpable != save_dumpable) {
    errno = 0;
    test_msg("FAIL: %s:%d: "
             "dumpable flag was not preserved over migration"
             " (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/dumpable01.c",
             42, errno, strerror(errno));
    return 1;
  }
  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    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1070 <prctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11e7 <main+0x87>
mov    0x2e34(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e26(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,%r8d
lea    0xe38(%rip),%rdi
lea    0xe81(%rip),%rsi
mov    $0x14,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d3 <main+0x173>
mov    $0x0,%al
call   1040 <test_daemon@plt>
mov    $0x0,%al
call   1060 <test_waitsig@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1070 <prctl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    125a <main+0xfa>
mov    0x2dc1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    -0x28(%rbp),%rcx
mov    %eax,%r8d
lea    0xebc(%rip),%rdi
lea    0xe0e(%rip),%rsi
mov    $0x21,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d3 <main+0x173>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     12be <main+0x15e>
mov    0x2d6b(%rip),%rax
movq   $0x0,(%rax)
mov    0x2d5d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    -0x30(%rbp),%rcx
mov    %eax,%r8d
lea    0xeaa(%rip),%rdi
lea    0xdaa(%rip),%rsi
mov    $0x2a,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d3 <main+0x173>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1050 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
call   1030 <test_init@plt>
mov    0x2e78(%rip),%r14
mov    (%r14),%edi
call   1070 <prctl@plt>
test   %eax,%eax
js     11b1 <main+0x51>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <test_daemon@plt>
xor    %eax,%eax
call   1060 <test_waitsig@plt>
mov    (%r14),%edi
call   1070 <prctl@plt>
test   %eax,%eax
js     11d8 <main+0x78>
cmp    %ebx,%eax
jne    1202 <main+0xa2>
lea    0xff5(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <test_msg@plt>
jmp    123b <main+0xdb>
mov    0x2e20(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1080 <strerror@plt>
lea    0xe36(%rip),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x14,%edx
jmp    11fd <main+0x9d>
mov    0x2df9(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1080 <strerror@plt>
lea    0xf06(%rip),%rdi
lea    0xe58(%rip),%rsi
mov    $0x21,%edx
mov    %rbx,%rcx
jmp    122c <main+0xcc>
mov    0x2dcf(%rip),%rax
movq   $0x0,(%rax)
xor    %edi,%edi
call   1080 <strerror@plt>
lea    0xf2b(%rip),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x2a,%edx
xor    %ecx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <test_msg@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@PR_GET_DUMPABLE = global i32 0
@.str = [80 x i8] c"ERR: %s:%d: error getting prctl(PR_GET_DUMPABLE) before dump (errno = %d (%s))\0A\00"
@.str.1 = [167 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/dumpable01.c\00"
@errno = global i64 0
@.str.2 = [82 x i8] c"ERR: %s:%d: error getting prctl(PR_GET_DUMPABLE) after restore (errno = %d (%s))\0A\00"
@.str.3 = [79 x i8] c"FAIL: %s:%d: dumpable flag was not preserved over migration (errno = %d (%s))\0A\00"
@.str.4 = [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 i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @test_init(i32 %8, i8** %9)
%11 = load i32, i32* @PR_GET_DUMPABLE
%12 = call i32 @prctl(i32 %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i64, i64* @errno
%17 = load i64, i64* @errno
%18 = call i32 @strerror(i64 %17)
%19 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 20, i64 %16, i32 %18)
store i32 1, i32* %3
br label %43
20: ; preds = %2
%21 = call i32 (...) @test_daemon()
%22 = call i32 (...) @test_waitsig()
%23 = load i32, i32* @PR_GET_DUMPABLE
%24 = call i32 @prctl(i32 %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %20
%28 = load i64, i64* @errno
%29 = load i64, i64* @errno
%30 = call i32 @strerror(i64 %29)
%31 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 33, i64 %28, i32 %30)
store i32 1, i32* %3
br label %43
32: ; preds = %20
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %41
36: ; preds = %32
store i64 0, i64* @errno
%37 = load i64, i64* @errno
%38 = load i64, i64* @errno
%39 = call i32 @strerror(i64 %38)
%40 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 42, i64 %37, i32 %39)
store i32 1, i32* %3
br label %43
41: ; preds = %32
%42 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %43
43: ; preds = %41, %36, %27, %15
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@PR_GET_DUMPABLE = global i32 0
@.str = [80 x i8] c"ERR: %s:%d: error getting prctl(PR_GET_DUMPABLE) before dump (errno = %d (%s))\0A\00"
@.str.1 = [167 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/dumpable01.c\00"
@errno = global i64 0
@.str.2 = [82 x i8] c"ERR: %s:%d: error getting prctl(PR_GET_DUMPABLE) after restore (errno = %d (%s))\0A\00"
@.str.3 = [79 x i8] c"FAIL: %s:%d: dumpable flag was not preserved over migration (errno = %d (%s))\0A\00"
@.str.4 = [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* @PR_GET_DUMPABLE
%5 = tail call i32 @prctl(i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i64, i64* @errno
%9 = tail call i32 @strerror(i64 %8)
%10 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 20, i64 %8, i32 %9)
br label %28
11: ; preds = %2
%12 = tail call i32 (...) @test_daemon()
%13 = tail call i32 (...) @test_waitsig()
%14 = load i32, i32* @PR_GET_DUMPABLE
%15 = tail call i32 @prctl(i32 %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i64, i64* @errno
%19 = tail call i32 @strerror(i64 %18)
%20 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 33, i64 %18, i32 %19)
br label %28
21: ; preds = %11
%22 = icmp eq i32 %15, %5
br i1 %22, label %26, label %23
23: ; preds = %21
store i64 0, i64* @errno
%24 = tail call i32 @strerror(i64 0)
%25 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 42, i64 0, i32 %24)
br label %28
26: ; preds = %21
%27 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %23, %17, %7
%29 = phi i32 [ 1, %7 ], [ 1, %17 ], [ 1, %23 ], [ 0, %26 ]
ret i32 %29
}