#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 udev_monitor {
  int dummy;
};
struct udev_list_entry {
  int dummy;
};
struct udev_enumerate {
  int dummy;
};
struct udev_device {
  int dummy;
};
struct udev {
  int dummy;
};
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ stdout;
char *udev_device_get_action(struct udev_device *);
char *udev_device_get_devnode(struct udev_device *);
char *udev_device_get_subsystem(struct udev_device *);
struct udev_device *udev_device_new_from_syspath(struct udev *, char const *);
int /*<<< orphan*/ udev_device_unref(struct udev_device *);
int /*<<< orphan*/ udev_enumerate_add_match_subsystem(struct udev_enumerate *,
                                                      char *);
struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *);
struct udev_enumerate *udev_enumerate_new(struct udev *);
int /*<<< orphan*/ udev_enumerate_scan_devices(struct udev_enumerate *);
int /*<<< orphan*/ udev_enumerate_unref(struct udev_enumerate *);
char *udev_list_entry_get_name(struct udev_list_entry *);
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *);
int /*<<< orphan*/ udev_monitor_enable_receiving(struct udev_monitor *);
int /*<<< orphan*/
udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *, char *,
                                                int /*<<< orphan*/ *);
int udev_monitor_get_fd(struct udev_monitor *);
struct udev_monitor *udev_monitor_new_from_netlink(struct udev *, char *);
struct udev_device *udev_monitor_receive_device(struct udev_monitor *);
struct udev *udev_new();
int /*<<< orphan*/ udev_unref(struct udev *);
int /*<<< orphan*/ usleep(int);
int main(void) {
  struct udev *udev;
  struct udev_enumerate *enumerate;
  struct udev_list_entry *devices, *dev_list_entry;
  struct udev_device *dev;
  struct udev_monitor *mon;
  int fd;
  udev = udev_new();
  if (!udev) {
    printf("Can't create udev\n");
    exit(1);
  }
  mon = udev_monitor_new_from_netlink(udev, "udev");
  udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
  udev_monitor_enable_receiving(mon);
  fd = udev_monitor_get_fd(mon);
  enumerate = udev_enumerate_new(udev);
  udev_enumerate_add_match_subsystem(enumerate, "input");
  udev_enumerate_scan_devices(enumerate);
  devices = udev_enumerate_get_list_entry(enumerate);
  for ((dev_list_entry) = devices; (dev_list_entry);
       (dev_list_entry) = udev_list_entry_get_next((dev_list_entry))) {
    const char *path;
    path = udev_list_entry_get_name(dev_list_entry);
    dev = udev_device_new_from_syspath(udev, path);
    printf("Device Node Path: %s\n", udev_device_get_devnode(dev));
    udev_device_unref(dev);
  }
  udev_enumerate_unref(enumerate);
  while (1) {
    fd_set fds;
    struct timeval tv;
    int ret;
    FD_ZERO(&fds);
    FD_SET(fd, &fds);
    tv.tv_sec = 0;
    tv.tv_usec = 0;
    ret = select(fd + 1, &fds, NULL, NULL, &tv);
    if (ret > 0 && FD_ISSET(fd, &fds)) {
      printf("\nselect() says there should be data\n");
      dev = udev_monitor_receive_device(mon);
      if (dev) {
        printf("Got Device\n");
        printf("   Node: %s\n", udev_device_get_devnode(dev));
        printf("   Subsystem: %s\n", udev_device_get_subsystem(dev));
        printf("   Action: %s\n", udev_device_get_action(dev));
        udev_device_unref(dev);
      } else {
        printf("No Device from receive_device(). An "
               "error occured.\n");
      }
    }
    usleep(250 * 1000);
    printf(".");
    fflush(stdout);
  }
  udev_unref(udev);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <udev_new@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12dd <main+0x3d>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    0xd2b(%rip),%rsi
call   1140 <udev_monitor_new_from_netlink@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xd1c(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1160 <udev_monitor_filter_add_match_subsystem_devtype@plt>
mov    -0x38(%rbp),%rdi
call   1180 <udev_monitor_enable_receiving@plt>
mov    -0x38(%rbp),%rdi
call   1100 <udev_monitor_get_fd@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <udev_enumerate_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xce6(%rip),%rsi
call   10b0 <udev_enumerate_add_match_subsystem@plt>
mov    -0x18(%rbp),%rdi
call   1040 <udev_enumerate_scan_devices@plt>
mov    -0x18(%rbp),%rdi
call   1110 <udev_enumerate_get_list_entry@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     13b3 <main+0x113>
mov    -0x28(%rbp),%rdi
call   1190 <udev_list_entry_get_name@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   10f0 <udev_device_new_from_syspath@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   11a0 <udev_device_get_devnode@plt>
mov    %rax,%rsi
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1130 <udev_device_unref@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <udev_list_entry_get_next@plt>
mov    %rax,-0x28(%rbp)
jmp    1355 <main+0xb5>
mov    -0x18(%rbp),%rdi
call   1150 <udev_enumerate_unref@plt>
lea    -0x4c(%rbp),%rdi
call   10d0 <FD_ZERO@plt>
mov    -0x3c(%rbp),%edi
lea    -0x4c(%rbp),%rsi
call   11b0 <FD_SET@plt>
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x3c(%rbp),%edi
add    $0x1,%edi
lea    -0x4c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x60(%rbp),%r8
mov    %rcx,%rdx
call   10e0 <select@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jle    14c1 <main+0x221>
mov    -0x3c(%rbp),%edi
lea    -0x4c(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14c1 <main+0x221>
lea    0xc0f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1060 <udev_monitor_receive_device@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     14ae <main+0x20e>
lea    0xc0e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   11a0 <udev_device_get_devnode@plt>
mov    %rax,%rsi
lea    0xc00(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1080 <udev_device_get_subsystem@plt>
mov    %rax,%rsi
lea    0xbf3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <udev_device_get_action@plt>
mov    %rax,%rsi
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1130 <udev_device_unref@plt>
jmp    14bc <main+0x21c>
lea    0xbde(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14c1 <main+0x221>
mov    $0x3d090,%edi
call   11c0 <usleep@plt>
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2b00(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
jmp    13bc <main+0x11c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1030 <udev_new@plt>
test   %rax,%rax
je     14c0 <main+0x200>
mov    %rax,%r12
lea    0xd7f(%rip),%rsi
mov    %rax,%rdi
call   1160 <udev_monitor_new_from_netlink@plt>
mov    %rax,%rbp
lea    0xd16(%rip),%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1180 <udev_monitor_filter_add_match_subsystem_devtype@plt>
mov    %rbp,%rdi
call   11a0 <udev_monitor_enable_receiving@plt>
mov    %rbp,(%rsp)
mov    %rbp,%rdi
call   1120 <udev_monitor_get_fd@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   10b0 <udev_enumerate_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   10d0 <udev_enumerate_add_match_subsystem@plt>
mov    %r14,%rdi
call   1060 <udev_enumerate_scan_devices@plt>
mov    %r14,%rdi
call   1130 <udev_enumerate_get_list_entry@plt>
test   %rax,%rax
je     13a3 <main+0xe3>
mov    %rax,%rbx
lea    0xcc4(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   11b0 <udev_list_entry_get_name@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1110 <udev_device_new_from_syspath@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   11c0 <udev_device_get_devnode@plt>
mov    %r13,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   1150 <udev_device_unref@plt>
mov    %rbx,%rdi
call   10e0 <udev_list_entry_get_next@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1360 <main+0xa0>
mov    %r14,%rdi
call   1170 <udev_enumerate_unref@plt>
mov    %ebp,%r15d
add    $0x1,%r15d
lea    0xc(%rsp),%rbx
lea    0x10(%rsp),%r12
mov    0x2c1d(%rip),%r14
jmp    13fc <main+0x13c>
lea    0xcc4(%rip),%rdi
call   1050 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x3d090,%edi
call   11e0 <usleep@plt>
mov    $0x2e,%edi
call   1040 <putchar@plt>
mov    (%r14),%edi
call   1140 <fflush@plt>
mov    %rbx,%rdi
call   10f0 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   11d0 <FD_SET@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1100 <select@plt>
test   %eax,%eax
jle    13e0 <main+0x120>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <FD_ISSET@plt>
test   %rax,%rax
je     13e0 <main+0x120>
lea    0xc2a(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%rdi
call   1080 <udev_monitor_receive_device@plt>
test   %rax,%rax
je     13c5 <main+0x105>
mov    %rax,%r13
lea    0xc60(%rip),%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   11c0 <udev_device_get_devnode@plt>
lea    0xbb5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13,%rdi
call   10a0 <udev_device_get_subsystem@plt>
lea    0xba9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13,%rdi
call   10c0 <udev_device_get_action@plt>
lea    0xba2(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13,%rdi
call   1150 <udev_device_unref@plt>
jmp    13e0 <main+0x120>
lea    0xb93(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1190 <exit@plt>

LLVM IR (-O0):
%struct.udev = type { i32 }
%struct.udev_enumerate = type { i32 }
%struct.udev_list_entry = type { i32 }
%struct.udev_device = type { i32 }
%struct.udev_monitor = type { i32 }
%struct.timeval = type { i64, i64 }
@.str = [19 x i8] c"Can't create udev\0A\00"
@.str.1 = [5 x i8] c"udev\00"
@.str.2 = [6 x i8] c"input\00"
@.str.3 = [22 x i8] c"Device Node Path: %s\0A\00"
@.str.4 = [37 x i8] c"\0Aselect() says there should be data\0A\00"
@.str.5 = [12 x i8] c"Got Device\0A\00"
@.str.6 = [13 x i8] c" Node: %s\0A\00"
@.str.7 = [18 x i8] c" Subsystem: %s\0A\00"
@.str.8 = [15 x i8] c" Action: %s\0A\00"
@.str.9 = [52 x i8] c"No Device from receive_device(). An error occured.\0A\00"
@.str.10 = [2 x i8] c".\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.udev*
%3 = alloca %struct.udev_enumerate*
%4 = alloca %struct.udev_list_entry*
%5 = alloca %struct.udev_list_entry*
%6 = alloca %struct.udev_device*
%7 = alloca %struct.udev_monitor*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.timeval
%12 = alloca i32
store i32 0, i32* %1
%13 = call %struct.udev* (...) @udev_new()
store %struct.udev* %13, %struct.udev** %2
%14 = load %struct.udev*, %struct.udev** %2
%15 = icmp ne %struct.udev* %14, null
br i1 %15, label %19, label %16
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
%20 = load %struct.udev*, %struct.udev** %2
%21 = call %struct.udev_monitor* @udev_monitor_new_from_netlink(%struct.udev* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store %struct.udev_monitor* %21, %struct.udev_monitor** %7
%22 = load %struct.udev_monitor*, %struct.udev_monitor** %7
%23 = call i32 @udev_monitor_filter_add_match_subsystem_devtype(%struct.udev_monitor* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* null)
%24 = load %struct.udev_monitor*, %struct.udev_monitor** %7
%25 = call i32 @udev_monitor_enable_receiving(%struct.udev_monitor* %24)
%26 = load %struct.udev_monitor*, %struct.udev_monitor** %7
%27 = call i32 @udev_monitor_get_fd(%struct.udev_monitor* %26)
store i32 %27, i32* %8
%28 = load %struct.udev*, %struct.udev** %2
%29 = call %struct.udev_enumerate* @udev_enumerate_new(%struct.udev* %28)
store %struct.udev_enumerate* %29, %struct.udev_enumerate** %3
%30 = load %struct.udev_enumerate*, %struct.udev_enumerate** %3
%31 = call i32 @udev_enumerate_add_match_subsystem(%struct.udev_enumerate* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%32 = load %struct.udev_enumerate*, %struct.udev_enumerate** %3
%33 = call i32 @udev_enumerate_scan_devices(%struct.udev_enumerate* %32)
%34 = load %struct.udev_enumerate*, %struct.udev_enumerate** %3
%35 = call %struct.udev_list_entry* @udev_enumerate_get_list_entry(%struct.udev_enumerate* %34)
store %struct.udev_list_entry* %35, %struct.udev_list_entry** %4
%36 = load %struct.udev_list_entry*, %struct.udev_list_entry** %4
store %struct.udev_list_entry* %36, %struct.udev_list_entry** %5
br label %37
37: ; preds = %51, %19
%38 = load %struct.udev_list_entry*, %struct.udev_list_entry** %5
%39 = icmp ne %struct.udev_list_entry* %38, null
br i1 %39, label %40, label %54
40: ; preds = %37
%41 = load %struct.udev_list_entry*, %struct.udev_list_entry** %5
%42 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %41)
store i8* %42, i8** %9
%43 = load %struct.udev*, %struct.udev** %2
%44 = load i8*, i8** %9
%45 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %43, i8* %44)
store %struct.udev_device* %45, %struct.udev_device** %6
%46 = load %struct.udev_device*, %struct.udev_device** %6
%47 = call i8* @udev_device_get_devnode(%struct.udev_device* %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = load %struct.udev_device*, %struct.udev_device** %6
%50 = call i32 @udev_device_unref(%struct.udev_device* %49)
br label %51
51: ; preds = %40
%52 = load %struct.udev_list_entry*, %struct.udev_list_entry** %5
%53 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %52)
store %struct.udev_list_entry* %53, %struct.udev_list_entry** %5
br label %37
54: ; preds = %37
%55 = load %struct.udev_enumerate*, %struct.udev_enumerate** %3
%56 = call i32 @udev_enumerate_unref(%struct.udev_enumerate* %55)
br label %57
57: ; preds = %54, %94
%58 = call i32 @FD_ZERO(i32* %10)
%59 = load i32, i32* %8
%60 = call i32 @FD_SET(i32 %59, i32* %10)
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
store i64 0, i64* %61
%62 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
store i64 0, i64* %62
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
%65 = call i32 @select(i32 %64, i32* %10, i32* null, i32* null, %struct.timeval* %11)
store i32 %65, i32* %12
%66 = load i32, i32* %12
%67 = icmp sgt i32 %66, 0
br i1 %67, label %68, label %94
68: ; preds = %57
%69 = load i32, i32* %8
%70 = call i64 @FD_ISSET(i32 %69, i32* %10)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %94
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%74 = load %struct.udev_monitor*, %struct.udev_monitor** %7
%75 = call %struct.udev_device* @udev_monitor_receive_device(%struct.udev_monitor* %74)
store %struct.udev_device* %75, %struct.udev_device** %6
%76 = load %struct.udev_device*, %struct.udev_device** %6
%77 = icmp ne %struct.udev_device* %76, null
br i1 %77, label %78, label %91
78: ; preds = %72
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%80 = load %struct.udev_device*, %struct.udev_device** %6
%81 = call i8* @udev_device_get_devnode(%struct.udev_device* %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %81)
%83 = load %struct.udev_device*, %struct.udev_device** %6
%84 = call i8* @udev_device_get_subsystem(%struct.udev_device* %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %84)
%86 = load %struct.udev_device*, %struct.udev_device** %6
%87 = call i8* @udev_device_get_action(%struct.udev_device* %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %87)
%89 = load %struct.udev_device*, %struct.udev_device** %6
%90 = call i32 @udev_device_unref(%struct.udev_device* %89)
br label %93
91: ; preds = %72
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0))
br label %93
93: ; preds = %91, %78
br label %94
94: ; preds = %93, %68, %57
%95 = call i32 @usleep(i32 250000)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%97 = load i32, i32* @stdout
%98 = call i32 @fflush(i32 %97)
br label %57
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
%struct.udev = type { i32 }
%struct.udev_monitor = type { i32 }
%struct.udev_enumerate = type { i32 }
%struct.udev_list_entry = type { i32 }
%struct.udev_device = type { i32 }
@.str.1 = [5 x i8] c"udev\00"
@.str.2 = [6 x i8] c"input\00"
@.str.3 = [22 x i8] c"Device Node Path: %s\0A\00"
@.str.6 = [13 x i8] c" Node: %s\0A\00"
@.str.7 = [18 x i8] c" Subsystem: %s\0A\00"
@.str.8 = [15 x i8] c" Action: %s\0A\00"
@stdout = global i32 0
@str = [18 x i8] c"Can't create udev\00"
@str.11 = [36 x i8] c"\0Aselect() says there should be data\00"
@str.12 = [51 x i8] c"No Device from receive_device(). An error occured.\00"
@str.13 = [11 x i8] c"Got Device\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = tail call %struct.udev* (...) @udev_new()
%4 = icmp eq %struct.udev* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call %struct.udev_monitor* @udev_monitor_new_from_netlink(%struct.udev* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @udev_monitor_filter_add_match_subsystem_devtype(%struct.udev_monitor* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* null)
%11 = tail call i32 @udev_monitor_enable_receiving(%struct.udev_monitor* %9)
%12 = tail call i32 @udev_monitor_get_fd(%struct.udev_monitor* %9)
%13 = tail call %struct.udev_enumerate* @udev_enumerate_new(%struct.udev* %3)
%14 = tail call i32 @udev_enumerate_add_match_subsystem(%struct.udev_enumerate* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @udev_enumerate_scan_devices(%struct.udev_enumerate* %13)
%16 = tail call %struct.udev_list_entry* @udev_enumerate_get_list_entry(%struct.udev_enumerate* %13)
%17 = icmp eq %struct.udev_list_entry* %16, null
br i1 %17, label %27, label %18
18: ; preds = %8, %18
%19 = phi %struct.udev_list_entry* [ %25, %18 ], [ %16, %8 ]
%20 = tail call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %19)
%21 = tail call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %3, i8* %20)
%22 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %21)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = tail call i32 @udev_device_unref(%struct.udev_device* %21)
%25 = tail call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %19)
%26 = icmp eq %struct.udev_list_entry* %25, null
br i1 %26, label %27, label %18
27: ; preds = %18, %8
%28 = tail call i32 @udev_enumerate_unref(%struct.udev_enumerate* %13)
%29 = bitcast i32* %1 to i8*
%30 = bitcast %struct.timeval* %2 to i8*
%31 = add nsw i32 %12, 1
%32 = bitcast %struct.timeval* %2 to i8*
br label %33
33: ; preds = %56, %27
%34 = call i32 @FD_ZERO(i32* %1)
%35 = call i32 @FD_SET(i32 %12, i32* %1)
%36 = call i32 @select(i32 %31, i32* %1, i32* null, i32* null, %struct.timeval* %2)
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %56
38: ; preds = %33
%39 = call i64 @FD_ISSET(i32 %12, i32* %1)
%40 = icmp eq i64 %39, 0
br i1 %40, label %56, label %41
41: ; preds = %38
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0))
%43 = call %struct.udev_device* @udev_monitor_receive_device(%struct.udev_monitor* %9)
%44 = icmp eq %struct.udev_device* %43, null
br i1 %44, label %54, label %45
45: ; preds = %41
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.13, i64 0, i64 0))
%47 = call i8* @udev_device_get_devnode(%struct.udev_device* %43)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %47)
%49 = call i8* @udev_device_get_subsystem(%struct.udev_device* %43)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %49)
%51 = call i8* @udev_device_get_action(%struct.udev_device* %43)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %51)
%53 = call i32 @udev_device_unref(%struct.udev_device* %43)
br label %56
54: ; preds = %41
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
br label %56
56: ; preds = %45, %54, %38, %33
%57 = call i32 @usleep(i32 250000)
%58 = call i32 @putchar(i32 46)
%59 = load i32, i32* @stdout
%60 = call i32 @fflush(i32 %59)
br label %33
}