#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 */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ errno;
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 *);
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;
    } else
      errno = EINVAL;
    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    151d <udev_device_new_from_subsystem_sysname+0x3bd>
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    151d <udev_device_new_from_subsystem_sysname+0x3bd>
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    151d <udev_device_new_from_subsystem_sysname+0x3bd>
jmp    1510 <udev_device_new_from_subsystem_sysname+0x3b0>
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    151d <udev_device_new_from_subsystem_sysname+0x3bd>
jmp    1510 <udev_device_new_from_subsystem_sysname+0x3b0>
mov    -0x18(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    140c <udev_device_new_from_subsystem_sysname+0x2ac>
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    151d <udev_device_new_from_subsystem_sysname+0x3bd>
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    151d <udev_device_new_from_subsystem_sysname+0x3bd>
jmp    1407 <udev_device_new_from_subsystem_sysname+0x2a7>
mov    0x2bdc(%rip),%rax
mov    (%rax),%ecx
mov    0x2bdb(%rip),%rax
mov    %ecx,(%rax)
jmp    1510 <udev_device_new_from_subsystem_sysname+0x3b0>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r9
mov    $0x400,%esi
lea    0xbe3(%rip),%rdx
lea    0xc28(%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    1461 <udev_device_new_from_subsystem_sysname+0x301>
jmp    151d <udev_device_new_from_subsystem_sysname+0x3bd>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r9
mov    $0x400,%esi
lea    0xb9e(%rip),%rdx
lea    0xbd3(%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    14b6 <udev_device_new_from_subsystem_sysname+0x356>
jmp    151d <udev_device_new_from_subsystem_sysname+0x3bd>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r9
mov    $0x400,%esi
lea    0xb53(%rip),%rdx
lea    0xb6a(%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    150b <udev_device_new_from_subsystem_sysname+0x3ab>
jmp    151d <udev_device_new_from_subsystem_sysname+0x3bd>
jmp    1510 <udev_device_new_from_subsystem_sysname+0x3b0>
movq   $0x0,-0x8(%rbp)
jmp    1531 <udev_device_new_from_subsystem_sysname+0x3d1>
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     1425 <udev_device_new_from_subsystem_sysname+0x2c5>
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
jne    1437 <udev_device_new_from_subsystem_sysname+0x2d7>
jmp    1332 <udev_device_new_from_subsystem_sysname+0x1d2>
mov    0x2bac(%rip),%rax
mov    (%rax),%eax
mov    0x2bab(%rip),%rcx
mov    %eax,(%rcx)
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"
@EINVAL = global i32 0
@errno = global i32 0
@.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 %120
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 %120
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 %120
39: ; preds = %31
br label %119
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 %120
52: ; preds = %44
br label %119
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 %91
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 %120
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 %120
87: ; preds = %78
br label %90
88: ; preds = %57
%89 = load i32, i32* @EINVAL
store i32 %89, i32* @errno
br label %90
90: ; preds = %88, %87
br label %119
91: ; preds = %53
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%93 = load i8*, i8** %6
%94 = load i8*, i8** %7
%95 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %92, i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %93, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %94, i8* null)
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%97 = call i64 @stat(i8* %96, %struct.stat* %9)
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %100
99: ; preds = %91
br label %120
100: ; preds = %91
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%102 = load i8*, i8** %6
%103 = load i8*, i8** %7
%104 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %101, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %102, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %103, i8* null)
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%106 = call i64 @stat(i8* %105, %struct.stat* %9)
%107 = icmp eq i64 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %100
br label %120
109: ; preds = %100
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%111 = load i8*, i8** %6
%112 = load i8*, i8** %7
%113 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @strscpyl(i8* %110, i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %112, i8* null)
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%115 = call i64 @stat(i8* %114, %struct.stat* %9)
%116 = icmp eq i64 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %109
br label %120
118: ; preds = %109
br label %119
119: ; preds = %118, %90, %52, %39
store %struct.udev_device* null, %struct.udev_device** %4
br label %124
120: ; preds = %117, %108, %99, %86, %77, %51, %38, %30, %22
%121 = load %struct.udev*, %struct.udev** %5
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%123 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %121, i8* %122)
store %struct.udev_device* %123, %struct.udev_device** %4
br label %124
124: ; preds = %120, %119
%125 = load %struct.udev_device*, %struct.udev_device** %4
ret %struct.udev_device* %125
}

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"
@EINVAL = global i32 0
@errno = global i32 0
@.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 %63, 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 %63, 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 %63, label %65
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 %63, label %65
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 %51
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 %47, 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 %49, 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 %49, label %50
47: ; preds = %33
%48 = load i32, i32* @EINVAL
store i32 %48, i32* @errno
br label %50
49: ; preds = %38, %43
br label %63
50: ; preds = %47, %43
br label %65
51: ; preds = %30
%52 = 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)
%53 = call i64 @stat(i8* %7, %struct.stat* %5)
%54 = icmp eq i64 %53, 0
br i1 %54, label %63, label %55
55: ; preds = %51
%56 = 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)
%57 = call i64 @stat(i8* %7, %struct.stat* %5)
%58 = icmp eq i64 %57, 0
br i1 %58, label %63, label %59
59: ; preds = %55
%60 = 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)
%61 = call i64 @stat(i8* %7, %struct.stat* %5)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %49, %59, %55, %51, %26, %19, %15, %11
%64 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %0, i8* %7)
br label %65
65: ; preds = %50, %19, %26, %59, %63
%66 = phi %struct.udev_device* [ %64, %63 ], [ null, %50 ], [ null, %59 ], [ null, %26 ], [ null, %19 ]
ret %struct.udev_device* %66
}