#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 inotify_event {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ IN_ALL_EVENTS;
int /*<<< orphan*/ IN_NONBLOCK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PATH_MAX;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int inotify_add_watch(int, char *, int /*<<< orphan*/);
int inotify_init1(int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
scalar_t__ read(int, 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 buf[((sizeof(struct inotify_event) + PATH_MAX))];
  int fd, wd;
  test_init(argc, argv);
  fd = inotify_init1(IN_NONBLOCK);
  if (fd < 0) {
    test_msg("FAIL: %s:%d: "
             "inotify_init failed"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/inotify00.c",
             32, errno);
    exit(1);
  }
  wd = 0;
  wd |= inotify_add_watch(fd, "/", IN_ALL_EVENTS);
  if (wd < 0) {
    test_msg("FAIL: %s:%d: "
             "inotify_add_watch failed"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/inotify00.c",
             39, errno);
    exit(1);
  }
  test_daemon();
  test_waitsig();
  wd = open("/", O_RDONLY);
  if (read(fd, buf, sizeof(buf)) > 0) {
    test_msg("PASS\n");
  } else {
    test_msg("FAIL: %s:%d: "
             "No events in queue"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/inotify00.c",
             50, errno);
    exit(1);
  }
  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)
mov    0x2e43(%rip),%rax
movslq (%rax),%rdx
mov    %rdx,%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
add    $0x13,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   10b0 <inotify_init1@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    122f <main+0x9f>
mov    0x2dbf(%rip),%rax
mov    (%rax),%ecx
lea    0xdee(%rip),%rdi
lea    0xe16(%rip),%rsi
mov    $0x20,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2d80(%rip),%rax
mov    (%rax),%edx
lea    0xe80(%rip),%rsi
call   1080 <inotify_add_watch@plt>
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    128b <main+0xfb>
mov    0x2d63(%rip),%rax
mov    (%rax),%ecx
lea    0xe5d(%rip),%rdi
lea    0xdba(%rip),%rsi
mov    $0x27,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1040 <test_daemon@plt>
mov    $0x0,%al
call   1070 <test_waitsig@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
lea    0xe20(%rip),%rdi
call   1090 <open@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    %eax,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jle    12e2 <main+0x152>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <test_msg@plt>
jmp    130f <main+0x17f>
mov    0x2cdf(%rip),%rax
mov    (%rax),%ecx
lea    0xe13(%rip),%rdi
lea    0xd36(%rip),%rsi
mov    $0x32,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e4f(%rip),%rax
movslq (%rax),%r14
mov    %rsp,%rbx
lea    0x13(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
call   1030 <test_init@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   10b0 <inotify_init1@plt>
test   %eax,%eax
js     1240 <main+0xb0>
mov    %eax,%r15d
mov    0x2dea(%rip),%rax
mov    (%rax),%edx
lea    0xeea(%rip),%rsi
mov    %r15d,%edi
call   1080 <inotify_add_watch@plt>
test   %eax,%eax
js     125e <main+0xce>
add    $0x4,%r14
xor    %eax,%eax
call   1040 <test_daemon@plt>
xor    %eax,%eax
call   1070 <test_waitsig@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
lea    0xebc(%rip),%rdi
call   1090 <open@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    127c <main+0xec>
lea    0xed3(%rip),%rdi
xor    %eax,%eax
call   1050 <test_msg@plt>
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d81(%rip),%rax
mov    (%rax),%ecx
lea    0xdb0(%rip),%rdi
lea    0xdd8(%rip),%rsi
mov    $0x20,%edx
jmp    1298 <main+0x108>
mov    0x2d63(%rip),%rax
mov    (%rax),%ecx
lea    0xe5d(%rip),%rdi
lea    0xdba(%rip),%rsi
mov    $0x27,%edx
jmp    1298 <main+0x108>
mov    0x2d45(%rip),%rax
mov    (%rax),%ecx
lea    0xe79(%rip),%rdi
lea    0xd9c(%rip),%rsi
mov    $0x32,%edx
xor    %eax,%eax
call   1050 <test_msg@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@IN_NONBLOCK = global i32 0
@.str = [47 x i8] c"FAIL: %s:%d: inotify_init failed (errno = %d)\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/zdtm/live/static/inotify00.c\00"
@errno = global i32 0
@.str.2 = [2 x i8] c"/\00"
@IN_ALL_EVENTS = global i32 0
@.str.3 = [52 x i8] c"FAIL: %s:%d: inotify_add_watch failed (errno = %d)\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [6 x i8] c"PASS\0A\00"
@.str.5 = [46 x i8] c"FAIL: %s:%d: No events in queue (errno = %d)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @PATH_MAX
%11 = sext i32 %10 to i64
%12 = add i64 4, %11
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @test_init(i32 %15, i8** %16)
%18 = load i32, i32* @IN_NONBLOCK
%19 = call i32 @inotify_init1(i32 %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @errno
%24 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 32, i32 %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
store i32 0, i32* %9
%27 = load i32, i32* %8
%28 = load i32, i32* @IN_ALL_EVENTS
%29 = call i32 @inotify_add_watch(i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %9
%31 = or i32 %30, %29
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = load i32, i32* @errno
%36 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 %35)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %26
%39 = call i32 (...) @test_daemon()
%40 = call i32 (...) @test_waitsig()
%41 = load i32, i32* @O_RDONLY
%42 = call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %41)
store i32 %42, i32* %9
%43 = load i32, i32* %8
%44 = trunc i64 %12 to i32
%45 = call i64 @read(i32 %43, i8* %14, i32 %44)
%46 = icmp sgt i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %38
%48 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %53
49: ; preds = %38
%50 = load i32, i32* @errno
%51 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 50, i32 %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %47
store i32 0, i32* %3
%54 = load i8*, i8** %6
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@IN_NONBLOCK = global i32 0
@.str = [47 x i8] c"FAIL: %s:%d: inotify_init failed (errno = %d)\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/zdtm/live/static/inotify00.c\00"
@errno = global i32 0
@.str.2 = [2 x i8] c"/\00"
@IN_ALL_EVENTS = global i32 0
@.str.3 = [52 x i8] c"FAIL: %s:%d: inotify_add_watch failed (errno = %d)\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [6 x i8] c"PASS\0A\00"
@.str.5 = [46 x i8] c"FAIL: %s:%d: No events in queue (errno = %d)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @PATH_MAX
%4 = sext i32 %3 to i64
%5 = add nsw i64 %4, 4
%6 = alloca i8, i64 %5
%7 = tail call i32 @test_init(i32 %0, i8** %1)
%8 = load i32, i32* @IN_NONBLOCK
%9 = tail call i32 @inotify_init1(i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 32, i32 %12)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32, i32* @IN_ALL_EVENTS
%17 = tail call i32 @inotify_add_watch(i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* @errno
%21 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %15
%24 = tail call i32 (...) @test_daemon()
%25 = tail call i32 (...) @test_waitsig()
%26 = load i32, i32* @O_RDONLY
%27 = tail call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = trunc i64 %5 to i32
%29 = call i64 @read(i32 %9, i8* %6, i32 %28)
%30 = icmp sgt i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
33: ; preds = %23
%34 = load i32, i32* @errno
%35 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 50, i32 %34)
%36 = tail call i32 @exit(i32 1)
unreachable
}