#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 dirent {
  char *d_name;
  scalar_t__ d_type;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ DT_DIR;
scalar_t__ DT_LNK;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ path_prepend(char **, char *, int, int, int, int);
struct dirent *readdir(int /*<<< orphan*/ *);
int sscanf(char const *, char *, int *, int *, int *, int *);
char *strdup(int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
char *strrchr(char *, char);
int strtoul(char *, char **, int);
struct udev_device *
udev_device_get_parent_with_subsystem_devtype(struct udev_device *, char *,
                                              char *);
char *udev_device_get_sysname(struct udev_device *);
int /*<<< orphan*/ udev_device_get_syspath(struct udev_device *);
struct udev_device *handle_scsi_default(struct udev_device *parent,
                                        char **path) {
  struct udev_device *hostdev;
  int host, bus, target, lun;
  const char *name;
  char *base;
  char *pos;
  DIR *dir;
  struct dirent *dent;
  int basenum;
  hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi",
                                                          "scsi_host");
  if (hostdev == NULL)
    return NULL;
  name = udev_device_get_sysname(parent);
  if (sscanf(name, "%d:%d:%d:%d", &host, &bus, &target, &lun) != 4)
    return NULL;
  basenum = -1;
  base = strdup(udev_device_get_syspath(hostdev));
  if (base == NULL)
    return NULL;
  pos = strrchr(base, '/');
  if (pos == NULL) {
    parent = NULL;
    goto out;
  }
  pos[0] = '\0';
  dir = opendir(base);
  if (dir == NULL) {
    parent = NULL;
    goto out;
  }
  for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
    char *rest;
    int i;
    if (dent->d_name[0] == '.')
      continue;
    if (dent->d_type != DT_DIR && dent->d_type != DT_LNK)
      continue;
    if (strncmp(dent->d_name, "host", 4) != 0)
      continue;
    i = strtoul(&dent->d_name[4], &rest, 10);
    if (rest[0] != '\0')
      continue;
    if (basenum == -1 || i < basenum)
      basenum = i;
  }
  closedir(dir);
  if (basenum == -1) {
    parent = NULL;
    goto out;
  }
  host -= basenum;
  path_prepend(path, "scsi-%u:%u:%u:%u", host, bus, target, lun);
out:
  free(base);
  return hostdev;
}


x86 assembly (clang, -O0):
<handle_scsi_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe15(%rip),%rsi
lea    0xe13(%rip),%rdx
call   1080 <udev_device_get_parent_with_subsystem_devtype@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1213 <handle_scsi_default+0x43>
movq   $0x0,-0x8(%rbp)
jmp    1429 <handle_scsi_default+0x259>
mov    -0x10(%rbp),%rdi
call   10d0 <udev_device_get_sysname@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xde4(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
call   10c0 <sscanf@plt>
cmp    $0x4,%eax
je     1256 <handle_scsi_default+0x86>
movq   $0x0,-0x8(%rbp)
jmp    1429 <handle_scsi_default+0x259>
movl   $0xffffffff,-0x5c(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <udev_device_get_syspath@plt>
mov    %eax,%edi
call   10f0 <strdup@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1289 <handle_scsi_default+0xb9>
movq   $0x0,-0x8(%rbp)
jmp    1429 <handle_scsi_default+0x259>
mov    -0x40(%rbp),%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12b3 <handle_scsi_default+0xe3>
movq   $0x0,-0x10(%rbp)
jmp    1418 <handle_scsi_default+0x248>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
call   1070 <opendir@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12df <handle_scsi_default+0x10f>
movq   $0x0,-0x10(%rbp)
jmp    1418 <handle_scsi_default+0x248>
mov    -0x50(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     13cf <handle_scsi_default+0x1ff>
mov    -0x58(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    130f <handle_scsi_default+0x13f>
jmp    13bd <handle_scsi_default+0x1ed>
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2cc2(%rip),%rcx
cmp    (%rcx),%rax
je     1344 <handle_scsi_default+0x174>
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2ca2(%rip),%rcx
cmp    (%rcx),%rax
je     1344 <handle_scsi_default+0x174>
jmp    13bd <handle_scsi_default+0x1ed>
mov    -0x58(%rbp),%rax
mov    (%rax),%rdi
lea    0xcb8(%rip),%rsi
mov    $0x4,%edx
call   1060 <strncmp@plt>
cmp    $0x0,%rax
je     136b <handle_scsi_default+0x19b>
jmp    13bd <handle_scsi_default+0x1ed>
mov    -0x58(%rbp),%rax
mov    (%rax),%rdi
add    $0x4,%rdi
lea    -0x68(%rbp),%rsi
mov    $0xa,%edx
call   10e0 <strtoul@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     139c <handle_scsi_default+0x1cc>
jmp    13bd <handle_scsi_default+0x1ed>
cmpl   $0xffffffff,-0x5c(%rbp)
je     13b2 <handle_scsi_default+0x1e2>
mov    -0x6c(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jge    13b8 <handle_scsi_default+0x1e8>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    13bd <handle_scsi_default+0x1ed>
mov    -0x50(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x58(%rbp)
jmp    12ec <handle_scsi_default+0x11c>
mov    -0x50(%rbp),%rdi
call   10a0 <closedir@plt>
cmpl   $0xffffffff,-0x5c(%rbp)
jne    13ef <handle_scsi_default+0x21f>
movq   $0x0,-0x10(%rbp)
jmp    1418 <handle_scsi_default+0x248>
mov    -0x5c(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
lea    0xc08(%rip),%rsi
call   1040 <path_prepend@plt>
mov    -0x40(%rbp),%rdi
call   1050 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_scsi_default>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0xe15(%rip),%rsi
lea    0xe13(%rip),%rdx
call   1080 <udev_device_get_parent_with_subsystem_devtype@plt>
test   %rax,%rax
je     129c <handle_scsi_default+0xcc>
mov    %rax,%rbx
mov    %rbp,%rdi
call   10d0 <udev_device_get_sysname@plt>
lea    0xdfd(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x1c(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x14(%rsp),%r9
mov    %rax,%rdi
call   10c0 <sscanf@plt>
cmp    $0x4,%eax
jne    129c <handle_scsi_default+0xcc>
mov    %rbx,%rdi
call   1030 <udev_device_get_syspath@plt>
mov    %eax,%edi
call   10f0 <strdup@plt>
test   %rax,%rax
je     129c <handle_scsi_default+0xcc>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
test   %rax,%rax
je     137b <handle_scsi_default+0x1ab>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     137b <handle_scsi_default+0x1ab>
mov    %rax,%r12
mov    %rax,%rdi
call   10b0 <readdir@plt>
test   %rax,%rax
je     1373 <handle_scsi_default+0x1a3>
mov    %rax,%rbp
movl   $0xffffffff,0xc(%rsp)
ff
mov    0x2d46(%rip),%r13
jmp    12e0 <handle_scsi_default+0x110>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd53(%rip),%rsi
mov    $0x4,%edx
call   1060 <strncmp@plt>
test   %rax,%rax
je     1301 <handle_scsi_default+0x131>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10b0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1339 <handle_scsi_default+0x169>
mov    0x0(%rbp),%rdi
cmpb   $0x2e,(%rdi)
je     12d0 <handle_scsi_default+0x100>
mov    0x8(%rbp),%rax
cmp    0x0(%r13),%rax
je     12b0 <handle_scsi_default+0xe0>
mov    0x2cde(%rip),%rcx
cmp    (%rcx),%rax
jne    12d0 <handle_scsi_default+0x100>
jmp    12b0 <handle_scsi_default+0xe0>
mov    0x0(%rbp),%rdi
add    $0x4,%rdi
lea    0x20(%rsp),%rsi
mov    $0xa,%edx
call   10e0 <strtoul@plt>
mov    0x20(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    12d0 <handle_scsi_default+0x100>
mov    0xc(%rsp),%edx
cmp    %edx,%eax
mov    %edx,%ecx
cmovl  %eax,%ecx
cmp    $0xffffffff,%edx
cmove  %eax,%ecx
mov    %ecx,0xc(%rsp)
jmp    12d0 <handle_scsi_default+0x100>
mov    %r12,%rdi
call   10a0 <closedir@plt>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     137b <handle_scsi_default+0x1ab>
mov    0x10(%rsp),%edx
sub    %eax,%edx
mov    %edx,0x10(%rsp)
mov    0x1c(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    0x14(%rsp),%r9d
lea    0xcb2(%rip),%rsi
mov    %r14,%rdi
call   1040 <path_prepend@plt>
jmp    137b <handle_scsi_default+0x1ab>
mov    %r12,%rdi
call   10a0 <closedir@plt>
mov    %r15,%rdi
call   1050 <free@plt>
jmp    129e <handle_scsi_default+0xce>

LLVM IR (-O0):
%struct.udev_device = type { i32 }
%struct.dirent = type { i8*, i64 }
@.str = [5 x i8] c"scsi\00"
@.str.1 = [10 x i8] c"scsi_host\00"
@.str.2 = [12 x i8] c"%d:%d:%d:%d\00"
@DT_DIR = global i64 0
@DT_LNK = global i64 0
@.str.3 = [5 x i8] c"host\00"
@.str.4 = [17 x i8] c"scsi-%u:%u:%u:%u\00"
define %struct.udev_device* @handle_scsi_default(%struct.udev_device* %0, i8** %1) {
%3 = alloca %struct.udev_device*
%4 = alloca %struct.udev_device*
%5 = alloca i8**
%6 = alloca %struct.udev_device*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca %struct.dirent*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32
store %struct.udev_device* %0, %struct.udev_device** %4
store i8** %1, i8*** %5
%19 = load %struct.udev_device*, %struct.udev_device** %4
%20 = call %struct.udev_device* @udev_device_get_parent_with_subsystem_devtype(%struct.udev_device* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store %struct.udev_device* %20, %struct.udev_device** %6
%21 = load %struct.udev_device*, %struct.udev_device** %6
%22 = icmp eq %struct.udev_device* %21, null
br i1 %22, label %23, label %24
23: ; preds = %2
store %struct.udev_device* null, %struct.udev_device** %3
br label %132
24: ; preds = %2
%25 = load %struct.udev_device*, %struct.udev_device** %4
%26 = call i8* @udev_device_get_sysname(%struct.udev_device* %25)
store i8* %26, i8** %11
%27 = load i8*, i8** %11
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %7, i32* %8, i32* %9, i32* %10)
%29 = icmp ne i32 %28, 4
br i1 %29, label %30, label %31
30: ; preds = %24
store %struct.udev_device* null, %struct.udev_device** %3
br label %132
31: ; preds = %24
store i32 -1, i32* %16
%32 = load %struct.udev_device*, %struct.udev_device** %6
%33 = call i32 @udev_device_get_syspath(%struct.udev_device* %32)
%34 = call i8* @strdup(i32 %33)
store i8* %34, i8** %12
%35 = load i8*, i8** %12
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %38
37: ; preds = %31
store %struct.udev_device* null, %struct.udev_device** %3
br label %132
38: ; preds = %31
%39 = load i8*, i8** %12
%40 = call i8* @strrchr(i8* %39, i8 signext 47)
store i8* %40, i8** %13
%41 = load i8*, i8** %13
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %44
43: ; preds = %38
store %struct.udev_device* null, %struct.udev_device** %4
br label %128
44: ; preds = %38
%45 = load i8*, i8** %13
%46 = getelementptr inbounds i8, i8* %45, i64 0
store i8 0, i8* %46
%47 = load i8*, i8** %12
%48 = call i32* @opendir(i8* %47)
store i32* %48, i32** %14
%49 = load i32*, i32** %14
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %52
51: ; preds = %44
store %struct.udev_device* null, %struct.udev_device** %4
br label %128
52: ; preds = %44
%53 = load i32*, i32** %14
%54 = call %struct.dirent* @readdir(i32* %53)
store %struct.dirent* %54, %struct.dirent** %15
br label %55
55: ; preds = %109, %52
%56 = load %struct.dirent*, %struct.dirent** %15
%57 = icmp ne %struct.dirent* %56, null
br i1 %57, label %58, label %112
58: ; preds = %55
%59 = load %struct.dirent*, %struct.dirent** %15
%60 = getelementptr inbounds %struct.dirent, %struct.dirent* %59, i32 0, i32 0
%61 = load i8*, i8** %60
%62 = getelementptr inbounds i8, i8* %61, i64 0
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 46
br i1 %65, label %66, label %67
66: ; preds = %58
br label %109
67: ; preds = %58
%68 = load %struct.dirent*, %struct.dirent** %15
%69 = getelementptr inbounds %struct.dirent, %struct.dirent* %68, i32 0, i32 1
%70 = load i64, i64* %69
%71 = load i64, i64* @DT_DIR
%72 = icmp ne i64 %70, %71
br i1 %72, label %73, label %80
73: ; preds = %67
%74 = load %struct.dirent*, %struct.dirent** %15
%75 = getelementptr inbounds %struct.dirent, %struct.dirent* %74, i32 0, i32 1
%76 = load i64, i64* %75
%77 = load i64, i64* @DT_LNK
%78 = icmp ne i64 %76, %77
br i1 %78, label %79, label %80
79: ; preds = %73
br label %109
80: ; preds = %73, %67
%81 = load %struct.dirent*, %struct.dirent** %15
%82 = getelementptr inbounds %struct.dirent, %struct.dirent* %81, i32 0, i32 0
%83 = load i8*, i8** %82
%84 = call i64 @strncmp(i8* %83, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %80
br label %109
87: ; preds = %80
%88 = load %struct.dirent*, %struct.dirent** %15
%89 = getelementptr inbounds %struct.dirent, %struct.dirent* %88, i32 0, i32 0
%90 = load i8*, i8** %89
%91 = getelementptr inbounds i8, i8* %90, i64 4
%92 = call i32 @strtoul(i8* %91, i8** %17, i32 10)
store i32 %92, i32* %18
%93 = load i8*, i8** %17
%94 = getelementptr inbounds i8, i8* %93, i64 0
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %87
br label %109
99: ; preds = %87
%100 = load i32, i32* %16
%101 = icmp eq i32 %100, -1
br i1 %101, label %106, label %102
102: ; preds = %99
%103 = load i32, i32* %18
%104 = load i32, i32* %16
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %108
106: ; preds = %102, %99
%107 = load i32, i32* %18
store i32 %107, i32* %16
br label %108
108: ; preds = %106, %102
br label %109
109: ; preds = %108, %98, %86, %79, %66
%110 = load i32*, i32** %14
%111 = call %struct.dirent* @readdir(i32* %110)
store %struct.dirent* %111, %struct.dirent** %15
br label %55
112: ; preds = %55
%113 = load i32*, i32** %14
%114 = call i32 @closedir(i32* %113)
%115 = load i32, i32* %16
%116 = icmp eq i32 %115, -1
br i1 %116, label %117, label %118
117: ; preds = %112
store %struct.udev_device* null, %struct.udev_device** %4
br label %128
118: ; preds = %112
%119 = load i32, i32* %16
%120 = load i32, i32* %7
%121 = sub nsw i32 %120, %119
store i32 %121, i32* %7
%122 = load i8**, i8*** %5
%123 = load i32, i32* %7
%124 = load i32, i32* %8
%125 = load i32, i32* %9
%126 = load i32, i32* %10
%127 = call i32 @path_prepend(i8** %122, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %123, i32 %124, i32 %125, i32 %126)
br label %128
128: ; preds = %118, %117, %51, %43
%129 = load i8*, i8** %12
%130 = call i32 @free(i8* %129)
%131 = load %struct.udev_device*, %struct.udev_device** %6
store %struct.udev_device* %131, %struct.udev_device** %3
br label %132
132: ; preds = %128, %37, %30, %23
%133 = load %struct.udev_device*, %struct.udev_device** %3
ret %struct.udev_device* %133
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
%struct.dirent = type { i8*, i64 }
@.str = [5 x i8] c"scsi\00"
@.str.1 = [10 x i8] c"scsi_host\00"
@.str.2 = [12 x i8] c"%d:%d:%d:%d\00"
@DT_DIR = global i64 0
@DT_LNK = global i64 0
@.str.3 = [5 x i8] c"host\00"
@.str.4 = [17 x i8] c"scsi-%u:%u:%u:%u\00"
define %struct.udev_device* @handle_scsi_default(%struct.udev_device* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = tail call %struct.udev_device* @udev_device_get_parent_with_subsystem_devtype(%struct.udev_device* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq %struct.udev_device* %12, null
br i1 %13, label %81, label %14
14: ; preds = %2
%15 = tail call i8* @udev_device_get_sysname(%struct.udev_device* %0)
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%17 = icmp eq i32 %16, 4
br i1 %17, label %18, label %81
18: ; preds = %14
%19 = call i32 @udev_device_get_syspath(%struct.udev_device* %12)
%20 = call i8* @strdup(i32 %19)
%21 = icmp eq i8* %20, null
br i1 %21, label %81, label %22
22: ; preds = %18
%23 = call i8* @strrchr(i8* %20, i8 signext 47)
%24 = icmp eq i8* %23, null
br i1 %24, label %79, label %25
25: ; preds = %22
store i8 0, i8* %23
%26 = call i32* @opendir(i8* %20)
%27 = icmp eq i32* %26, null
br i1 %27, label %79, label %28
28: ; preds = %25
%29 = call %struct.dirent* @readdir(i32* %26)
%30 = icmp eq %struct.dirent* %29, null
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @closedir(i32* %26)
br label %79
33: ; preds = %28
%34 = bitcast i8** %7 to i8*
br label %35
35: ; preds = %33, %65
%36 = phi i32 [ -1, %33 ], [ %66, %65 ]
%37 = phi %struct.dirent* [ %29, %33 ], [ %67, %65 ]
%38 = getelementptr inbounds %struct.dirent, %struct.dirent* %37, i64 0, i32 0
%39 = load i8*, i8** %38
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 46
br i1 %41, label %65, label %42
42: ; preds = %35
%43 = getelementptr inbounds %struct.dirent, %struct.dirent* %37, i64 0, i32 1
%44 = load i64, i64* %43
%45 = load i64, i64* @DT_DIR
%46 = icmp eq i64 %44, %45
%47 = load i64, i64* @DT_LNK
%48 = icmp eq i64 %44, %47
%49 = select i1 %46, i1 true, i1 %48
br i1 %49, label %50, label %65
50: ; preds = %42
%51 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %65
53: ; preds = %50
%54 = load i8*, i8** %38
%55 = getelementptr inbounds i8, i8* %54, i64 4
%56 = call i32 @strtoul(i8* %55, i8** %7, i32 10)
%57 = load i8*, i8** %7
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %53
%61 = icmp eq i32 %36, -1
%62 = icmp slt i32 %56, %36
%63 = select i1 %61, i1 true, i1 %62
%64 = select i1 %63, i32 %56, i32 %36
br label %65
65: ; preds = %53, %50, %42, %35, %60
%66 = phi i32 [ %64, %60 ], [ %36, %35 ], [ %36, %42 ], [ %36, %50 ], [ %36, %53 ]
%67 = call %struct.dirent* @readdir(i32* %26)
%68 = icmp eq %struct.dirent* %67, null
br i1 %68, label %69, label %35
69: ; preds = %65
%70 = call i32 @closedir(i32* %26)
%71 = icmp eq i32 %66, -1
br i1 %71, label %79, label %72
72: ; preds = %69
%73 = load i32, i32* %3
%74 = sub nsw i32 %73, %66
store i32 %74, i32* %3
%75 = load i32, i32* %4
%76 = load i32, i32* %5
%77 = load i32, i32* %6
%78 = call i32 @path_prepend(i8** %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %74, i32 %75, i32 %76, i32 %77)
br label %79
79: ; preds = %31, %69, %25, %22, %72
%80 = call i32 @free(i8* %20)
br label %81
81: ; preds = %18, %14, %2, %79
%82 = phi %struct.udev_device* [ %12, %79 ], [ null, %2 ], [ null, %14 ], [ null, %18 ]
ret %struct.udev_device* %82
}