#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_device {
  int dummy;
};
struct udev {
  int dummy;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ *opendir(char const *);
struct dirent *readdir(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, int /*<<< orphan*/);
int udev_device_get_devlink_priority(struct udev_device *);
char const *udev_device_get_devnode(struct udev_device *);
int /*<<< orphan*/ udev_device_get_id_filename(struct udev_device *);
int /*<<< orphan*/ udev_device_get_syspath(struct udev_device *);
struct udev *udev_device_get_udev(struct udev_device *);
struct udev_device *udev_device_new_from_id_filename(struct udev *, char *);
int /*<<< orphan*/ udev_device_unref(struct udev_device *);
int /*<<< orphan*/ udev_log_null(struct udev *, char *, char const *, ...);
int /*<<< orphan*/ util_strscpy(char *, size_t, char const *);
const char *link_find_prioritized(struct udev_device *dev, bool add,
                                  const char *stackdir, char *buf,
                                  size_t bufsize) {
  struct udev *udev = udev_device_get_udev(dev);
  DIR *dir;
  int priority = 0;
  const char *target = NULL;
  if (add) {
    priority = udev_device_get_devlink_priority(dev);
    util_strscpy(buf, bufsize, udev_device_get_devnode(dev));
    target = buf;
  }
  dir = opendir(stackdir);
  if (dir == NULL)
    return target;
  for (;;) {
    struct udev_device *dev_db;
    struct dirent *dent;
    dent = readdir(dir);
    if (dent == NULL || dent->d_name[0] == '\0')
      break;
    if (dent->d_name[0] == '.')
      continue;
    udev_log_null(udev, "found '%s' claiming '%s'\n", dent->d_name, stackdir);
    if (strcmp(dent->d_name, udev_device_get_id_filename(dev)) == 0)
      continue;
    dev_db = udev_device_new_from_id_filename(udev, dent->d_name);
    if (dev_db != NULL) {
      const char *devnode;
      devnode = udev_device_get_devnode(dev_db);
      if (devnode != NULL) {
        udev_log_null(udev, "compare priority of '%s'(%i) > '%s'(%i)\n", target,
                      priority, udev_device_get_devnode(dev_db),
                      udev_device_get_devlink_priority(dev_db));
        if (target == NULL ||
            udev_device_get_devlink_priority(dev_db) > priority) {
          udev_log_null(udev, "'%s' claims priority %i for '%s'\n",
                        udev_device_get_syspath(dev_db),
                        udev_device_get_devlink_priority(dev_db), stackdir);
          priority = udev_device_get_devlink_priority(dev_db);
          util_strscpy(buf, bufsize, devnode);
          target = buf;
        }
      }
      udev_device_unref(dev_db);
    }
  }
  closedir(dir);
  return target;
}


x86 assembly (clang, -O0):
<link_find_prioritized>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <udev_device_get_udev@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1251 <link_find_prioritized+0x81>
mov    -0x10(%rbp),%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <udev_device_get_devnode@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %rax,%rdx
call   1050 <util_strscpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <opendir@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1276 <link_find_prioritized+0xa6>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1457 <link_find_prioritized+0x287>
jmp    127b <link_find_prioritized+0xab>
mov    -0x40(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     12a6 <link_find_prioritized+0xd6>
mov    -0x60(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12ab <link_find_prioritized+0xdb>
jmp    1446 <link_find_prioritized+0x276>
mov    -0x60(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    12c3 <link_find_prioritized+0xf3>
jmp    127b <link_find_prioritized+0xab>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd27(%rip),%rsi
mov    $0x0,%al
call   1060 <udev_log_null@plt>
mov    -0x60(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
call   10d0 <udev_device_get_id_filename@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%esi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    130e <link_find_prioritized+0x13e>
jmp    127b <link_find_prioritized+0xab>
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%rax
mov    (%rax),%rsi
call   10c0 <udev_device_new_from_id_filename@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1441 <link_find_prioritized+0x271>
mov    -0x58(%rbp),%rdi
call   10f0 <udev_device_get_devnode@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     1438 <link_find_prioritized+0x268>
mov    -0x38(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x58(%rbp),%rdi
call   10f0 <udev_device_get_devnode@plt>
mov    %rax,-0x88(%rbp)
mov    -0x58(%rbp),%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rdx
mov    -0x8c(%rbp),%ecx
mov    -0x88(%rbp),%r8
mov    %eax,%r9d
lea    0xc78(%rip),%rsi
mov    $0x0,%al
call   1060 <udev_log_null@plt>
cmpq   $0x0,-0x50(%rbp)
je     13c6 <link_find_prioritized+0x1f6>
mov    -0x58(%rbp),%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
cmp    -0x44(%rbp),%eax
jle    1433 <link_find_prioritized+0x263>
mov    -0x38(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <udev_device_get_syspath@plt>
cltq
mov    %rax,-0xa8(%rbp)
mov    -0x58(%rbp),%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rdx
mov    %eax,%ecx
mov    -0x20(%rbp),%r8
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   1060 <udev_log_null@plt>
mov    -0x58(%rbp),%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x68(%rbp),%rdx
call   1050 <util_strscpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1438 <link_find_prioritized+0x268>
mov    -0x58(%rbp),%rdi
call   10b0 <udev_device_unref@plt>
jmp    127b <link_find_prioritized+0xab>
mov    -0x40(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<link_find_prioritized>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,%r15
mov    %esi,%ebx
mov    %rdi,%rbp
call   1040 <udev_device_get_udev@plt>
mov    %rax,%r12
test   %ebx,%ebx
mov    %r13,0x28(%rsp)
mov    %rbp,0x18(%rsp)
mov    %r14,0x30(%rsp)
je     1230 <link_find_prioritized+0x60>
mov    %rbp,%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    %eax,0xc(%rsp)
mov    %rbp,%rdi
call   10f0 <udev_device_get_devnode@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <util_strscpy@plt>
mov    %r13,0x10(%rsp)
jmp    123f <link_find_prioritized+0x6f>
xor    %eax,%eax
mov    %rax,0x10(%rsp)
movl   $0x0,0xc(%rsp)
mov    %r15,%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     13b2 <link_find_prioritized+0x1e2>
mov    %rax,%r13
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     13aa <link_find_prioritized+0x1da>
mov    %rax,%rbx
mov    0x18(%rsp),%r14
mov    %r15,0x20(%rsp)
jmp    12ed <link_find_prioritized+0x11d>
mov    %r14,%rdi
call   1030 <udev_device_get_syspath@plt>
movslq %eax,%rbx
mov    %r14,%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    %r12,%rdi
lea    0xdb3(%rip),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
mov    0x20(%rsp),%r8
xor    %eax,%eax
call   1060 <udev_log_null@plt>
mov    %r14,%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    %eax,0xc(%rsp)
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
mov    0x30(%rsp),%rsi
mov    %r15,%rdx
call   1050 <util_strscpy@plt>
mov    %rbx,0x10(%rsp)
mov    %r14,%rdi
call   10b0 <udev_device_unref@plt>
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%r14
mov    %r13,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     13aa <link_find_prioritized+0x1da>
mov    (%rbx),%rdx
movzbl (%rdx),%eax
cmp    $0x2e,%al
je     12d9 <link_find_prioritized+0x109>
test   %al,%al
je     13aa <link_find_prioritized+0x1da>
mov    %r12,%rdi
lea    0xcf7(%rip),%rsi
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <udev_log_null@plt>
mov    (%rbx),%rbp
mov    %r14,%rdi
call   10d0 <udev_device_get_id_filename@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12d9 <link_find_prioritized+0x109>
mov    (%rbx),%rsi
mov    %r12,%rdi
call   10c0 <udev_device_new_from_id_filename@plt>
test   %rax,%rax
je     12d4 <link_find_prioritized+0x104>
mov    %rax,%r14
mov    %rax,%rdi
call   10f0 <udev_device_get_devnode@plt>
test   %rax,%rax
je     12c7 <link_find_prioritized+0xf7>
mov    %rax,%r15
mov    %r14,%rdi
call   10f0 <udev_device_get_devnode@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
mov    %r12,%rdi
lea    0xca9(%rip),%rsi
mov    0x10(%rsp),%rbp
mov    %rbp,%rdx
mov    0xc(%rsp),%ecx
mov    %rbx,%r8
mov    %eax,%r9d
xor    %eax,%eax
call   1060 <udev_log_null@plt>
test   %rbp,%rbp
je     1273 <link_find_prioritized+0xa3>
mov    %r14,%rdi
call   10e0 <udev_device_get_devlink_priority@plt>
cmp    0xc(%rsp),%eax
jg     1273 <link_find_prioritized+0xa3>
jmp    12c7 <link_find_prioritized+0xf7>
mov    %r13,%rdi
call   1080 <closedir@plt>
mov    0x10(%rsp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.dirent = type { i8* }
@.str = [26 x i8] c"found '%s' claiming '%s'\0A\00"
@.str.1 = [41 x i8] c"compare priority of '%s'(%i) > '%s'(%i)\0A\00"
@.str.2 = [34 x i8] c"'%s' claims priority %i for '%s'\0A\00"
define i8* @link_find_prioritized(%struct.udev_device* %0, i32 %1, i8* %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca %struct.udev_device*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca %struct.udev*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca %struct.udev_device*
%17 = alloca %struct.dirent*
%18 = alloca i8*
store %struct.udev_device* %0, %struct.udev_device** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%19 = load %struct.udev_device*, %struct.udev_device** %7
%20 = call %struct.udev* @udev_device_get_udev(%struct.udev_device* %19)
store %struct.udev* %20, %struct.udev** %12
store i32 0, i32* %14
store i8* null, i8** %15
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %5
%24 = load %struct.udev_device*, %struct.udev_device** %7
%25 = call i32 @udev_device_get_devlink_priority(%struct.udev_device* %24)
store i32 %25, i32* %14
%26 = load i8*, i8** %10
%27 = load i64, i64* %11
%28 = load %struct.udev_device*, %struct.udev_device** %7
%29 = call i8* @udev_device_get_devnode(%struct.udev_device* %28)
%30 = call i32 @util_strscpy(i8* %26, i64 %27, i8* %29)
%31 = load i8*, i8** %10
store i8* %31, i8** %15
br label %32
32: ; preds = %23, %5
%33 = load i8*, i8** %9
%34 = call i32* @opendir(i8* %33)
store i32* %34, i32** %13
%35 = load i32*, i32** %13
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = load i8*, i8** %15
store i8* %38, i8** %6
br label %133
39: ; preds = %32
br label %40
40: ; preds = %128, %77, %62, %39
%41 = load i32*, i32** %13
%42 = call %struct.dirent* @readdir(i32* %41)
store %struct.dirent* %42, %struct.dirent** %17
%43 = load %struct.dirent*, %struct.dirent** %17
%44 = icmp eq %struct.dirent* %43, null
br i1 %44, label %53, label %45
45: ; preds = %40
%46 = load %struct.dirent*, %struct.dirent** %17
%47 = getelementptr inbounds %struct.dirent, %struct.dirent* %46, i32 0, i32 0
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %45, %40
br label %129
54: ; preds = %45
%55 = load %struct.dirent*, %struct.dirent** %17
%56 = getelementptr inbounds %struct.dirent, %struct.dirent* %55, i32 0, i32 0
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 46
br i1 %61, label %62, label %63
62: ; preds = %54
br label %40
63: ; preds = %54
%64 = load %struct.udev*, %struct.udev** %12
%65 = load %struct.dirent*, %struct.dirent** %17
%66 = getelementptr inbounds %struct.dirent, %struct.dirent* %65, i32 0, i32 0
%67 = load i8*, i8** %66
%68 = load i8*, i8** %9
%69 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %64, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %67, i8* %68)
%70 = load %struct.dirent*, %struct.dirent** %17
%71 = getelementptr inbounds %struct.dirent, %struct.dirent* %70, i32 0, i32 0
%72 = load i8*, i8** %71
%73 = load %struct.udev_device*, %struct.udev_device** %7
%74 = call i32 @udev_device_get_id_filename(%struct.udev_device* %73)
%75 = call i64 @strcmp(i8* %72, i32 %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %63
br label %40
78: ; preds = %63
%79 = load %struct.udev*, %struct.udev** %12
%80 = load %struct.dirent*, %struct.dirent** %17
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %80, i32 0, i32 0
%82 = load i8*, i8** %81
%83 = call %struct.udev_device* @udev_device_new_from_id_filename(%struct.udev* %79, i8* %82)
store %struct.udev_device* %83, %struct.udev_device** %16
%84 = load %struct.udev_device*, %struct.udev_device** %16
%85 = icmp ne %struct.udev_device* %84, null
br i1 %85, label %86, label %128
86: ; preds = %78
%87 = load %struct.udev_device*, %struct.udev_device** %16
%88 = call i8* @udev_device_get_devnode(%struct.udev_device* %87)
store i8* %88, i8** %18
%89 = load i8*, i8** %18
%90 = icmp ne i8* %89, null
br i1 %90, label %91, label %125
91: ; preds = %86
%92 = load %struct.udev*, %struct.udev** %12
%93 = load i8*, i8** %15
%94 = load i32, i32* %14
%95 = load %struct.udev_device*, %struct.udev_device** %16
%96 = call i8* @udev_device_get_devnode(%struct.udev_device* %95)
%97 = load %struct.udev_device*, %struct.udev_device** %16
%98 = call i32 @udev_device_get_devlink_priority(%struct.udev_device* %97)
%99 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %92, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %93, i32 %94, i8* %96, i32 %98)
%100 = load i8*, i8** %15
%101 = icmp eq i8* %100, null
br i1 %101, label %107, label %102
102: ; preds = %91
%103 = load %struct.udev_device*, %struct.udev_device** %16
%104 = call i32 @udev_device_get_devlink_priority(%struct.udev_device* %103)
%105 = load i32, i32* %14
%106 = icmp sgt i32 %104, %105
br i1 %106, label %107, label %124
107: ; preds = %102, %91
%108 = load %struct.udev*, %struct.udev** %12
%109 = load %struct.udev_device*, %struct.udev_device** %16
%110 = call i32 @udev_device_get_syspath(%struct.udev_device* %109)
%111 = sext i32 %110 to i64
%112 = inttoptr i64 %111 to i8*
%113 = load %struct.udev_device*, %struct.udev_device** %16
%114 = call i32 @udev_device_get_devlink_priority(%struct.udev_device* %113)
%115 = load i8*, i8** %9
%116 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %108, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %112, i32 %114, i8* %115)
%117 = load %struct.udev_device*, %struct.udev_device** %16
%118 = call i32 @udev_device_get_devlink_priority(%struct.udev_device* %117)
store i32 %118, i32* %14
%119 = load i8*, i8** %10
%120 = load i64, i64* %11
%121 = load i8*, i8** %18
%122 = call i32 @util_strscpy(i8* %119, i64 %120, i8* %121)
%123 = load i8*, i8** %10
store i8* %123, i8** %15
br label %124
124: ; preds = %107, %102
br label %125
125: ; preds = %124, %86
%126 = load %struct.udev_device*, %struct.udev_device** %16
%127 = call i32 @udev_device_unref(%struct.udev_device* %126)
br label %128
128: ; preds = %125, %78
br label %40
129: ; preds = %53
%130 = load i32*, i32** %13
%131 = call i32 @closedir(i32* %130)
%132 = load i8*, i8** %15
store i8* %132, i8** %6
br label %133
133: ; preds = %129, %37
%134 = load i8*, i8** %6
ret i8* %134
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.dirent = type { i8* }
@.str = [26 x i8] c"found '%s' claiming '%s'\0A\00"
@.str.1 = [41 x i8] c"compare priority of '%s'(%i) > '%s'(%i)\0A\00"
@.str.2 = [34 x i8] c"'%s' claims priority %i for '%s'\0A\00"
define i8* @link_find_prioritized(%struct.udev_device* %0, i32 %1, i8* %2, i8* %3, i64 %4) {
%6 = tail call %struct.udev* @udev_device_get_udev(%struct.udev_device* %0)
%7 = icmp eq i32 %1, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @udev_device_get_devlink_priority(%struct.udev_device* %0)
%10 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%11 = tail call i32 @util_strscpy(i8* %3, i64 %4, i8* %10)
br label %12
12: ; preds = %8, %5
%13 = phi i8* [ %3, %8 ], [ null, %5 ]
%14 = phi i32 [ %9, %8 ], [ 0, %5 ]
%15 = tail call i32* @opendir(i8* %2)
%16 = icmp eq i32* %15, null
br i1 %16, label %68, label %17
17: ; preds = %12
%18 = tail call %struct.dirent* @readdir(i32* %15)
%19 = icmp eq %struct.dirent* %18, null
br i1 %19, label %65, label %20
20: ; preds = %17, %60
%21 = phi %struct.dirent* [ %63, %60 ], [ %18, %17 ]
%22 = phi i32 [ %62, %60 ], [ %14, %17 ]
%23 = phi i8* [ %61, %60 ], [ %13, %17 ]
%24 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i64 0, i32 0
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
switch i8 %26, label %27 [
i8 0, label %65
i8 46, label %60
]
27: ; preds = %20
%28 = tail call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %25, i8* %2)
%29 = load i8*, i8** %24
%30 = tail call i32 @udev_device_get_id_filename(%struct.udev_device* %0)
%31 = tail call i64 @strcmp(i8* %29, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %60, label %33
33: ; preds = %27
%34 = load i8*, i8** %24
%35 = tail call %struct.udev_device* @udev_device_new_from_id_filename(%struct.udev* %6, i8* %34)
%36 = icmp eq %struct.udev_device* %35, null
br i1 %36, label %60, label %37
37: ; preds = %33
%38 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %35)
%39 = icmp eq i8* %38, null
br i1 %39, label %56, label %40
40: ; preds = %37
%41 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %35)
%42 = tail call i32 @udev_device_get_devlink_priority(%struct.udev_device* %35)
%43 = tail call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %6, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %22, i8* %41, i32 %42)
%44 = icmp eq i8* %23, null
br i1 %44, label %48, label %45
45: ; preds = %40
%46 = tail call i32 @udev_device_get_devlink_priority(%struct.udev_device* %35)
%47 = icmp sgt i32 %46, %22
br i1 %47, label %48, label %56
48: ; preds = %45, %40
%49 = tail call i32 @udev_device_get_syspath(%struct.udev_device* %35)
%50 = sext i32 %49 to i64
%51 = inttoptr i64 %50 to i8*
%52 = tail call i32 @udev_device_get_devlink_priority(%struct.udev_device* %35)
%53 = tail call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %51, i32 %52, i8* %2)
%54 = tail call i32 @udev_device_get_devlink_priority(%struct.udev_device* %35)
%55 = tail call i32 @util_strscpy(i8* %3, i64 %4, i8* %38)
br label %56
56: ; preds = %45, %48, %37
%57 = phi i8* [ %3, %48 ], [ %23, %45 ], [ %23, %37 ]
%58 = phi i32 [ %54, %48 ], [ %22, %45 ], [ %22, %37 ]
%59 = tail call i32 @udev_device_unref(%struct.udev_device* %35)
br label %60
60: ; preds = %20, %33, %56, %27
%61 = phi i8* [ %23, %27 ], [ %57, %56 ], [ %23, %33 ], [ %23, %20 ]
%62 = phi i32 [ %22, %27 ], [ %58, %56 ], [ %22, %33 ], [ %22, %20 ]
%63 = tail call %struct.dirent* @readdir(i32* %15)
%64 = icmp eq %struct.dirent* %63, null
br i1 %64, label %65, label %20
65: ; preds = %60, %20, %17
%66 = phi i8* [ %13, %17 ], [ %23, %20 ], [ %61, %60 ]
%67 = tail call i32 @closedir(i32* %15)
br label %68
68: ; preds = %12, %65
%69 = phi i8* [ %66, %65 ], [ %13, %12 ]
ret i8* %69
}