#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 */
typedef int /*<<< orphan*/ subsys;
struct udev_device {
  int dummy;
};
struct udev {
  int dummy;
};
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ path;

/* Variables and functions */
scalar_t__ stat(char *, struct stat *);
char *strchr(char *, char);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strscpy(char *, int, char const *);
int /*<<< orphan*/ strscpyl(char *, int, char *, char const *, char *, ...);
struct udev_device *udev_device_new_from_syspath(struct udev *, char *);
__attribute__((visibility("default"))) struct udev_device *
udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem,
                                       const char *sysname) {
  char path[1024];
  struct stat statbuf;
  if ((strcmp((subsystem), ("subsystem")) == 0)) {
    strscpyl(path, sizeof(path), "/sys/subsystem/", sysname, NULL);
    if (stat(path, &statbuf) == 0)
      goto found;
    strscpyl(path, sizeof(path), "/sys/bus/", sysname, NULL);
    if (stat(path, &statbuf) == 0)
      goto found;
    strscpyl(path, sizeof(path), "/sys/class/", sysname, NULL);
    if (stat(path, &statbuf) == 0)
      goto found;
    goto out;
  }
  if ((strcmp((subsystem), ("module")) == 0)) {
    strscpyl(path, sizeof(path), "/sys/module/", sysname, NULL);
    if (stat(path, &statbuf) == 0)
      goto found;
    goto out;
  }
  if ((strcmp((subsystem), ("drivers")) == 0)) {
    char subsys[512];
    char *driver;
    strscpy(subsys, sizeof(subsys), sysname);
    driver = strchr(subsys, ':');
    if (driver != NULL) {
      driver[0] = '\0';
      driver = &driver[1];
      strscpyl(path, sizeof(path), "/sys/subsystem/", subsys, "/drivers/",
               driver, NULL);
      if (stat(path, &statbuf) == 0)
        goto found;
      strscpyl(path, sizeof(path), "/sys/bus/", subsys, "/drivers/", driver,
               NULL);
      if (stat(path, &statbuf) == 0)
        goto found;
    }
    goto out;
  }
  strscpyl(path, sizeof(path), "/sys/subsystem/", subsystem, "/devices/",
           sysname, NULL);
  if (stat(path, &statbuf) == 0)
    goto found;
  strscpyl(path, sizeof(path), "/sys/bus/", subsystem, "/devices/", sysname,
           NULL);
  if (stat(path, &statbuf) == 0)
    goto found;
  strscpyl(path, sizeof(path), "/sys/class/", subsystem, "/", sysname, NULL);
  if (stat(path, &statbuf) == 0)
    goto found;
out:
  return NULL;
found:
  return udev_device_new_from_syspath(udev, path);
}


x86 assembly (clang, -O0):
<udev_device_new_from_subsystem_sysname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x640,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <udev_device_new_from_subsystem_sysname+0x105>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x400,%esi
lea    0xe62(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    11d6 <udev_device_new_from_subsystem_sysname+0x76>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x400,%esi
lea    0xe2d(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    121b <udev_device_new_from_subsystem_sysname+0xbb>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x400,%esi
lea    0xdf2(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    1260 <udev_device_new_from_subsystem_sysname+0x100>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
jmp    14fe <udev_device_new_from_subsystem_sysname+0x39e>
mov    -0x18(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12c9 <udev_device_new_from_subsystem_sysname+0x169>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x400,%esi
lea    0xda1(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    12c4 <udev_device_new_from_subsystem_sysname+0x164>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
jmp    14fe <udev_device_new_from_subsystem_sysname+0x39e>
mov    -0x18(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    13fa <udev_device_new_from_subsystem_sysname+0x29a>
lea    -0x630(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x200,%esi
call   1080 <strscpy@plt>
lea    -0x630(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x638(%rbp)
cmpq   $0x0,-0x638(%rbp)
je     13f5 <udev_device_new_from_subsystem_sysname+0x295>
mov    -0x638(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x638(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x638(%rbp)
lea    -0x420(%rbp),%rdi
lea    -0x630(%rbp),%rcx
mov    -0x638(%rbp),%r9
mov    $0x400,%esi
lea    0xcaf(%rip),%rdx
lea    0xcea(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    1395 <udev_device_new_from_subsystem_sysname+0x235>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
lea    -0x420(%rbp),%rdi
lea    -0x630(%rbp),%rcx
mov    -0x638(%rbp),%r9
mov    $0x400,%esi
lea    0xc64(%rip),%rdx
lea    0xc8f(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    13f0 <udev_device_new_from_subsystem_sysname+0x290>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
jmp    13f5 <udev_device_new_from_subsystem_sysname+0x295>
jmp    14fe <udev_device_new_from_subsystem_sysname+0x39e>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r9
mov    $0x400,%esi
lea    0xbf5(%rip),%rdx
lea    0xc3a(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    144f <udev_device_new_from_subsystem_sysname+0x2ef>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r9
mov    $0x400,%esi
lea    0xbb0(%rip),%rdx
lea    0xbe5(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    14a4 <udev_device_new_from_subsystem_sysname+0x344>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r9
mov    $0x400,%esi
lea    0xb65(%rip),%rdx
lea    0xb7c(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1070 <strscpyl@plt>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    14f9 <udev_device_new_from_subsystem_sysname+0x399>
jmp    150b <udev_device_new_from_subsystem_sysname+0x3ab>
jmp    14fe <udev_device_new_from_subsystem_sysname+0x39e>
movq   $0x0,-0x8(%rbp)
jmp    151f <udev_device_new_from_subsystem_sysname+0x3bf>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1060 <udev_device_new_from_syspath@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x640,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_new_from_subsystem_sysname>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x610,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     128d <udev_device_new_from_subsystem_sysname+0x12d>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12fc <udev_device_new_from_subsystem_sysname+0x19c>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1356 <udev_device_new_from_subsystem_sysname+0x1f6>
movq   $0x0,(%rsp)
lea    0xe3a(%rip),%rdx
lea    0xe7f(%rip),%r8
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rbx,%rcx
mov    %r15,%r9
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     1332 <udev_device_new_from_subsystem_sysname+0x1d2>
movq   $0x0,(%rsp)
lea    0xe04(%rip),%rdx
lea    0xe39(%rip),%r8
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rbx,%rcx
mov    %r15,%r9
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     1332 <udev_device_new_from_subsystem_sysname+0x1d2>
movq   $0x0,(%rsp)
lea    0xdc8(%rip),%rdx
lea    0xddf(%rip),%r8
xor    %r12d,%r12d
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    $0x400,%esi
mov    %rbx,%rcx
mov    %r15,%r9
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %r13,%rdi
jmp    1328 <udev_device_new_from_subsystem_sysname+0x1c8>
lea    0xd76(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     1332 <udev_device_new_from_subsystem_sysname+0x1d2>
lea    0xd53(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     1332 <udev_device_new_from_subsystem_sysname+0x1d2>
lea    0xd2a(%rip),%rdx
jmp    1303 <udev_device_new_from_subsystem_sysname+0x1a3>
lea    0xd34(%rip),%rdx
xor    %r12d,%r12d
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
test   %rax,%rax
jne    1342 <udev_device_new_from_subsystem_sysname+0x1e2>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1060 <udev_device_new_from_syspath@plt>
mov    %rax,%r12
mov    %r12,%rax
add    $0x610,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0x410(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1080 <strscpy@plt>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1424 <udev_device_new_from_subsystem_sysname+0x2c4>
mov    %rax,%rbx
movb   $0x0,(%rax)
add    $0x1,%rbx
movq   $0x0,(%rsp)
lea    0xc6d(%rip),%rdx
lea    0xca8(%rip),%r8
lea    0x10(%rsp),%r15
lea    0x410(%rsp),%rcx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%r9
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     1332 <udev_device_new_from_subsystem_sysname+0x1d2>
movq   $0x0,(%rsp)
lea    0xc32(%rip),%rdx
lea    0xc5d(%rip),%r8
lea    0x10(%rsp),%r15
lea    0x410(%rsp),%rcx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%r9
xor    %eax,%eax
call   1070 <strscpyl@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     1332 <udev_device_new_from_subsystem_sysname+0x1d2>
xor    %r12d,%r12d
jmp    1342 <udev_device_new_from_subsystem_sysname+0x1e2>

LLVM IR (-O0):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.stat = type { i32 }
@.str = [10 x i8] c"subsystem\00"
@.str.1 = [16 x i8] c"/sys/subsystem/\00"
@.str.2 = [10 x i8] c"/sys/bus/\00"
@.str.3 = [12 x i8] c"/sys/class/\00"
@.str.4 = [7 x i8] c"module\00"
@.str.5 = [13 x i8] c"/sys/module/\00"
@.str.6 = [8 x i8] c"drivers\00"
@.str.7 = [10 x i8] c"/drivers/\00"
@.str.8 = [10 x i8] c"/devices/\00"
@.str.9 = [2 x i8] c"/\00"
define %struct.udev_device* @udev_device_new_from_subsystem_sysname(%struct.udev* %0, i8* %1, i8* %2) {
%4 = alloca %struct.udev_device*
%5 = alloca %struct.udev*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [1024 x i8]
%9 = alloca %struct.stat
%10 = alloca [512 x i8]
%11 = alloca i8*
store %struct.udev* %0, %struct.udev** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = load i8*, i8** %6
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %40
15: ; preds = %3
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%17 = load i8*, i8** %7
%18 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %16, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* null)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = call i64 @stat(i8* %19, %struct.stat* %9)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
br label %118
23: ; preds = %15
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%25 = load i8*, i8** %7
%26 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %24, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* null)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%28 = call i64 @stat(i8* %27, %struct.stat* %9)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
br label %118
31: ; preds = %23
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%33 = load i8*, i8** %7
%34 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %32, i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %33, i8* null)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%36 = call i64 @stat(i8* %35, %struct.stat* %9)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %31
br label %118
39: ; preds = %31
br label %117
40: ; preds = %3
%41 = load i8*, i8** %6
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %40
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%46 = load i8*, i8** %7
%47 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %45, i32 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %46, i8* null)
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%49 = call i64 @stat(i8* %48, %struct.stat* %9)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %44
br label %118
52: ; preds = %44
br label %117
53: ; preds = %40
%54 = load i8*, i8** %6
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %89
57: ; preds = %53
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%59 = load i8*, i8** %7
%60 = call i32 @strscpy(i8* %58, i32 512, i8* %59)
%61 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%62 = call i8* @strchr(i8* %61, i8 signext 58)
store i8* %62, i8** %11
%63 = load i8*, i8** %11
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %88
65: ; preds = %57
%66 = load i8*, i8** %11
%67 = getelementptr inbounds i8, i8* %66, i64 0
store i8 0, i8* %67
%68 = load i8*, i8** %11
%69 = getelementptr inbounds i8, i8* %68, i64 1
store i8* %69, i8** %11
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%71 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%72 = load i8*, i8** %11
%73 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %70, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %71, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %72, i8* null)
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%75 = call i64 @stat(i8* %74, %struct.stat* %9)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %65
br label %118
78: ; preds = %65
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%80 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%81 = load i8*, i8** %11
%82 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %79, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %80, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %81, i8* null)
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%84 = call i64 @stat(i8* %83, %struct.stat* %9)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %78
br label %118
87: ; preds = %78
br label %88
88: ; preds = %87, %57
br label %117
89: ; preds = %53
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%91 = load i8*, i8** %6
%92 = load i8*, i8** %7
%93 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %90, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %91, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %92, i8* null)
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%95 = call i64 @stat(i8* %94, %struct.stat* %9)
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %98
97: ; preds = %89
br label %118
98: ; preds = %89
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%100 = load i8*, i8** %6
%101 = load i8*, i8** %7
%102 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %99, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %101, i8* null)
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%104 = call i64 @stat(i8* %103, %struct.stat* %9)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %107
106: ; preds = %98
br label %118
107: ; preds = %98
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%109 = load i8*, i8** %6
%110 = load i8*, i8** %7
%111 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %108, i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %110, i8* null)
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%113 = call i64 @stat(i8* %112, %struct.stat* %9)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %116
115: ; preds = %107
br label %118
116: ; preds = %107
br label %117
117: ; preds = %116, %88, %52, %39
store %struct.udev_device* null, %struct.udev_device** %4
br label %122
118: ; preds = %115, %106, %97, %86, %77, %51, %38, %30, %22
%119 = load %struct.udev*, %struct.udev** %5
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%121 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %119, i8* %120)
store %struct.udev_device* %121, %struct.udev_device** %4
br label %122
122: ; preds = %118, %117
%123 = load %struct.udev_device*, %struct.udev_device** %4
ret %struct.udev_device* %123
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.stat = type { i32 }
@.str = [10 x i8] c"subsystem\00"
@.str.1 = [16 x i8] c"/sys/subsystem/\00"
@.str.2 = [10 x i8] c"/sys/bus/\00"
@.str.3 = [12 x i8] c"/sys/class/\00"
@.str.4 = [7 x i8] c"module\00"
@.str.5 = [13 x i8] c"/sys/module/\00"
@.str.6 = [8 x i8] c"drivers\00"
@.str.7 = [10 x i8] c"/drivers/\00"
@.str.8 = [10 x i8] c"/devices/\00"
@.str.9 = [2 x i8] c"/\00"
define %struct.udev_device* @udev_device_new_from_subsystem_sysname(%struct.udev* %0, i8* %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = alloca %struct.stat
%6 = alloca [512 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = bitcast %struct.stat* %5 to i8*
%9 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %3
%12 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* null)
%13 = call i64 @stat(i8* %7, %struct.stat* %5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %61, label %15
15: ; preds = %11
%16 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* null)
%17 = call i64 @stat(i8* %7, %struct.stat* %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %61, label %19
19: ; preds = %15
%20 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* null)
%21 = call i64 @stat(i8* %7, %struct.stat* %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %61, label %63
23: ; preds = %3
%24 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* null)
%28 = call i64 @stat(i8* %7, %struct.stat* %5)
%29 = icmp eq i64 %28, 0
br i1 %29, label %61, label %63
30: ; preds = %23
%31 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %49
33: ; preds = %30
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%35 = call i32 @strscpy(i8* %34, i32 512, i8* %2)
%36 = call i8* @strchr(i8* %34, i8 signext 58)
%37 = icmp eq i8* %36, null
br i1 %37, label %48, label %38
38: ; preds = %33
store i8 0, i8* %36
%39 = getelementptr inbounds i8, i8* %36, i64 1
%40 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %39, i8* null)
%41 = call i64 @stat(i8* %7, %struct.stat* %5)
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %38
%44 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %39, i8* null)
%45 = call i64 @stat(i8* %7, %struct.stat* %5)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %38, %43
br label %61
48: ; preds = %33, %43
br label %63
49: ; preds = %30
%50 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %2, i8* null)
%51 = call i64 @stat(i8* %7, %struct.stat* %5)
%52 = icmp eq i64 %51, 0
br i1 %52, label %61, label %53
53: ; preds = %49
%54 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %2, i8* null)
%55 = call i64 @stat(i8* %7, %struct.stat* %5)
%56 = icmp eq i64 %55, 0
br i1 %56, label %61, label %57
57: ; preds = %53
%58 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %7, i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %2, i8* null)
%59 = call i64 @stat(i8* %7, %struct.stat* %5)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %47, %57, %53, %49, %26, %19, %15, %11
%62 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %0, i8* %7)
br label %63
63: ; preds = %48, %19, %26, %57, %61
%64 = phi %struct.udev_device* [ %62, %61 ], [ null, %48 ], [ null, %57 ], [ null, %26 ], [ null, %19 ]
ret %struct.udev_device* %64
}