#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_list_entry {
  int dummy;
};
struct udev_enumerate {
  int dummy;
};
struct udev_device {
  int dummy;
};
struct udev {
  int dummy;
};
typedef int /*<<< orphan*/ path;
typedef scalar_t__ dev_t;

/* Variables and functions */
int major(scalar_t__);
int minor(scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *, int,
                            int);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
scalar_t__ udev_device_get_devnum(struct udev_device *);
int /*<<< orphan*/ udev_device_get_subsystem(struct udev_device *);
struct udev_device *udev_device_new_from_syspath(struct udev *, char *);
int /*<<< orphan*/ udev_device_unref(struct udev_device *);
int /*<<< orphan*/ udev_enumerate_add_match_subsystem(struct udev_enumerate *,
                                                      char *);
int /*<<< orphan*/ udev_enumerate_add_nomatch_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_get_sys_path(struct udev *);
char *udev_list_entry_get_name(struct udev_list_entry *);
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *);
scalar_t__ util_resolve_sys_link(struct udev *, char *, int);
struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type,
                                                dev_t devnum) {
  char path[1024];
  const char *type_str;
  struct udev_enumerate *udev_enumerate;
  struct udev_list_entry *list_entry;
  struct udev_device *device = NULL;
  if (type == 'b')
    type_str = "block";
  else if (type == 'c')
    type_str = "char";
  else
    return NULL;
  snprintf(path, sizeof(path), "%s/dev/%s/%u:%u", udev_get_sys_path(udev),
           type_str, major(devnum), minor(devnum));
  if (util_resolve_sys_link(udev, path, sizeof(path)) == 0)
    return udev_device_new_from_syspath(udev, path);
  udev_enumerate = udev_enumerate_new(udev);
  if (udev_enumerate == NULL)
    return NULL;
  if (type == 'b')
    udev_enumerate_add_match_subsystem(udev_enumerate, "block");
  else if (type == 'c')
    udev_enumerate_add_nomatch_subsystem(udev_enumerate, "block");
  udev_enumerate_scan_devices(udev_enumerate);
  for (list_entry = udev_enumerate_get_list_entry(udev_enumerate);
       list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry)) {
    struct udev_device *device_loop;
    device_loop = udev_device_new_from_syspath(
        udev, udev_list_entry_get_name(list_entry));
    if (device_loop != NULL) {
      if (udev_device_get_devnum(device_loop) == devnum) {
        if (type == 'b' &&
            strcmp(udev_device_get_subsystem(device_loop), "block") != 0)
          continue;
        if (type == 'c' &&
            strcmp(udev_device_get_subsystem(device_loop), "block") == 0)
          continue;
        device = device_loop;
        break;
      }
      udev_device_unref(device_loop);
    }
  }
  udev_enumerate_unref(udev_enumerate);
  return device;
}


x86 assembly (clang, -O0):
<udev_device_new_from_devnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x440(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x62,%eax
jne    1264 <udev_device_new_from_devnum+0x44>
lea    0xda8(%rip),%rax
mov    %rax,-0x428(%rbp)
jmp    1296 <udev_device_new_from_devnum+0x76>
movsbl -0x11(%rbp),%eax
cmp    $0x63,%eax
jne    1284 <udev_device_new_from_devnum+0x64>
lea    0xd8e(%rip),%rax
mov    %rax,-0x428(%rbp)
jmp    1291 <udev_device_new_from_devnum+0x71>
movq   $0x0,-0x8(%rbp)
jmp    14f4 <udev_device_new_from_devnum+0x2d4>
jmp    1296 <udev_device_new_from_devnum+0x76>
lea    -0x420(%rbp),%rax
mov    %rax,-0x468(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <udev_get_sys_path@plt>
mov    %rax,-0x460(%rbp)
mov    -0x428(%rbp),%rax
mov    %rax,-0x458(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <major@plt>
mov    %eax,-0x44c(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <minor@plt>
mov    -0x468(%rbp),%rdi
mov    -0x460(%rbp),%rcx
mov    -0x458(%rbp),%r8
mov    -0x44c(%rbp),%r9d
mov    $0x400,%esi
lea    0xd09(%rip),%rdx
mov    %eax,(%rsp)
call   1060 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <util_resolve_sys_link@plt>
cmp    $0x0,%rax
jne    1342 <udev_device_new_from_devnum+0x122>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   10f0 <udev_device_new_from_syspath@plt>
mov    %rax,-0x8(%rbp)
jmp    14f4 <udev_device_new_from_devnum+0x2d4>
mov    -0x10(%rbp),%rdi
call   10b0 <udev_enumerate_new@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
jne    136d <udev_device_new_from_devnum+0x14d>
movq   $0x0,-0x8(%rbp)
jmp    14f4 <udev_device_new_from_devnum+0x2d4>
movsbl -0x11(%rbp),%eax
cmp    $0x62,%eax
jne    1392 <udev_device_new_from_devnum+0x172>
mov    -0x430(%rbp),%rdi
lea    0xc78(%rip),%rsi
call   10d0 <udev_enumerate_add_match_subsystem@plt>
jmp    13b7 <udev_device_new_from_devnum+0x197>
movsbl -0x11(%rbp),%eax
cmp    $0x63,%eax
jne    13b2 <udev_device_new_from_devnum+0x192>
mov    -0x430(%rbp),%rdi
lea    0xc53(%rip),%rsi
call   1090 <udev_enumerate_add_nomatch_subsystem@plt>
jmp    13b7 <udev_device_new_from_devnum+0x197>
mov    -0x430(%rbp),%rdi
call   1030 <udev_enumerate_scan_devices@plt>
mov    -0x430(%rbp),%rdi
call   1100 <udev_enumerate_get_list_entry@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
je     14dd <udev_device_new_from_devnum+0x2bd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x470(%rbp)
mov    -0x438(%rbp),%rdi
call   1140 <udev_list_entry_get_name@plt>
mov    -0x470(%rbp),%rdi
mov    %rax,%rsi
call   10f0 <udev_device_new_from_syspath@plt>
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x448(%rbp)
je     14c0 <udev_device_new_from_devnum+0x2a0>
mov    -0x448(%rbp),%rdi
call   1120 <udev_device_get_devnum@plt>
cmp    -0x20(%rbp),%rax
jne    14b4 <udev_device_new_from_devnum+0x294>
movsbl -0x11(%rbp),%eax
cmp    $0x62,%eax
jne    146b <udev_device_new_from_devnum+0x24b>
mov    -0x448(%rbp),%rdi
call   1080 <udev_device_get_subsystem@plt>
mov    %eax,%edi
lea    0xba9(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
je     146b <udev_device_new_from_devnum+0x24b>
jmp    14c5 <udev_device_new_from_devnum+0x2a5>
movsbl -0x11(%rbp),%eax
cmp    $0x63,%eax
jne    14a1 <udev_device_new_from_devnum+0x281>
mov    -0x448(%rbp),%rdi
call   1080 <udev_device_get_subsystem@plt>
mov    %eax,%edi
lea    0xb73(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    14a1 <udev_device_new_from_devnum+0x281>
jmp    14c5 <udev_device_new_from_devnum+0x2a5>
mov    -0x448(%rbp),%rax
mov    %rax,-0x440(%rbp)
jmp    14dd <udev_device_new_from_devnum+0x2bd>
mov    -0x448(%rbp),%rdi
call   1110 <udev_device_unref@plt>
jmp    14c5 <udev_device_new_from_devnum+0x2a5>
mov    -0x438(%rbp),%rdi
call   10e0 <udev_list_entry_get_next@plt>
mov    %rax,-0x438(%rbp)
jmp    13d6 <udev_device_new_from_devnum+0x1b6>
mov    -0x430(%rbp),%rdi
call   1130 <udev_enumerate_unref@plt>
mov    -0x440(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_new_from_devnum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdx,%r14
mov    %rdi,%r13
cmp    $0x62,%sil
jne    124a <udev_device_new_from_devnum+0x2a>
mov    %esi,0xc(%rsp)
lea    0xdb8(%rip),%r15
jmp    125f <udev_device_new_from_devnum+0x3f>
cmp    $0x63,%sil
jne    12e2 <udev_device_new_from_devnum+0xc2>
mov    %esi,0xc(%rsp)
lea    0xda7(%rip),%r15
mov    %r13,%rdi
call   1040 <udev_get_sys_path@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1070 <major@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <minor@plt>
mov    %eax,(%rsp)
lea    0xd85(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rbp,%rcx
mov    %r15,%r8
mov    %ebx,%r9d
call   1060 <snprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x400,%edx
call   10a0 <util_resolve_sys_link@plt>
test   %rax,%rax
je     12e9 <udev_device_new_from_devnum+0xc9>
mov    %r13,%rdi
call   10b0 <udev_enumerate_new@plt>
test   %rax,%rax
je     12e2 <udev_device_new_from_devnum+0xc2>
mov    %rax,%r15
mov    0xc(%rsp),%r12d
lea    0xd2e(%rip),%rsi
mov    %rax,%rdi
cmp    $0x62,%r12b
jne    12fe <udev_device_new_from_devnum+0xde>
call   10d0 <udev_enumerate_add_match_subsystem@plt>
jmp    1303 <udev_device_new_from_devnum+0xe3>
xor    %ebx,%ebx
jmp    13c0 <udev_device_new_from_devnum+0x1a0>
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
call   10f0 <udev_device_new_from_syspath@plt>
mov    %rax,%rbx
jmp    13c0 <udev_device_new_from_devnum+0x1a0>
call   1090 <udev_enumerate_add_nomatch_subsystem@plt>
mov    %r15,%rdi
call   1030 <udev_enumerate_scan_devices@plt>
mov    %r15,%rdi
call   1100 <udev_enumerate_get_list_entry@plt>
test   %rax,%rax
je     13b6 <udev_device_new_from_devnum+0x196>
mov    %rax,%rbp
jmp    1348 <udev_device_new_from_devnum+0x128>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1110 <udev_device_unref@plt>
mov    %rbp,%rdi
call   10e0 <udev_list_entry_get_next@plt>
mov    %rax,%rbp
test   %rax,%rax
je     13b6 <udev_device_new_from_devnum+0x196>
mov    %rbp,%rdi
call   1140 <udev_list_entry_get_name@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   10f0 <udev_device_new_from_syspath@plt>
test   %rax,%rax
je     1338 <udev_device_new_from_devnum+0x118>
mov    %rax,%rbx
mov    %rax,%rdi
call   1120 <udev_device_get_devnum@plt>
cmp    %r14,%rax
jne    1330 <udev_device_new_from_devnum+0x110>
cmp    $0x62,%r12b
jne    1393 <udev_device_new_from_devnum+0x173>
mov    %rbx,%rdi
call   1080 <udev_device_get_subsystem@plt>
mov    %eax,%edi
lea    0xc79(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    1338 <udev_device_new_from_devnum+0x118>
jmp    13b8 <udev_device_new_from_devnum+0x198>
cmp    $0x63,%r12b
jne    13b8 <udev_device_new_from_devnum+0x198>
mov    %rbx,%rdi
call   1080 <udev_device_get_subsystem@plt>
mov    %eax,%edi
lea    0xc56(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1338 <udev_device_new_from_devnum+0x118>
jmp    13b8 <udev_device_new_from_devnum+0x198>
xor    %ebx,%ebx
mov    %r15,%rdi
call   1130 <udev_enumerate_unref@plt>
mov    %rbx,%rax
add    $0x418,%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.udev_enumerate = type { i32 }
%struct.udev_list_entry = type { i32 }
@.str = [6 x i8] c"block\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [16 x i8] c"%s/dev/%s/%u:%u\00"
define %struct.udev_device* @udev_device_new_from_devnum(%struct.udev* %0, i8 signext %1, i64 %2) {
%4 = alloca %struct.udev_device*
%5 = alloca %struct.udev*
%6 = alloca i8
%7 = alloca i64
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca %struct.udev_enumerate*
%11 = alloca %struct.udev_list_entry*
%12 = alloca %struct.udev_device*
%13 = alloca %struct.udev_device*
store %struct.udev* %0, %struct.udev** %5
store i8 %1, i8* %6
store i64 %2, i64* %7
store %struct.udev_device* null, %struct.udev_device** %12
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 98
br i1 %16, label %17, label %18
17: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %9
br label %25
18: ; preds = %3
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 99
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %24
23: ; preds = %18
store %struct.udev_device* null, %struct.udev_device** %4
br label %117
24: ; preds = %22
br label %25
25: ; preds = %24, %17
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%27 = load %struct.udev*, %struct.udev** %5
%28 = call i8* @udev_get_sys_path(%struct.udev* %27)
%29 = load i8*, i8** %9
%30 = load i64, i64* %7
%31 = call i32 @major(i64 %30)
%32 = load i64, i64* %7
%33 = call i32 @minor(i64 %32)
%34 = call i32 @snprintf(i8* %26, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %29, i32 %31, i32 %33)
%35 = load %struct.udev*, %struct.udev** %5
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%37 = call i64 @util_resolve_sys_link(%struct.udev* %35, i8* %36, i32 1024)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %25
%40 = load %struct.udev*, %struct.udev** %5
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%42 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %40, i8* %41)
store %struct.udev_device* %42, %struct.udev_device** %4
br label %117
43: ; preds = %25
%44 = load %struct.udev*, %struct.udev** %5
%45 = call %struct.udev_enumerate* @udev_enumerate_new(%struct.udev* %44)
store %struct.udev_enumerate* %45, %struct.udev_enumerate** %10
%46 = load %struct.udev_enumerate*, %struct.udev_enumerate** %10
%47 = icmp eq %struct.udev_enumerate* %46, null
br i1 %47, label %48, label %49
48: ; preds = %43
store %struct.udev_device* null, %struct.udev_device** %4
br label %117
49: ; preds = %43
%50 = load i8, i8* %6
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 98
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load %struct.udev_enumerate*, %struct.udev_enumerate** %10
%55 = call i32 @udev_enumerate_add_match_subsystem(%struct.udev_enumerate* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %64
56: ; preds = %49
%57 = load i8, i8* %6
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 99
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load %struct.udev_enumerate*, %struct.udev_enumerate** %10
%62 = call i32 @udev_enumerate_add_nomatch_subsystem(%struct.udev_enumerate* %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %63
63: ; preds = %60, %56
br label %64
64: ; preds = %63, %53
%65 = load %struct.udev_enumerate*, %struct.udev_enumerate** %10
%66 = call i32 @udev_enumerate_scan_devices(%struct.udev_enumerate* %65)
%67 = load %struct.udev_enumerate*, %struct.udev_enumerate** %10
%68 = call %struct.udev_list_entry* @udev_enumerate_get_list_entry(%struct.udev_enumerate* %67)
store %struct.udev_list_entry* %68, %struct.udev_list_entry** %11
br label %69
69: ; preds = %110, %64
%70 = load %struct.udev_list_entry*, %struct.udev_list_entry** %11
%71 = icmp ne %struct.udev_list_entry* %70, null
br i1 %71, label %72, label %113
72: ; preds = %69
%73 = load %struct.udev*, %struct.udev** %5
%74 = load %struct.udev_list_entry*, %struct.udev_list_entry** %11
%75 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %74)
%76 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %73, i8* %75)
store %struct.udev_device* %76, %struct.udev_device** %13
%77 = load %struct.udev_device*, %struct.udev_device** %13
%78 = icmp ne %struct.udev_device* %77, null
br i1 %78, label %79, label %109
79: ; preds = %72
%80 = load %struct.udev_device*, %struct.udev_device** %13
%81 = call i64 @udev_device_get_devnum(%struct.udev_device* %80)
%82 = load i64, i64* %7
%83 = icmp eq i64 %81, %82
br i1 %83, label %84, label %106
84: ; preds = %79
%85 = load i8, i8* %6
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 98
br i1 %87, label %88, label %94
88: ; preds = %84
%89 = load %struct.udev_device*, %struct.udev_device** %13
%90 = call i32 @udev_device_get_subsystem(%struct.udev_device* %89)
%91 = call i64 @strcmp(i32 %90, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %94
93: ; preds = %88
br label %110
94: ; preds = %88, %84
%95 = load i8, i8* %6
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 99
br i1 %97, label %98, label %104
98: ; preds = %94
%99 = load %struct.udev_device*, %struct.udev_device** %13
%100 = call i32 @udev_device_get_subsystem(%struct.udev_device* %99)
%101 = call i64 @strcmp(i32 %100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%102 = icmp eq i64 %101, 0
br i1 %102, label %103, label %104
103: ; preds = %98
br label %110
104: ; preds = %98, %94
%105 = load %struct.udev_device*, %struct.udev_device** %13
store %struct.udev_device* %105, %struct.udev_device** %12
br label %113
106: ; preds = %79
%107 = load %struct.udev_device*, %struct.udev_device** %13
%108 = call i32 @udev_device_unref(%struct.udev_device* %107)
br label %109
109: ; preds = %106, %72
br label %110
110: ; preds = %109, %103, %93
%111 = load %struct.udev_list_entry*, %struct.udev_list_entry** %11
%112 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %111)
store %struct.udev_list_entry* %112, %struct.udev_list_entry** %11
br label %69
113: ; preds = %104, %69
%114 = load %struct.udev_enumerate*, %struct.udev_enumerate** %10
%115 = call i32 @udev_enumerate_unref(%struct.udev_enumerate* %114)
%116 = load %struct.udev_device*, %struct.udev_device** %12
store %struct.udev_device* %116, %struct.udev_device** %4
br label %117
117: ; preds = %113, %48, %39, %23
%118 = load %struct.udev_device*, %struct.udev_device** %4
ret %struct.udev_device* %118
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.udev_enumerate = type { i32 }
%struct.udev_list_entry = type { i32 }
@.str = [6 x i8] c"block\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [16 x i8] c"%s/dev/%s/%u:%u\00"
define %struct.udev_device* @udev_device_new_from_devnum(%struct.udev* %0, i8 signext %1, i64 %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8 %1, 98
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = icmp eq i8 %1, 99
br i1 %8, label %9, label %59
9: ; preds = %7, %3
%10 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %7 ]
%11 = tail call i8* @udev_get_sys_path(%struct.udev* %0)
%12 = tail call i32 @major(i64 %2)
%13 = tail call i32 @minor(i64 %2)
%14 = call i32 @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %10, i32 %12, i32 %13)
%15 = call i64 @util_resolve_sys_link(%struct.udev* %0, i8* %5, i32 1024)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %9
%18 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %0, i8* %5)
br label %59
19: ; preds = %9
%20 = call %struct.udev_enumerate* @udev_enumerate_new(%struct.udev* %0)
%21 = icmp eq %struct.udev_enumerate* %20, null
br i1 %21, label %59, label %22
22: ; preds = %19
br i1 %6, label %23, label %25
23: ; preds = %22
%24 = call i32 @udev_enumerate_add_match_subsystem(%struct.udev_enumerate* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %27
25: ; preds = %22
%26 = call i32 @udev_enumerate_add_nomatch_subsystem(%struct.udev_enumerate* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = call i32 @udev_enumerate_scan_devices(%struct.udev_enumerate* %20)
%29 = call %struct.udev_list_entry* @udev_enumerate_get_list_entry(%struct.udev_enumerate* %20)
%30 = icmp eq %struct.udev_list_entry* %29, null
br i1 %30, label %56, label %31
31: ; preds = %27
%32 = icmp eq i8 %1, 99
br label %33
33: ; preds = %31, %53
%34 = phi %struct.udev_list_entry* [ %29, %31 ], [ %54, %53 ]
%35 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %34)
%36 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %0, i8* %35)
%37 = icmp eq %struct.udev_device* %36, null
br i1 %37, label %53, label %38
38: ; preds = %33
%39 = call i64 @udev_device_get_devnum(%struct.udev_device* %36)
%40 = icmp eq i64 %39, %2
br i1 %40, label %41, label %51
41: ; preds = %38
br i1 %6, label %42, label %46
42: ; preds = %41
%43 = call i32 @udev_device_get_subsystem(%struct.udev_device* %36)
%44 = call i64 @strcmp(i32 %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %56, label %53
46: ; preds = %41
br i1 %32, label %47, label %56
47: ; preds = %46
%48 = call i32 @udev_device_get_subsystem(%struct.udev_device* %36)
%49 = call i64 @strcmp(i32 %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %56
51: ; preds = %38
%52 = call i32 @udev_device_unref(%struct.udev_device* %36)
br label %53
53: ; preds = %42, %47, %51, %33
%54 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %34)
%55 = icmp eq %struct.udev_list_entry* %54, null
br i1 %55, label %56, label %33
56: ; preds = %53, %42, %46, %47, %27
%57 = phi %struct.udev_device* [ null, %27 ], [ %36, %47 ], [ %36, %46 ], [ %36, %42 ], [ null, %53 ]
%58 = call i32 @udev_enumerate_unref(%struct.udev_enumerate* %20)
br label %59
59: ; preds = %19, %7, %56, %17
%60 = phi %struct.udev_device* [ %18, %17 ], [ %57, %56 ], [ null, %7 ], [ null, %19 ]
ret %struct.udev_device* %60
}