#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 /*<<< orphan*/ name;
  int /*<<< orphan*/ wd;
};

/* Variables and functions */
int /*<<< orphan*/ db_delete_projects_for_watchd_and_config(char **, int);
int /*<<< orphan*/ db_get_projects_for_watchd_and_config(char ***, int *,
                                                         int /*<<< orphan*/,
                                                         int /*<<< orphan*/);
int /*<<< orphan*/ project_manager_projectname_configfile_changed(char *);
void inotify_check_watchlist_for_watch(
    const struct inotify_event *inotifyevent) {
  int i;
  int len;
  char **list;
  db_get_projects_for_watchd_and_config(&list, &len, inotifyevent->wd,
                                        inotifyevent->name);
  for (i = 0; i < len; i++) {
    project_manager_projectname_configfile_changed(list[i]);
  }
  db_delete_projects_for_watchd_and_config(list, len);
}


x86 assembly (clang, -O0):
<inotify_check_watchlist_for_watch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <db_get_projects_for_watchd_and_config@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1188 <inotify_check_watchlist_for_watch+0x58>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <project_manager_projectname_configfile_changed@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <inotify_check_watchlist_for_watch+0x2d>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <db_delete_projects_for_watchd_and_config@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inotify_check_watchlist_for_watch>:
push   %rbx
sub    $0x10,%rsp
mov    (%rdi),%ecx
mov    0x4(%rdi),%edx
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1050 <db_get_projects_for_watchd_and_config@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    117c <inotify_check_watchlist_for_watch+0x4c>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rdi
call   1030 <project_manager_projectname_configfile_changed@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rsi
cmp    %rsi,%rbx
jl     1160 <inotify_check_watchlist_for_watch+0x30>
mov    0x8(%rsp),%rdi
call   1040 <db_delete_projects_for_watchd_and_config@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.inotify_event = type { i32, i32 }
define void @inotify_check_watchlist_for_watch(%struct.inotify_event* %0) {
%2 = alloca %struct.inotify_event*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store %struct.inotify_event* %0, %struct.inotify_event** %2
%6 = load %struct.inotify_event*, %struct.inotify_event** %2
%7 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %6, i32 0, i32 1
%8 = load i32, i32* %7
%9 = load %struct.inotify_event*, %struct.inotify_event** %2
%10 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @db_get_projects_for_watchd_and_config(i8*** %5, i32* %4, i32 %8, i32 %11)
store i32 0, i32* %3
br label %13
13: ; preds = %24, %1
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @project_manager_projectname_configfile_changed(i8* %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %13
27: ; preds = %13
%28 = load i8**, i8*** %5
%29 = load i32, i32* %4
%30 = call i32 @db_delete_projects_for_watchd_and_config(i8** %28, i32 %29)
ret void
}

LLVM IR (-O2):
%struct.inotify_event = type { i32, i32 }
define void @inotify_check_watchlist_for_watch(%struct.inotify_event* nocapture %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = bitcast i32* %2 to i8*
%5 = bitcast i8*** %3 to i8*
%6 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %0, i64 0, i32 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %0, i64 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 @db_get_projects_for_watchd_and_config(i8*** %3, i32* %2, i32 %7, i32 %9)
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %1, %13
%14 = phi i64 [ %19, %13 ], [ 0, %1 ]
%15 = load i8**, i8*** %3
%16 = getelementptr inbounds i8*, i8** %15, i64 %14
%17 = load i8*, i8** %16
%18 = call i32 @project_manager_projectname_configfile_changed(i8* %17)
%19 = add nuw nsw i64 %14, 1
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %1
%24 = phi i32 [ %11, %1 ], [ %20, %13 ]
%25 = load i8**, i8*** %3
%26 = call i32 @db_delete_projects_for_watchd_and_config(i8** %25, i32 %24)
ret void
}