#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_full;

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


x86 assembly (clang, -O0):
<udev_device_new_from_subsystem_sysname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x650,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x650(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <udev_get_sys_path@plt>
mov    -0x650(%rbp),%rdi
mov    %rax,%rsi
mov    $0x400,%edx
call   1080 <util_strlcpy@plt>
mov    %rax,-0x28(%rbp)
lea    -0x430(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12f8 <udev_device_new_from_subsystem_sysname+0x188>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xe0f(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    123d <udev_device_new_from_subsystem_sysname+0xcd>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xdc0(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    1298 <udev_device_new_from_subsystem_sysname+0x128>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xd6b(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    12f3 <udev_device_new_from_subsystem_sysname+0x183>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
jmp    16e2 <udev_device_new_from_subsystem_sysname+0x572>
mov    -0x18(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1372 <udev_device_new_from_subsystem_sysname+0x202>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xd00(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    136d <udev_device_new_from_subsystem_sysname+0x1fd>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
jmp    16e2 <udev_device_new_from_subsystem_sysname+0x572>
mov    -0x18(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1521 <udev_device_new_from_subsystem_sysname+0x3b1>
lea    -0x640(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x200,%edx
call   1080 <util_strlcpy@plt>
lea    -0x640(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x648(%rbp)
cmpq   $0x0,-0x648(%rbp)
je     151c <udev_device_new_from_subsystem_sysname+0x3ac>
mov    -0x648(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x648(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x648(%rbp)
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xc0e(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
lea    -0x640(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xc04(%rip),%rsi
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    -0x648(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    147d <udev_device_new_from_subsystem_sysname+0x30d>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xb80(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
lea    -0x640(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xb6a(%rip),%rsi
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    -0x648(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    1517 <udev_device_new_from_subsystem_sysname+0x3a7>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
jmp    151c <udev_device_new_from_subsystem_sysname+0x3ac>
jmp    16e2 <udev_device_new_from_subsystem_sysname+0x572>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xad0(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xad3(%rip),%rsi
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    15b5 <udev_device_new_from_subsystem_sysname+0x445>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xa48(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xa3f(%rip),%rsi
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    1649 <udev_device_new_from_subsystem_sysname+0x4d9>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0x9ba(%rip),%rsi
call   1080 <util_strlcpy@plt>
mov    -0x438(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0x997(%rip),%rsi
call   1090 <util_strlcat@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x400,%eax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1090 <util_strlcat@plt>
lea    -0x430(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    16dd <udev_device_new_from_subsystem_sysname+0x56d>
jmp    16ef <udev_device_new_from_subsystem_sysname+0x57f>
jmp    16e2 <udev_device_new_from_subsystem_sysname+0x572>
movq   $0x0,-0x8(%rbp)
jmp    1703 <udev_device_new_from_subsystem_sysname+0x593>
mov    -0x10(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1070 <udev_device_new_from_syspath@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x650,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_new_from_subsystem_sysname>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x618,%rsp
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r14
call   1030 <udev_get_sys_path@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%ebp
mov    %rax,%rsi
mov    $0x400,%edx
call   1080 <util_strlcpy@plt>
mov    %rax,%rbx
lea    (%rsp,%rax,1),%r12
add    $0x10,%r12
lea    0xe48(%rip),%rsi
mov    %r13,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12d2 <udev_device_new_from_subsystem_sysname+0x162>
lea    0xe54(%rip),%rsi
mov    %r13,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1349 <udev_device_new_from_subsystem_sysname+0x1d9>
lea    0xe4c(%rip),%rsi
mov    %r13,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1366 <udev_device_new_from_subsystem_sysname+0x1f6>
mov    $0x400,%ebp
sub    %ebx,%ebp
lea    0xe03(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0xe21(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     1453 <udev_device_new_from_subsystem_sysname+0x2e3>
lea    0xdbb(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0xdcd(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     1453 <udev_device_new_from_subsystem_sysname+0x2e3>
lea    0xd6d(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0xd65(%rip),%rsi
jmp    1424 <udev_device_new_from_subsystem_sysname+0x2b4>
sub    %ebx,%ebp
lea    0xd2f(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     1453 <udev_device_new_from_subsystem_sysname+0x2e3>
lea    0xd05(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     1453 <udev_device_new_from_subsystem_sysname+0x2e3>
lea    0xcd5(%rip),%rsi
jmp    1357 <udev_device_new_from_subsystem_sysname+0x1e7>
mov    $0x400,%ebp
sub    %ebx,%ebp
lea    0xcd4(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
jmp    142e <udev_device_new_from_subsystem_sysname+0x2be>
lea    0x410(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x200,%edx
call   1080 <util_strlcpy@plt>
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     144f <udev_device_new_from_subsystem_sysname+0x2df>
mov    %rax,%r15
movb   $0x0,(%rax)
add    $0x1,%r15
mov    $0x400,%ebp
sub    %ebx,%ebp
lea    0xc5e(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
lea    0x410(%rsp),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0xc6d(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     1453 <udev_device_new_from_subsystem_sysname+0x2e3>
lea    0xc15(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <util_strlcpy@plt>
lea    0x410(%rsp),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0xc18(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <util_strlcat@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     1453 <udev_device_new_from_subsystem_sysname+0x2e3>
xor    %eax,%eax
jmp    1460 <udev_device_new_from_subsystem_sysname+0x2f0>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1070 <udev_device_new_from_syspath@plt>
add    $0x618,%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.stat = type { i32 }
@.str = [10 x i8] c"subsystem\00"
@.str.1 = [12 x i8] c"/subsystem/\00"
@.str.2 = [6 x i8] c"/bus/\00"
@.str.3 = [8 x i8] c"/class/\00"
@.str.4 = [7 x i8] c"module\00"
@.str.5 = [9 x i8] c"/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 i64
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca %struct.stat
%12 = alloca [512 x i8]
%13 = alloca i8*
store %struct.udev* %0, %struct.udev** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%15 = load %struct.udev*, %struct.udev** %5
%16 = call i8* @udev_get_sys_path(%struct.udev* %15)
%17 = call i64 @util_strlcpy(i8* %14, i8* %16, i32 1024)
store i64 %17, i64* %8
%18 = load i64, i64* %8
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 %18
store i8* %19, i8** %10
%20 = load i8*, i8** %6
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %72
23: ; preds = %3
%24 = load i8*, i8** %10
%25 = load i64, i64* %8
%26 = sub i64 1024, %25
%27 = trunc i64 %26 to i32
%28 = call i64 @util_strlcpy(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i8*, i8** %10
%30 = load i8*, i8** %7
%31 = load i64, i64* %8
%32 = sub i64 1024, %31
%33 = trunc i64 %32 to i32
%34 = call i32 @util_strlcat(i8* %29, i8* %30, i32 %33)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%36 = call i64 @stat(i8* %35, %struct.stat* %11)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %23
br label %248
39: ; preds = %23
%40 = load i8*, i8** %10
%41 = load i64, i64* %8
%42 = sub i64 1024, %41
%43 = trunc i64 %42 to i32
%44 = call i64 @util_strlcpy(i8* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = load i8*, i8** %10
%46 = load i8*, i8** %7
%47 = load i64, i64* %8
%48 = sub i64 1024, %47
%49 = trunc i64 %48 to i32
%50 = call i32 @util_strlcat(i8* %45, i8* %46, i32 %49)
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%52 = call i64 @stat(i8* %51, %struct.stat* %11)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %39
br label %248
55: ; preds = %39
%56 = load i8*, i8** %10
%57 = load i64, i64* %8
%58 = sub i64 1024, %57
%59 = trunc i64 %58 to i32
%60 = call i64 @util_strlcpy(i8* %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = load i8*, i8** %10
%62 = load i8*, i8** %7
%63 = load i64, i64* %8
%64 = sub i64 1024, %63
%65 = trunc i64 %64 to i32
%66 = call i32 @util_strlcat(i8* %61, i8* %62, i32 %65)
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%68 = call i64 @stat(i8* %67, %struct.stat* %11)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %55
br label %248
71: ; preds = %55
br label %247
72: ; preds = %3
%73 = load i8*, i8** %6
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %93
76: ; preds = %72
%77 = load i8*, i8** %10
%78 = load i64, i64* %8
%79 = sub i64 1024, %78
%80 = trunc i64 %79 to i32
%81 = call i64 @util_strlcpy(i8* %77, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %80)
%82 = load i8*, i8** %10
%83 = load i8*, i8** %7
%84 = load i64, i64* %8
%85 = sub i64 1024, %84
%86 = trunc i64 %85 to i32
%87 = call i32 @util_strlcat(i8* %82, i8* %83, i32 %86)
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%89 = call i64 @stat(i8* %88, %struct.stat* %11)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %92
91: ; preds = %76
br label %248
92: ; preds = %76
br label %247
93: ; preds = %72
%94 = load i8*, i8** %6
%95 = call i64 @strcmp(i8* %94, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %165
97: ; preds = %93
%98 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%99 = load i8*, i8** %7
%100 = call i64 @util_strlcpy(i8* %98, i8* %99, i32 512)
%101 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%102 = call i8* @strchr(i8* %101, i8 signext 58)
store i8* %102, i8** %13
%103 = load i8*, i8** %13
%104 = icmp ne i8* %103, null
br i1 %104, label %105, label %164
105: ; preds = %97
%106 = load i8*, i8** %13
%107 = getelementptr inbounds i8, i8* %106, i64 0
store i8 0, i8* %107
%108 = load i8*, i8** %13
%109 = getelementptr inbounds i8, i8* %108, i64 1
store i8* %109, i8** %13
%110 = load i8*, i8** %10
%111 = load i64, i64* %8
%112 = sub i64 1024, %111
%113 = trunc i64 %112 to i32
%114 = call i64 @util_strlcpy(i8* %110, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %113)
%115 = load i8*, i8** %10
%116 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%117 = load i64, i64* %8
%118 = sub i64 1024, %117
%119 = trunc i64 %118 to i32
%120 = call i32 @util_strlcat(i8* %115, i8* %116, i32 %119)
%121 = load i8*, i8** %10
%122 = load i64, i64* %8
%123 = sub i64 1024, %122
%124 = trunc i64 %123 to i32
%125 = call i32 @util_strlcat(i8* %121, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %124)
%126 = load i8*, i8** %10
%127 = load i8*, i8** %13
%128 = load i64, i64* %8
%129 = sub i64 1024, %128
%130 = trunc i64 %129 to i32
%131 = call i32 @util_strlcat(i8* %126, i8* %127, i32 %130)
%132 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%133 = call i64 @stat(i8* %132, %struct.stat* %11)
%134 = icmp eq i64 %133, 0
br i1 %134, label %135, label %136
135: ; preds = %105
br label %248
136: ; preds = %105
%137 = load i8*, i8** %10
%138 = load i64, i64* %8
%139 = sub i64 1024, %138
%140 = trunc i64 %139 to i32
%141 = call i64 @util_strlcpy(i8* %137, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %140)
%142 = load i8*, i8** %10
%143 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%144 = load i64, i64* %8
%145 = sub i64 1024, %144
%146 = trunc i64 %145 to i32
%147 = call i32 @util_strlcat(i8* %142, i8* %143, i32 %146)
%148 = load i8*, i8** %10
%149 = load i64, i64* %8
%150 = sub i64 1024, %149
%151 = trunc i64 %150 to i32
%152 = call i32 @util_strlcat(i8* %148, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %151)
%153 = load i8*, i8** %10
%154 = load i8*, i8** %13
%155 = load i64, i64* %8
%156 = sub i64 1024, %155
%157 = trunc i64 %156 to i32
%158 = call i32 @util_strlcat(i8* %153, i8* %154, i32 %157)
%159 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%160 = call i64 @stat(i8* %159, %struct.stat* %11)
%161 = icmp eq i64 %160, 0
br i1 %161, label %162, label %163
162: ; preds = %136
br label %248
163: ; preds = %136
br label %164
164: ; preds = %163, %97
br label %247
165: ; preds = %93
%166 = load i8*, i8** %10
%167 = load i64, i64* %8
%168 = sub i64 1024, %167
%169 = trunc i64 %168 to i32
%170 = call i64 @util_strlcpy(i8* %166, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %169)
%171 = load i8*, i8** %10
%172 = load i8*, i8** %6
%173 = load i64, i64* %8
%174 = sub i64 1024, %173
%175 = trunc i64 %174 to i32
%176 = call i32 @util_strlcat(i8* %171, i8* %172, i32 %175)
%177 = load i8*, i8** %10
%178 = load i64, i64* %8
%179 = sub i64 1024, %178
%180 = trunc i64 %179 to i32
%181 = call i32 @util_strlcat(i8* %177, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %180)
%182 = load i8*, i8** %10
%183 = load i8*, i8** %7
%184 = load i64, i64* %8
%185 = sub i64 1024, %184
%186 = trunc i64 %185 to i32
%187 = call i32 @util_strlcat(i8* %182, i8* %183, i32 %186)
%188 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%189 = call i64 @stat(i8* %188, %struct.stat* %11)
%190 = icmp eq i64 %189, 0
br i1 %190, label %191, label %192
191: ; preds = %165
br label %248
192: ; preds = %165
%193 = load i8*, i8** %10
%194 = load i64, i64* %8
%195 = sub i64 1024, %194
%196 = trunc i64 %195 to i32
%197 = call i64 @util_strlcpy(i8* %193, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %196)
%198 = load i8*, i8** %10
%199 = load i8*, i8** %6
%200 = load i64, i64* %8
%201 = sub i64 1024, %200
%202 = trunc i64 %201 to i32
%203 = call i32 @util_strlcat(i8* %198, i8* %199, i32 %202)
%204 = load i8*, i8** %10
%205 = load i64, i64* %8
%206 = sub i64 1024, %205
%207 = trunc i64 %206 to i32
%208 = call i32 @util_strlcat(i8* %204, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %207)
%209 = load i8*, i8** %10
%210 = load i8*, i8** %7
%211 = load i64, i64* %8
%212 = sub i64 1024, %211
%213 = trunc i64 %212 to i32
%214 = call i32 @util_strlcat(i8* %209, i8* %210, i32 %213)
%215 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%216 = call i64 @stat(i8* %215, %struct.stat* %11)
%217 = icmp eq i64 %216, 0
br i1 %217, label %218, label %219
218: ; preds = %192
br label %248
219: ; preds = %192
%220 = load i8*, i8** %10
%221 = load i64, i64* %8
%222 = sub i64 1024, %221
%223 = trunc i64 %222 to i32
%224 = call i64 @util_strlcpy(i8* %220, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %223)
%225 = load i8*, i8** %10
%226 = load i8*, i8** %6
%227 = load i64, i64* %8
%228 = sub i64 1024, %227
%229 = trunc i64 %228 to i32
%230 = call i32 @util_strlcat(i8* %225, i8* %226, i32 %229)
%231 = load i8*, i8** %10
%232 = load i64, i64* %8
%233 = sub i64 1024, %232
%234 = trunc i64 %233 to i32
%235 = call i32 @util_strlcat(i8* %231, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 %234)
%236 = load i8*, i8** %10
%237 = load i8*, i8** %7
%238 = load i64, i64* %8
%239 = sub i64 1024, %238
%240 = trunc i64 %239 to i32
%241 = call i32 @util_strlcat(i8* %236, i8* %237, i32 %240)
%242 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%243 = call i64 @stat(i8* %242, %struct.stat* %11)
%244 = icmp eq i64 %243, 0
br i1 %244, label %245, label %246
245: ; preds = %219
br label %248
246: ; preds = %219
br label %247
247: ; preds = %246, %164, %92, %71
store %struct.udev_device* null, %struct.udev_device** %4
br label %252
248: ; preds = %245, %218, %191, %162, %135, %91, %70, %54, %38
%249 = load %struct.udev*, %struct.udev** %5
%250 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%251 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %249, i8* %250)
store %struct.udev_device* %251, %struct.udev_device** %4
br label %252
252: ; preds = %248, %247
%253 = load %struct.udev_device*, %struct.udev_device** %4
ret %struct.udev_device* %253
}

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 = [12 x i8] c"/subsystem/\00"
@.str.2 = [6 x i8] c"/bus/\00"
@.str.3 = [8 x i8] c"/class/\00"
@.str.4 = [7 x i8] c"module\00"
@.str.5 = [9 x i8] c"/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 i8* @udev_get_sys_path(%struct.udev* %0)
%10 = call i64 @util_strlcpy(i8* %7, i8* %9, i32 1024)
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %10
%12 = call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %3
%15 = trunc i64 %10 to i32
%16 = sub i32 1024, %15
%17 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = call i32 @util_strlcat(i8* %11, i8* %2, i32 %16)
%19 = call i64 @stat(i8* %7, %struct.stat* %5)
%20 = icmp eq i64 %19, 0
br i1 %20, label %91, label %21
21: ; preds = %14
%22 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%23 = call i32 @util_strlcat(i8* %11, i8* %2, i32 %16)
%24 = call i64 @stat(i8* %7, %struct.stat* %5)
%25 = icmp eq i64 %24, 0
br i1 %25, label %91, label %26
26: ; preds = %21
%27 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%28 = call i32 @util_strlcat(i8* %11, i8* %2, i32 %16)
%29 = call i64 @stat(i8* %7, %struct.stat* %5)
%30 = icmp eq i64 %29, 0
br i1 %30, label %91, label %93
31: ; preds = %3
%32 = call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = trunc i64 %10 to i32
%36 = sub i32 1024, %35
%37 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = call i32 @util_strlcat(i8* %11, i8* %2, i32 %36)
%39 = call i64 @stat(i8* %7, %struct.stat* %5)
%40 = icmp eq i64 %39, 0
br i1 %40, label %91, label %93
41: ; preds = %31
%42 = call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %68
44: ; preds = %41
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%46 = call i64 @util_strlcpy(i8* %45, i8* %2, i32 512)
%47 = call i8* @strchr(i8* %45, i8 signext 58)
%48 = icmp eq i8* %47, null
br i1 %48, label %67, label %49
49: ; preds = %44
store i8 0, i8* %47
%50 = getelementptr inbounds i8, i8* %47, i64 1
%51 = trunc i64 %10 to i32
%52 = sub i32 1024, %51
%53 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = call i32 @util_strlcat(i8* %11, i8* %45, i32 %52)
%55 = call i32 @util_strlcat(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %52)
%56 = call i32 @util_strlcat(i8* %11, i8* %50, i32 %52)
%57 = call i64 @stat(i8* %7, %struct.stat* %5)
%58 = icmp eq i64 %57, 0
br i1 %58, label %66, label %59
59: ; preds = %49
%60 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%61 = call i32 @util_strlcat(i8* %11, i8* %45, i32 %52)
%62 = call i32 @util_strlcat(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %52)
%63 = call i32 @util_strlcat(i8* %11, i8* %50, i32 %52)
%64 = call i64 @stat(i8* %7, %struct.stat* %5)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %49, %59
br label %91
67: ; preds = %44, %59
br label %93
68: ; preds = %41
%69 = trunc i64 %10 to i32
%70 = sub i32 1024, %69
%71 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %70)
%72 = call i32 @util_strlcat(i8* %11, i8* %1, i32 %70)
%73 = call i32 @util_strlcat(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %70)
%74 = call i32 @util_strlcat(i8* %11, i8* %2, i32 %70)
%75 = call i64 @stat(i8* %7, %struct.stat* %5)
%76 = icmp eq i64 %75, 0
br i1 %76, label %91, label %77
77: ; preds = %68
%78 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %70)
%79 = call i32 @util_strlcat(i8* %11, i8* %1, i32 %70)
%80 = call i32 @util_strlcat(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %70)
%81 = call i32 @util_strlcat(i8* %11, i8* %2, i32 %70)
%82 = call i64 @stat(i8* %7, %struct.stat* %5)
%83 = icmp eq i64 %82, 0
br i1 %83, label %91, label %84
84: ; preds = %77
%85 = call i64 @util_strlcpy(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %70)
%86 = call i32 @util_strlcat(i8* %11, i8* %1, i32 %70)
%87 = call i32 @util_strlcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 %70)
%88 = call i32 @util_strlcat(i8* %11, i8* %2, i32 %70)
%89 = call i64 @stat(i8* %7, %struct.stat* %5)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %66, %84, %77, %68, %34, %26, %21, %14
%92 = call %struct.udev_device* @udev_device_new_from_syspath(%struct.udev* %0, i8* %7)
br label %93
93: ; preds = %67, %26, %34, %84, %91
%94 = phi %struct.udev_device* [ %92, %91 ], [ null, %67 ], [ null, %84 ], [ null, %34 ], [ null, %26 ]
ret %struct.udev_device* %94
}