#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 stat {
  int /*<<< orphan*/ st_mode;
};
struct inotify_event {
  int mask;
  size_t wd;
  scalar_t__ len;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int IN_DELETE_SELF;
int IN_MODIFY;
int NAME_MAX;
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int inotify_add_watch(int, char *, int);
int inotify_init();
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void main() {
  FILE *fconfig;
  FILE *fout;
  char watchname[1000];
  struct stat sb;
  int notifyfd, watchfd;
  char eventbuf[(100 * (sizeof(struct inotify_event) + NAME_MAX + 1))];
  int n;
  char *p;
  struct inotify_event *event;
  char watchednames[100][NAME_MAX + 1];
  notifyfd = inotify_init();
  if ((fconfig = fopen("monitor.conf", "r")) == NULL) {
    printf("unable to open the config file; giving up!\n");
    exit(1);
  }
  while (fgets(watchname, 1000, fconfig) != NULL) {
    watchname[strlen(watchname) - 1] = '\0';
    if (stat(watchname, &sb) < 0) {
      printf("Cannot stat %s, ignored\n", watchname);
      continue;
    }
    if (S_ISREG(sb.st_mode)) {
      if ((watchfd = inotify_add_watch(notifyfd, watchname,
                                       IN_MODIFY | IN_DELETE_SELF)) < 0) {
        printf("error adding watch for %s\n", watchname);
      } else {
        printf("added %s to watch list on descriptor %d\n", watchname, watchfd);
        strcpy(watchednames[watchfd], watchname);
      }
    } else {
      printf("%s is not a regular file, ignored\n", watchname);
    }
  }
  fout = fopen("monitor.out", "a");
  while (1) {
    n = read(notifyfd, eventbuf,
             (100 * (sizeof(struct inotify_event) + NAME_MAX + 1)));
    for (p = eventbuf; p < eventbuf + n;) {
      event = (struct inotify_event *)p;
      p += sizeof(struct inotify_event) + event->len;
      if (event->mask & IN_MODIFY)
        fprintf(fout, "%s was modified\n", watchednames[event->wd]);
      if (event->mask & IN_DELETE_SELF)
        fprintf(fout, "%s was deleted\n", watchednames[event->wd]);
      fflush(fout);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    0x2de6(%rip),%rax
movslq (%rax),%rcx
imul   $0x64,%rcx,%rsi
mov    %rsi,%rcx
add    $0x9c4,%rcx
mov    %rsp,%rdx
mov    %rdx,-0x418(%rbp)
add    $0x9d3,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x458(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x420(%rbp)
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,-0x450(%rbp)
imul   $0x64,%rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x448(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x440(%rbp)
mov    $0x0,%al
call   10a0 <inotify_init@plt>
mov    %eax,-0x40c(%rbp)
lea    0xd9e(%rip),%rdi
lea    0xda4(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1294 <main+0xc4>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1299 <main+0xc9>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     13cc <main+0x1fc>
lea    -0x400(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rdi
lea    -0x408(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jge    1308 <main+0x138>
lea    -0x400(%rbp),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1299 <main+0xc9>
mov    -0x408(%rbp),%edi
call   10b0 <S_ISREG@plt>
cmp    $0x0,%rax
je     13b2 <main+0x1e2>
mov    -0x40c(%rbp),%edi
lea    -0x400(%rbp),%rsi
mov    0x2cbf(%rip),%rax
mov    (%rax),%edx
mov    0x2c96(%rip),%rax
or     (%rax),%edx
call   10d0 <inotify_add_watch@plt>
mov    %eax,-0x410(%rbp)
cmp    $0x0,%eax
jge    136a <main+0x19a>
lea    -0x400(%rbp),%rsi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13ad <main+0x1dd>
lea    -0x400(%rbp),%rsi
mov    -0x410(%rbp),%edx
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x450(%rbp),%rcx
mov    -0x448(%rbp),%rdi
movslq -0x410(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rdi
lea    -0x400(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    13c7 <main+0x1f7>
lea    -0x400(%rbp),%rsi
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1299 <main+0xc9>
lea    0xce8(%rip),%rdi
lea    0xced(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x10(%rbp)
jmp    13e8 <main+0x218>
mov    -0x458(%rbp),%rsi
mov    -0x40c(%rbp),%edi
mov    0x2bcc(%rip),%rax
movslq (%rax),%rax
add    $0x18,%rax
add    $0x1,%rax
imul   $0x64,%rax,%rax
mov    %eax,%edx
call   1060 <read@plt>
mov    %eax,%ecx
mov    -0x458(%rbp),%rax
mov    %ecx,-0x424(%rbp)
mov    %rax,-0x430(%rbp)
mov    -0x458(%rbp),%rcx
mov    -0x430(%rbp),%rax
movslq -0x424(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    1512 <main+0x342>
mov    -0x430(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rax
mov    0x10(%rax),%rax
add    $0x18,%rax
add    -0x430(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x438(%rbp),%rax
mov    (%rax),%eax
mov    0x2b6c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14bc <main+0x2ec>
mov    -0x448(%rbp),%rdx
mov    -0x450(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x438(%rbp),%rcx
imul   0x8(%rcx),%rax
add    %rax,%rdx
lea    0xc12(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x438(%rbp),%rax
mov    (%rax),%eax
mov    0x2b04(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1504 <main+0x334>
mov    -0x448(%rbp),%rdx
mov    -0x450(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x438(%rbp),%rcx
imul   0x8(%rcx),%rax
add    %rax,%rdx
lea    0xbdb(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <fflush@plt>
jmp    1428 <main+0x258>
jmp    13e3 <main+0x213>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    0x2dcd(%rip),%rax
movslq (%rax),%rax
imul   $0x64,%rax,%rcx
mov    %rsp,%rdx
add    $0x9d3,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
add    $0x1,%eax
mov    %rax,-0x40(%rbp)
imul   $0x64,%rax,%rax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
xor    %eax,%eax
call   10b0 <inotify_init@plt>
mov    %eax,-0x2c(%rbp)
lea    0xdb5(%rip),%rdi
lea    0xdbb(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     141b <main+0x23b>
mov    %rax,%r15
lea    -0x440(%rbp),%r12
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1358 <main+0x178>
lea    -0x48(%rbp),%r14
lea    0xd81(%rip),%r13
jmp    12b6 <main+0xd6>
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1358 <main+0x178>
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r12,1)
mov    %r12,%rdi
mov    %r14,%rsi
call   10a0 <stat@plt>
test   %rax,%rax
js     1290 <main+0xb0>
mov    -0x48(%rbp),%edi
call   10c0 <S_ISREG@plt>
test   %rax,%rax
je     1340 <main+0x160>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edx
mov    0x2cfd(%rip),%rax
or     (%rax),%edx
mov    -0x2c(%rbp),%edi
mov    %r12,%rsi
call   10e0 <inotify_add_watch@plt>
test   %eax,%eax
js     134c <main+0x16c>
mov    %eax,%ebx
lea    0xd36(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
imul   -0x40(%rbp),%rdi
add    -0x38(%rbp),%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
jmp    129d <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd25(%rip),%rdi
jmp    1293 <main+0xb3>
lea    0xcd5(%rip),%rdi
jmp    1293 <main+0xb3>
lea    0xd30(%rip),%rdi
lea    0xd35(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%rbx
mov    0x2c5b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2c41(%rip),%rax
imul   $0x64,(%rax),%edx
add    $0x9c4,%edx
mov    -0x2c(%rbp),%edi
mov    -0x50(%rbp),%rsi
call   1070 <read@plt>
test   %eax,%eax
jle    1380 <main+0x1a0>
movslq %eax,%r14
mov    -0x50(%rbp),%r13
add    %r13,%r14
jmp    13c4 <main+0x1e4>
nopl   0x0(%rax)
add    %r15,%r13
add    $0x18,%r13
mov    %rbx,%rdi
call   10d0 <fflush@plt>
cmp    %r14,%r13
jae    1380 <main+0x1a0>
mov    0x10(%r13),%r15
mov    0x0(%r13),%eax
mov    0x2c1d(%rip),%rcx
test   %eax,(%rcx)
je     13f7 <main+0x217>
mov    0x8(%r13),%rdx
imul   -0x40(%rbp),%rdx
add    -0x38(%rbp),%rdx
mov    %rbx,%rdi
lea    0xcaf(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x0(%r13),%eax
test   %eax,(%r12)
je     13b0 <main+0x1d0>
mov    0x8(%r13),%rdx
imul   -0x40(%rbp),%rdx
add    -0x38(%rbp),%rdx
mov    %rbx,%rdi
lea    0xc9a(%rip),%rsi
call   1090 <fprintf@plt>
jmp    13b0 <main+0x1d0>
lea    0xc9c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.inotify_event = type { i32, i64, i64 }
@NAME_MAX = global i32 0
@.str = [13 x i8] c"monitor.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [44 x i8] c"unable to open the config file; giving up!\0A\00"
@.str.3 = [25 x i8] c"Cannot stat %s, ignored\0A\00"
@IN_MODIFY = global i32 0
@IN_DELETE_SELF = global i32 0
@.str.4 = [27 x i8] c"error adding watch for %s\0A\00"
@.str.5 = [41 x i8] c"added %s to watch list on descriptor %d\0A\00"
@.str.6 = [35 x i8] c"%s is not a regular file, ignored\0A\00"
@.str.7 = [12 x i8] c"monitor.out\00"
@.str.8 = [2 x i8] c"a\00"
@.str.9 = [17 x i8] c"%s was modified\0A\00"
@.str.10 = [16 x i8] c"%s was deleted\0A\00"
define void @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca [1000 x i8]
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca %struct.inotify_event*
%12 = alloca i64
%13 = load i32, i32* @NAME_MAX
%14 = sext i32 %13 to i64
%15 = add i64 24, %14
%16 = add i64 %15, 1
%17 = mul i64 100, %16
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %7
%19 = alloca i8, i64 %17
store i64 %17, i64* %8
%20 = load i32, i32* @NAME_MAX
%21 = add nsw i32 %20, 1
%22 = zext i32 %21 to i64
%23 = mul nuw i64 100, %22
%24 = alloca i8, i64 %23
store i64 %22, i64* %12
%25 = call i32 (...) @inotify_init()
store i32 %25, i32* %5
%26 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %1
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %31
28: ; preds = %0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %0
br label %32
32: ; preds = %79, %46, %31
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%34 = load i32*, i32** %1
%35 = call i32* @fgets(i8* %33, i32 1000, i32* %34)
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %80
37: ; preds = %32
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %41
store i8 0, i8* %42
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%44 = call i64 @stat(i8* %43, %struct.stat* %4)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %37
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %47)
br label %32
49: ; preds = %37
%50 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i64 @S_ISREG(i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %76
54: ; preds = %49
%55 = load i32, i32* %5
%56 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%57 = load i32, i32* @IN_MODIFY
%58 = load i32, i32* @IN_DELETE_SELF
%59 = or i32 %57, %58
%60 = call i32 @inotify_add_watch(i32 %55, i8* %56, i32 %59)
store i32 %60, i32* %6
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %54
%63 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %63)
br label %75
65: ; preds = %54
%66 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%67 = load i32, i32* %6
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %66, i32 %67)
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = mul nsw i64 %70, %22
%72 = getelementptr inbounds i8, i8* %24, i64 %71
%73 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%74 = call i32 @strcpy(i8* %72, i8* %73)
br label %75
75: ; preds = %65, %62
br label %79
76: ; preds = %49
%77 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %77)
br label %79
79: ; preds = %76, %75
br label %32
80: ; preds = %32
%81 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %81, i32** %2
br label %82
82: ; preds = %139, %80
br label %83
83: ; preds = %82
%84 = load i32, i32* %5
%85 = load i32, i32* @NAME_MAX
%86 = sext i32 %85 to i64
%87 = add i64 24, %86
%88 = add i64 %87, 1
%89 = mul i64 100, %88
%90 = trunc i64 %89 to i32
%91 = call i32 @read(i32 %84, i8* %19, i32 %90)
store i32 %91, i32* %9
store i8* %19, i8** %10
br label %92
92: ; preds = %136, %83
%93 = load i8*, i8** %10
%94 = load i32, i32* %9
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %19, i64 %95
%97 = icmp ult i8* %93, %96
br i1 %97, label %98, label %139
98: ; preds = %92
%99 = load i8*, i8** %10
%100 = bitcast i8* %99 to %struct.inotify_event*
store %struct.inotify_event* %100, %struct.inotify_event** %11
%101 = load %struct.inotify_event*, %struct.inotify_event** %11
%102 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %101, i32 0, i32 2
%103 = load i64, i64* %102
%104 = add i64 24, %103
%105 = load i8*, i8** %10
%106 = getelementptr inbounds i8, i8* %105, i64 %104
store i8* %106, i8** %10
%107 = load %struct.inotify_event*, %struct.inotify_event** %11
%108 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %107, i32 0, i32 0
%109 = load i32, i32* %108
%110 = load i32, i32* @IN_MODIFY
%111 = and i32 %109, %110
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %121
113: ; preds = %98
%114 = load i32*, i32** %2
%115 = load %struct.inotify_event*, %struct.inotify_event** %11
%116 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %115, i32 0, i32 1
%117 = load i64, i64* %116
%118 = mul nsw i64 %117, %22
%119 = getelementptr inbounds i8, i8* %24, i64 %118
%120 = call i32 @fprintf(i32* %114, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %119)
br label %121
121: ; preds = %113, %98
%122 = load %struct.inotify_event*, %struct.inotify_event** %11
%123 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %122, i32 0, i32 0
%124 = load i32, i32* %123
%125 = load i32, i32* @IN_DELETE_SELF
%126 = and i32 %124, %125
%127 = icmp ne i32 %126, 0
br i1 %127, label %128, label %136
128: ; preds = %121
%129 = load i32*, i32** %2
%130 = load %struct.inotify_event*, %struct.inotify_event** %11
%131 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %130, i32 0, i32 1
%132 = load i64, i64* %131
%133 = mul nsw i64 %132, %22
%134 = getelementptr inbounds i8, i8* %24, i64 %133
%135 = call i32 @fprintf(i32* %129, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %134)
br label %136
136: ; preds = %128, %121
%137 = load i32*, i32** %2
%138 = call i32 @fflush(i32* %137)
br label %92
139: ; preds = %92
br label %82
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@NAME_MAX = global i32 0
@.str = [13 x i8] c"monitor.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [25 x i8] c"Cannot stat %s, ignored\0A\00"
@IN_MODIFY = global i32 0
@IN_DELETE_SELF = global i32 0
@.str.4 = [27 x i8] c"error adding watch for %s\0A\00"
@.str.5 = [41 x i8] c"added %s to watch list on descriptor %d\0A\00"
@.str.6 = [35 x i8] c"%s is not a regular file, ignored\0A\00"
@.str.7 = [12 x i8] c"monitor.out\00"
@.str.8 = [2 x i8] c"a\00"
@.str.9 = [17 x i8] c"%s was modified\0A\00"
@.str.10 = [16 x i8] c"%s was deleted\0A\00"
@str = [43 x i8] c"unable to open the config file; giving up!\00"
define void @main() {
%1 = alloca [1000 x i8]
%2 = alloca %struct.stat
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.stat* %2 to i8*
%5 = load i32, i32* @NAME_MAX
%6 = sext i32 %5 to i64
%7 = mul nsw i64 %6, 100
%8 = add nsw i64 %7, 2500
%9 = alloca i8, i64 %8
%10 = add nsw i32 %5, 1
%11 = zext i32 %10 to i64
%12 = mul nuw nsw i64 %11, 100
%13 = alloca i8, i64 %12
%14 = tail call i32 (...) @inotify_init()
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %22, label %17
17: ; preds = %0
%18 = call i32* @fgets(i8* %3, i32 1000, i32* %15)
%19 = icmp eq i32* %18, null
br i1 %19, label %57, label %20
20: ; preds = %17
%21 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
br label %25
22: ; preds = %0
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %20, %34
%26 = call i32 @strlen(i8* %3)
%27 = add nsw i32 %26, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i64 @stat(i8* %3, %struct.stat* %2)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %34
34: ; preds = %55, %49, %47, %32
%35 = call i32* @fgets(i8* %3, i32 1000, i32* %15)
%36 = icmp eq i32* %35, null
br i1 %36, label %57, label %25
37: ; preds = %25
%38 = load i32, i32* %21
%39 = call i64 @S_ISREG(i32 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %55, label %41
41: ; preds = %37
%42 = load i32, i32* @IN_MODIFY
%43 = load i32, i32* @IN_DELETE_SELF
%44 = or i32 %43, %42
%45 = call i32 @inotify_add_watch(i32 %14, i8* %3, i32 %44)
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %41
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %3)
br label %34
49: ; preds = %41
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %3, i32 %45)
%51 = zext i32 %45 to i64
%52 = mul nuw nsw i64 %51, %11
%53 = getelementptr inbounds i8, i8* %13, i64 %52
%54 = call i32 @strcpy(i8* %53, i8* %3)
br label %34
55: ; preds = %37
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %3)
br label %34
57: ; preds = %34, %17
%58 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %59
59: ; preds = %67, %57
%60 = load i32, i32* @NAME_MAX
%61 = mul i32 %60, 100
%62 = add i32 %61, 2500
%63 = call i32 @read(i32 %14, i8* %9, i32 %62)
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %9, i64 %64
%66 = icmp sgt i32 %63, 0
br i1 %66, label %68, label %67
67: ; preds = %100, %59
br label %59
68: ; preds = %59, %100
%69 = phi i8* [ %74, %100 ], [ %9, %59 ]
%70 = getelementptr inbounds i8, i8* %69, i64 16
%71 = bitcast i8* %70 to i64*
%72 = load i64, i64* %71
%73 = add i64 %72, 24
%74 = getelementptr inbounds i8, i8* %69, i64 %73
%75 = bitcast i8* %69 to i32*
%76 = load i32, i32* %75
%77 = load i32, i32* @IN_MODIFY
%78 = and i32 %77, %76
%79 = icmp eq i32 %78, 0
br i1 %79, label %88, label %80
80: ; preds = %68
%81 = getelementptr inbounds i8, i8* %69, i64 8
%82 = bitcast i8* %81 to i64*
%83 = load i64, i64* %82
%84 = mul nsw i64 %83, %11
%85 = getelementptr inbounds i8, i8* %13, i64 %84
%86 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %85)
%87 = load i32, i32* %75
br label %88
88: ; preds = %80, %68
%89 = phi i32 [ %87, %80 ], [ %76, %68 ]
%90 = load i32, i32* @IN_DELETE_SELF
%91 = and i32 %90, %89
%92 = icmp eq i32 %91, 0
br i1 %92, label %100, label %93
93: ; preds = %88
%94 = getelementptr inbounds i8, i8* %69, i64 8
%95 = bitcast i8* %94 to i64*
%96 = load i64, i64* %95
%97 = mul nsw i64 %96, %11
%98 = getelementptr inbounds i8, i8* %13, i64 %97
%99 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %98)
br label %100
100: ; preds = %93, %88
%101 = call i32 @fflush(i32* %58)
%102 = icmp ult i8* %74, %65
br i1 %102, label %68, label %67
}