#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 */

/* Variables and functions */
int ENOMEM;
int /*<<< orphan*/ format_lun_number(char const *, char **);
int /*<<< orphan*/ free(char *);
int handle_scsi_sas_wide_port(char const *, char **, char **);
int /*<<< orphan*/ path_prepend(char **, char *, char *, char *, ...);
char *strdup(char const *);
scalar_t__ strncmp(char *, char *, int);
int vdev_sysfs_device_path_from_subsystem_sysname(char *, char *, char *,
                                                  char **, size_t *);
int vdev_sysfs_get_parent_device(char *, char **, size_t *);
int vdev_sysfs_get_parent_with_subsystem_devtype(char const *, char *, char *,
                                                 char **, size_t *);
int vdev_sysfs_get_sysname(char *, char **, size_t *);
int vdev_sysfs_read_attr(char *, char *, char **, size_t *);
int handle_scsi_sas(char const *parent, char **path, char **new_parent) {
  char *targetdev = NULL;
  size_t targetdev_len = 0;
  char *target_parent = NULL;
  size_t target_parent_len = 0;
  char *target_parent_sysname = NULL;
  size_t target_parent_sysname_len = 0;
  char *port = NULL;
  size_t port_len = 0;
  char *port_sysname = NULL;
  size_t port_sysname_len = 0;
  char *expander = NULL;
  size_t expander_len = 0;
  char *expander_sysname = NULL;
  size_t expander_sysname_len = 0;
  char *target_sasdev = NULL;
  size_t target_sasdev_len = 0;
  char *expander_sasdev = NULL;
  size_t expander_sasdev_len = 0;
  char *port_sasdev = NULL;
  size_t port_sasdev_len = 0;
  char *sas_address = NULL;
  size_t sas_address_len = 0;
  char *phy_id = NULL;
  size_t phy_id_len = 0;
  char *phy_count = NULL;
  size_t phy_count_len = 0;
  char *lun = NULL;
  int rc = 0;
  rc = vdev_sysfs_get_parent_with_subsystem_devtype(
      parent, "scsi", "scsi_target", &targetdev, &targetdev_len);
  if (rc != 0) {
    return rc;
  }
  rc = vdev_sysfs_get_parent_device(targetdev, &target_parent,
                                    &target_parent_len);
  free(targetdev);
  if (rc != 0) {
    return rc;
  }
  rc = vdev_sysfs_get_sysname(target_parent, &target_parent_sysname,
                              &target_parent_sysname_len);
  if (rc != 0) {
    free(target_parent);
    return rc;
  }
  rc = vdev_sysfs_device_path_from_subsystem_sysname(
      "/sys", "sas_device", target_parent_sysname, &target_sasdev,
      &target_sasdev_len);
  free(target_parent);
  if (rc != 0) {
    return rc;
  }
  rc = vdev_sysfs_get_parent_device(target_parent, &port, &port_len);
  if (rc != 0) {
    free(target_sasdev);
    return rc;
  }
  rc = vdev_sysfs_get_sysname(port, &port_sysname, &port_sysname_len);
  if (rc != 0) {
    free(target_sasdev);
    free(port);
    return rc;
  }
  rc = vdev_sysfs_device_path_from_subsystem_sysname(
      "/sys", "sas_port", port_sysname, &port_sasdev, &port_sasdev_len);
  free(port_sysname);
  if (rc != 0) {
    free(target_sasdev);
    free(port);
    return rc;
  }
  rc =
      vdev_sysfs_read_attr(port_sasdev, "num_phys", &phy_count, &phy_count_len);
  if (rc != 0) {
    free(target_sasdev);
    free(port_sasdev);
    free(port);
    return rc;
  }
  if (strncmp(phy_count, "1", 2) != 0) {
    rc = handle_scsi_sas_wide_port(parent, path, new_parent);
    free(target_sasdev);
    free(port_sasdev);
    return rc;
  }
  free(phy_count);
  rc = vdev_sysfs_read_attr(target_sasdev, "phy_identifier", &phy_id,
                            &phy_id_len);
  free(target_sasdev);
  if (rc != 0) {
    free(port);
    return rc;
  }
  rc = vdev_sysfs_get_parent_device(port, &expander, &expander_len);
  free(port);
  if (rc != 0) {
    free(phy_id);
    return rc;
  }
  rc = vdev_sysfs_get_sysname(expander, &expander_sysname,
                              &expander_sysname_len);
  if (rc != 0) {
    free(phy_id);
    free(expander);
    return rc;
  }
  free(expander);
  rc = vdev_sysfs_device_path_from_subsystem_sysname(
      "/sys", "sas_device", expander_sysname, &expander_sasdev,
      &expander_sasdev_len);
  free(expander_sysname);
  if (rc == 0) {
    rc = vdev_sysfs_read_attr(expander_sasdev, "sas_address", &sas_address,
                              &sas_address_len);
    free(expander_sasdev);
    if (rc != 0) {
      free(phy_id);
      return rc;
    }
  }
  format_lun_number(parent, &lun);
  if (sas_address != NULL) {
    path_prepend(path, "sas-exp%s-phy%s-%s", sas_address, phy_id, lun);
    free(sas_address);
  } else {
    path_prepend(path, "sas-phy%s-%s", phy_id, lun);
  }
  if (lun != NULL) {
    free(lun);
  }
  free(phy_id);
  *new_parent = strdup(parent);
  if (*new_parent == NULL) {
    return -ENOMEM;
  }
  return 0;
}


x86 assembly (clang, -O0):
<handle_scsi_sas>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0x98(%rbp)
movq   $0x0,-0xa0(%rbp)
movq   $0x0,-0xa8(%rbp)
movq   $0x0,-0xb0(%rbp)
movq   $0x0,-0xb8(%rbp)
movq   $0x0,-0xc0(%rbp)
movq   $0x0,-0xc8(%rbp)
movq   $0x0,-0xd0(%rbp)
movq   $0x0,-0xd8(%rbp)
movq   $0x0,-0xe0(%rbp)
movq   $0x0,-0xe8(%rbp)
movq   $0x0,-0xf0(%rbp)
movq   $0x0,-0xf8(%rbp)
movl   $0x0,-0xfc(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd1f(%rip),%rsi
lea    0xd1d(%rip),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1070 <vdev_sysfs_get_parent_with_subsystem_devtype@plt>
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     1316 <handle_scsi_sas+0x166>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   10b0 <vdev_sysfs_get_parent_device@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0xfc(%rbp)
je     1351 <handle_scsi_sas+0x1a1>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x38(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1090 <vdev_sysfs_get_sysname@plt>
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     138c <handle_scsi_sas+0x1dc>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x48(%rbp),%rdx
lea    0xc7a(%rip),%rdi
lea    0xc78(%rip),%rsi
lea    -0x98(%rbp),%rcx
lea    -0xa0(%rbp),%r8
call   10d0 <vdev_sysfs_device_path_from_subsystem_sysname@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0xfc(%rbp)
je     13db <handle_scsi_sas+0x22b>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x38(%rbp),%rdi
lea    -0x58(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   10b0 <vdev_sysfs_get_parent_device@plt>
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     1419 <handle_scsi_sas+0x269>
mov    -0x98(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x58(%rbp),%rdi
lea    -0x68(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1090 <vdev_sysfs_get_sysname@plt>
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     1460 <handle_scsi_sas+0x2b0>
mov    -0x98(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x68(%rbp),%rdx
lea    0xba6(%rip),%rdi
lea    0xbaf(%rip),%rsi
lea    -0xb8(%rbp),%rcx
lea    -0xc0(%rbp),%r8
call   10d0 <vdev_sysfs_device_path_from_subsystem_sysname@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x68(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0xfc(%rbp)
je     14c4 <handle_scsi_sas+0x314>
mov    -0x98(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0xb8(%rbp),%rdi
lea    0xb58(%rip),%rsi
lea    -0xe8(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
call   1080 <vdev_sysfs_read_attr@plt>
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     1527 <handle_scsi_sas+0x377>
mov    -0x98(%rbp),%rdi
call   1040 <free@plt>
mov    -0xb8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0xe8(%rbp),%rdi
lea    0xafe(%rip),%rsi
mov    $0x2,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1586 <handle_scsi_sas+0x3d6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <handle_scsi_sas_wide_port@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x98(%rbp),%rdi
call   1040 <free@plt>
mov    -0xb8(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0xe8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x98(%rbp),%rdi
lea    0xa95(%rip),%rsi
lea    -0xd8(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
call   1080 <vdev_sysfs_read_attr@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x98(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0xfc(%rbp)
je     15e9 <handle_scsi_sas+0x439>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x58(%rbp),%rdi
lea    -0x78(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   10b0 <vdev_sysfs_get_parent_device@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0xfc(%rbp)
je     1630 <handle_scsi_sas+0x480>
mov    -0xd8(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x78(%rbp),%rdi
lea    -0x88(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1090 <vdev_sysfs_get_sysname@plt>
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     167d <handle_scsi_sas+0x4cd>
mov    -0xd8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x78(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
mov    -0x78(%rbp),%rdi
call   1040 <free@plt>
mov    -0x88(%rbp),%rdx
lea    0x97d(%rip),%rdi
lea    0x97b(%rip),%rsi
lea    -0xa8(%rbp),%rcx
lea    -0xb0(%rbp),%r8
call   10d0 <vdev_sysfs_device_path_from_subsystem_sysname@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x88(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0xfc(%rbp)
jne    172c <handle_scsi_sas+0x57c>
mov    -0xa8(%rbp),%rdi
lea    0x969(%rip),%rsi
lea    -0xc8(%rbp),%rdx
lea    -0xd0(%rbp),%rcx
call   1080 <vdev_sysfs_read_attr@plt>
mov    %eax,-0xfc(%rbp)
mov    -0xa8(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0xfc(%rbp)
je     1727 <handle_scsi_sas+0x577>
mov    -0xd8(%rbp),%rdi
call   1040 <free@plt>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
jmp    172c <handle_scsi_sas+0x57c>
mov    -0x10(%rbp),%rdi
lea    -0xf8(%rbp),%rsi
call   10a0 <format_lun_number@plt>
cmpq   $0x0,-0xc8(%rbp)
je     1782 <handle_scsi_sas+0x5d2>
mov    -0x18(%rbp),%rdi
mov    -0xc8(%rbp),%rdx
mov    -0xd8(%rbp),%rcx
mov    -0xf8(%rbp),%r8
lea    0x8e6(%rip),%rsi
mov    $0x0,%al
call   1030 <path_prepend@plt>
mov    -0xc8(%rbp),%rdi
call   1040 <free@plt>
jmp    17a2 <handle_scsi_sas+0x5f2>
mov    -0x18(%rbp),%rdi
mov    -0xd8(%rbp),%rdx
mov    -0xf8(%rbp),%rcx
lea    0x8c8(%rip),%rsi
mov    $0x0,%al
call   1030 <path_prepend@plt>
cmpq   $0x0,-0xf8(%rbp)
je     17bc <handle_scsi_sas+0x60c>
mov    -0xf8(%rbp),%rdi
call   1040 <free@plt>
mov    -0xd8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    17fc <handle_scsi_sas+0x64c>
xor    %eax,%eax
mov    0x27ee(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1803 <handle_scsi_sas+0x653>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_scsi_sas>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movq   $0x0,0x60(%rsp)
movq   $0x0,0xd0(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0xc8(%rsp)
movq   $0x0,0x68(%rsp)
movq   $0x0,0xc0(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0xb8(%rsp)
movq   $0x0,0x58(%rsp)
movq   $0x0,0xb0(%rsp)
movq   $0x0,0x28(%rsp)
movq   $0x0,0xa8(%rsp)
movq   $0x0,0x50(%rsp)
movq   $0x0,0xa0(%rsp)
movq   $0x0,(%rsp)
movq   $0x0,0x98(%rsp)
movq   $0x0,0x48(%rsp)
movq   $0x0,0x90(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x88(%rsp)
movq   $0x0,0x40(%rsp)
movq   $0x0,0x80(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x78(%rsp)
movq   $0x0,0x38(%rsp)
movq   $0x0,0x70(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xd20(%rip),%rsi
lea    0xd1e(%rip),%rdx
lea    0x60(%rsp),%rcx
lea    0xd0(%rsp),%r8
call   1070 <vdev_sysfs_get_parent_with_subsystem_devtype@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1386 <handle_scsi_sas+0x1d6>
mov    0x60(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0xc8(%rsp),%rdx
call   10b0 <vdev_sysfs_get_parent_device@plt>
mov    %eax,%ebp
mov    0x60(%rsp),%rdi
call   1040 <free@plt>
test   %ebp,%ebp
jne    1386 <handle_scsi_sas+0x1d6>
mov    0x18(%rsp),%rdi
lea    0x68(%rsp),%rsi
lea    0xc0(%rsp),%rdx
call   1090 <vdev_sysfs_get_sysname@plt>
test   %eax,%eax
je     1353 <handle_scsi_sas+0x1a3>
mov    %eax,%ebp
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
jmp    1386 <handle_scsi_sas+0x1d6>
mov    0x68(%rsp),%rdx
lea    0xcb2(%rip),%rdi
lea    0xcb0(%rip),%rsi
mov    %rsp,%rcx
lea    0x98(%rsp),%r8
call   10d0 <vdev_sysfs_device_path_from_subsystem_sysname@plt>
mov    %eax,%ebp
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
test   %ebp,%ebp
je     1396 <handle_scsi_sas+0x1e6>
mov    %ebp,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x18(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0xb8(%rsp),%rdx
call   10b0 <vdev_sysfs_get_parent_device@plt>
test   %eax,%eax
je     13b9 <handle_scsi_sas+0x209>
mov    %eax,%ebp
mov    (%rsp),%rdi
jmp    134c <handle_scsi_sas+0x19c>
mov    0x8(%rsp),%rdi
lea    0x58(%rsp),%rsi
lea    0xb0(%rsp),%rdx
call   1090 <vdev_sysfs_get_sysname@plt>
test   %eax,%eax
je     13d8 <handle_scsi_sas+0x228>
mov    %eax,%ebp
jmp    140d <handle_scsi_sas+0x25d>
mov    0x58(%rsp),%rdx
lea    0xc2d(%rip),%rdi
lea    0xc36(%rip),%rsi
lea    0x20(%rsp),%rcx
lea    0x88(%rsp),%r8
call   10d0 <vdev_sysfs_device_path_from_subsystem_sysname@plt>
mov    %eax,%ebp
mov    0x58(%rsp),%rdi
call   1040 <free@plt>
test   %ebp,%ebp
je     1420 <handle_scsi_sas+0x270>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    0x8(%rsp),%rdi
jmp    134c <handle_scsi_sas+0x19c>
mov    0x20(%rsp),%rdi
lea    0xbfe(%rip),%rsi
lea    0x38(%rsp),%rdx
lea    0x70(%rsp),%rcx
call   1080 <vdev_sysfs_read_attr@plt>
test   %eax,%eax
je     1451 <handle_scsi_sas+0x2a1>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    0x20(%rsp),%rdi
jmp    1411 <handle_scsi_sas+0x261>
mov    0x38(%rsp),%rdi
lea    0xbd6(%rip),%rsi
mov    $0x2,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     148f <handle_scsi_sas+0x2df>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <handle_scsi_sas_wide_port@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    0x20(%rsp),%rdi
jmp    134c <handle_scsi_sas+0x19c>
mov    0x38(%rsp),%rdi
call   1040 <free@plt>
mov    (%rsp),%rdi
lea    0xb91(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x78(%rsp),%rcx
call   1080 <vdev_sysfs_read_attr@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    0x8(%rsp),%rdi
test   %ebp,%ebp
jne    134c <handle_scsi_sas+0x19c>
lea    0x28(%rsp),%rsi
lea    0xa8(%rsp),%rdx
call   10b0 <vdev_sysfs_get_parent_device@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
test   %ebp,%ebp
je     14f7 <handle_scsi_sas+0x347>
mov    0x10(%rsp),%rdi
jmp    134c <handle_scsi_sas+0x19c>
mov    0x28(%rsp),%rdi
lea    0x50(%rsp),%rsi
lea    0xa0(%rsp),%rdx
call   1090 <vdev_sysfs_get_sysname@plt>
test   %eax,%eax
je     1528 <handle_scsi_sas+0x378>
mov    %eax,%ebp
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    0x28(%rsp),%rdi
jmp    134c <handle_scsi_sas+0x19c>
mov    0x28(%rsp),%rdi
call   1040 <free@plt>
mov    0x50(%rsp),%rdx
lea    0xad3(%rip),%rdi
lea    0xad1(%rip),%rsi
lea    0x48(%rsp),%rcx
lea    0x90(%rsp),%r8
call   10d0 <vdev_sysfs_device_path_from_subsystem_sysname@plt>
mov    %eax,%ebp
mov    0x50(%rsp),%rdi
call   1040 <free@plt>
test   %ebp,%ebp
je     15a5 <handle_scsi_sas+0x3f5>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <format_lun_number@plt>
mov    0x40(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x30(%rsp),%r8
test   %rdx,%rdx
je     15d9 <handle_scsi_sas+0x429>
lea    0xac1(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <path_prepend@plt>
mov    0x40(%rsp),%rdi
call   1040 <free@plt>
jmp    15f0 <handle_scsi_sas+0x440>
mov    0x48(%rsp),%rdi
lea    0xa93(%rip),%rsi
lea    0x40(%rsp),%rdx
lea    0x80(%rsp),%rcx
call   1080 <vdev_sysfs_read_attr@plt>
mov    %eax,%ebp
mov    0x48(%rsp),%rdi
call   1040 <free@plt>
test   %ebp,%ebp
jne    14ed <handle_scsi_sas+0x33d>
jmp    1567 <handle_scsi_sas+0x3b7>
lea    0xa83(%rip),%rsi
mov    %r15,%rdi
mov    %rcx,%rdx
mov    %r8,%rcx
xor    %eax,%eax
call   1030 <path_prepend@plt>
mov    0x30(%rsp),%rdi
test   %rdi,%rdi
je     15ff <handle_scsi_sas+0x44f>
call   1040 <free@plt>
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   10c0 <strdup@plt>
mov    %rax,(%r14)
xor    %ebp,%ebp
test   %rax,%rax
jne    1386 <handle_scsi_sas+0x1d6>
mov    0x29ba(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    1386 <handle_scsi_sas+0x1d6>

LLVM IR (-O0):
@.str = [5 x i8] c"scsi\00"
@.str.1 = [12 x i8] c"scsi_target\00"
@.str.2 = [5 x i8] c"/sys\00"
@.str.3 = [11 x i8] c"sas_device\00"
@.str.4 = [9 x i8] c"sas_port\00"
@.str.5 = [9 x i8] c"num_phys\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [15 x i8] c"phy_identifier\00"
@.str.8 = [12 x i8] c"sas_address\00"
@.str.9 = [19 x i8] c"sas-exp%s-phy%s-%s\00"
@.str.10 = [13 x i8] c"sas-phy%s-%s\00"
@ENOMEM = global i32 0
define i32 @handle_scsi_sas(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i8*
%25 = alloca i64
%26 = alloca i8*
%27 = alloca i64
%28 = alloca i8*
%29 = alloca i64
%30 = alloca i8*
%31 = alloca i64
%32 = alloca i8*
%33 = alloca i64
%34 = alloca i8*
%35 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8* null, i8** %8
store i64 0, i64* %9
store i8* null, i8** %10
store i64 0, i64* %11
store i8* null, i8** %12
store i64 0, i64* %13
store i8* null, i8** %14
store i64 0, i64* %15
store i8* null, i8** %16
store i64 0, i64* %17
store i8* null, i8** %18
store i64 0, i64* %19
store i8* null, i8** %20
store i64 0, i64* %21
store i8* null, i8** %22
store i64 0, i64* %23
store i8* null, i8** %24
store i64 0, i64* %25
store i8* null, i8** %26
store i64 0, i64* %27
store i8* null, i8** %28
store i64 0, i64* %29
store i8* null, i8** %30
store i64 0, i64* %31
store i8* null, i8** %32
store i64 0, i64* %33
store i8* null, i8** %34
store i32 0, i32* %35
%36 = load i8*, i8** %5
%37 = call i32 @vdev_sysfs_get_parent_with_subsystem_devtype(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %8, i64* %9)
store i32 %37, i32* %35
%38 = load i32, i32* %35
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %3
%41 = load i32, i32* %35
store i32 %41, i32* %4
br label %222
42: ; preds = %3
%43 = load i8*, i8** %8
%44 = call i32 @vdev_sysfs_get_parent_device(i8* %43, i8** %10, i64* %11)
store i32 %44, i32* %35
%45 = load i8*, i8** %8
%46 = call i32 @free(i8* %45)
%47 = load i32, i32* %35
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %42
%50 = load i32, i32* %35
store i32 %50, i32* %4
br label %222
51: ; preds = %42
%52 = load i8*, i8** %10
%53 = call i32 @vdev_sysfs_get_sysname(i8* %52, i8** %12, i64* %13)
store i32 %53, i32* %35
%54 = load i32, i32* %35
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %51
%57 = load i8*, i8** %10
%58 = call i32 @free(i8* %57)
%59 = load i32, i32* %35
store i32 %59, i32* %4
br label %222
60: ; preds = %51
%61 = load i8*, i8** %12
%62 = call i32 @vdev_sysfs_device_path_from_subsystem_sysname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %61, i8** %22, i64* %23)
store i32 %62, i32* %35
%63 = load i8*, i8** %10
%64 = call i32 @free(i8* %63)
%65 = load i32, i32* %35
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %60
%68 = load i32, i32* %35
store i32 %68, i32* %4
br label %222
69: ; preds = %60
%70 = load i8*, i8** %10
%71 = call i32 @vdev_sysfs_get_parent_device(i8* %70, i8** %14, i64* %15)
store i32 %71, i32* %35
%72 = load i32, i32* %35
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %69
%75 = load i8*, i8** %22
%76 = call i32 @free(i8* %75)
%77 = load i32, i32* %35
store i32 %77, i32* %4
br label %222
78: ; preds = %69
%79 = load i8*, i8** %14
%80 = call i32 @vdev_sysfs_get_sysname(i8* %79, i8** %16, i64* %17)
store i32 %80, i32* %35
%81 = load i32, i32* %35
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %89
83: ; preds = %78
%84 = load i8*, i8** %22
%85 = call i32 @free(i8* %84)
%86 = load i8*, i8** %14
%87 = call i32 @free(i8* %86)
%88 = load i32, i32* %35
store i32 %88, i32* %4
br label %222
89: ; preds = %78
%90 = load i8*, i8** %16
%91 = call i32 @vdev_sysfs_device_path_from_subsystem_sysname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %90, i8** %26, i64* %27)
store i32 %91, i32* %35
%92 = load i8*, i8** %16
%93 = call i32 @free(i8* %92)
%94 = load i32, i32* %35
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %102
96: ; preds = %89
%97 = load i8*, i8** %22
%98 = call i32 @free(i8* %97)
%99 = load i8*, i8** %14
%100 = call i32 @free(i8* %99)
%101 = load i32, i32* %35
store i32 %101, i32* %4
br label %222
102: ; preds = %89
%103 = load i8*, i8** %26
%104 = call i32 @vdev_sysfs_read_attr(i8* %103, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %32, i64* %33)
store i32 %104, i32* %35
%105 = load i32, i32* %35
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %115
107: ; preds = %102
%108 = load i8*, i8** %22
%109 = call i32 @free(i8* %108)
%110 = load i8*, i8** %26
%111 = call i32 @free(i8* %110)
%112 = load i8*, i8** %14
%113 = call i32 @free(i8* %112)
%114 = load i32, i32* %35
store i32 %114, i32* %4
br label %222
115: ; preds = %102
%116 = load i8*, i8** %32
%117 = call i64 @strncmp(i8* %116, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 2)
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %129
119: ; preds = %115
%120 = load i8*, i8** %5
%121 = load i8**, i8*** %6
%122 = load i8**, i8*** %7
%123 = call i32 @handle_scsi_sas_wide_port(i8* %120, i8** %121, i8** %122)
store i32 %123, i32* %35
%124 = load i8*, i8** %22
%125 = call i32 @free(i8* %124)
%126 = load i8*, i8** %26
%127 = call i32 @free(i8* %126)
%128 = load i32, i32* %35
store i32 %128, i32* %4
br label %222
129: ; preds = %115
%130 = load i8*, i8** %32
%131 = call i32 @free(i8* %130)
%132 = load i8*, i8** %22
%133 = call i32 @vdev_sysfs_read_attr(i8* %132, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8** %30, i64* %31)
store i32 %133, i32* %35
%134 = load i8*, i8** %22
%135 = call i32 @free(i8* %134)
%136 = load i32, i32* %35
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %142
138: ; preds = %129
%139 = load i8*, i8** %14
%140 = call i32 @free(i8* %139)
%141 = load i32, i32* %35
store i32 %141, i32* %4
br label %222
142: ; preds = %129
%143 = load i8*, i8** %14
%144 = call i32 @vdev_sysfs_get_parent_device(i8* %143, i8** %18, i64* %19)
store i32 %144, i32* %35
%145 = load i8*, i8** %14
%146 = call i32 @free(i8* %145)
%147 = load i32, i32* %35
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %153
149: ; preds = %142
%150 = load i8*, i8** %30
%151 = call i32 @free(i8* %150)
%152 = load i32, i32* %35
store i32 %152, i32* %4
br label %222
153: ; preds = %142
%154 = load i8*, i8** %18
%155 = call i32 @vdev_sysfs_get_sysname(i8* %154, i8** %20, i64* %21)
store i32 %155, i32* %35
%156 = load i32, i32* %35
%157 = icmp ne i32 %156, 0
br i1 %157, label %158, label %164
158: ; preds = %153
%159 = load i8*, i8** %30
%160 = call i32 @free(i8* %159)
%161 = load i8*, i8** %18
%162 = call i32 @free(i8* %161)
%163 = load i32, i32* %35
store i32 %163, i32* %4
br label %222
164: ; preds = %153
%165 = load i8*, i8** %18
%166 = call i32 @free(i8* %165)
%167 = load i8*, i8** %20
%168 = call i32 @vdev_sysfs_device_path_from_subsystem_sysname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %167, i8** %24, i64* %25)
store i32 %168, i32* %35
%169 = load i8*, i8** %20
%170 = call i32 @free(i8* %169)
%171 = load i32, i32* %35
%172 = icmp eq i32 %171, 0
br i1 %172, label %173, label %185
173: ; preds = %164
%174 = load i8*, i8** %24
%175 = call i32 @vdev_sysfs_read_attr(i8* %174, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8** %28, i64* %29)
store i32 %175, i32* %35
%176 = load i8*, i8** %24
%177 = call i32 @free(i8* %176)
%178 = load i32, i32* %35
%179 = icmp ne i32 %178, 0
br i1 %179, label %180, label %184
180: ; preds = %173
%181 = load i8*, i8** %30
%182 = call i32 @free(i8* %181)
%183 = load i32, i32* %35
store i32 %183, i32* %4
br label %222
184: ; preds = %173
br label %185
185: ; preds = %184, %164
%186 = load i8*, i8** %5
%187 = call i32 @format_lun_number(i8* %186, i8** %34)
%188 = load i8*, i8** %28
%189 = icmp ne i8* %188, null
br i1 %189, label %190, label %198
190: ; preds = %185
%191 = load i8**, i8*** %6
%192 = load i8*, i8** %28
%193 = load i8*, i8** %30
%194 = load i8*, i8** %34
%195 = call i32 (i8**, i8*, i8*, i8*, ...) @path_prepend(i8** %191, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %192, i8* %193, i8* %194)
%196 = load i8*, i8** %28
%197 = call i32 @free(i8* %196)
br label %203
198: ; preds = %185
%199 = load i8**, i8*** %6
%200 = load i8*, i8** %30
%201 = load i8*, i8** %34
%202 = call i32 (i8**, i8*, i8*, i8*, ...) @path_prepend(i8** %199, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* %200, i8* %201)
br label %203
203: ; preds = %198, %190
%204 = load i8*, i8** %34
%205 = icmp ne i8* %204, null
br i1 %205, label %206, label %209
206: ; preds = %203
%207 = load i8*, i8** %34
%208 = call i32 @free(i8* %207)
br label %209
209: ; preds = %206, %203
%210 = load i8*, i8** %30
%211 = call i32 @free(i8* %210)
%212 = load i8*, i8** %5
%213 = call i8* @strdup(i8* %212)
%214 = load i8**, i8*** %7
store i8* %213, i8** %214
%215 = load i8**, i8*** %7
%216 = load i8*, i8** %215
%217 = icmp eq i8* %216, null
br i1 %217, label %218, label %221
218: ; preds = %209
%219 = load i32, i32* @ENOMEM
%220 = sub nsw i32 0, %219
store i32 %220, i32* %4
br label %222
221: ; preds = %209
store i32 0, i32* %4
br label %222
222: ; preds = %221, %218, %180, %158, %149, %138, %119, %107, %96, %83, %74, %67, %56, %49, %40
%223 = load i32, i32* %4
ret i32 %223
}

LLVM IR (-O2):
@.str = [5 x i8] c"scsi\00"
@.str.1 = [12 x i8] c"scsi_target\00"
@.str.2 = [5 x i8] c"/sys\00"
@.str.3 = [11 x i8] c"sas_device\00"
@.str.4 = [9 x i8] c"sas_port\00"
@.str.5 = [9 x i8] c"num_phys\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [15 x i8] c"phy_identifier\00"
@.str.8 = [12 x i8] c"sas_address\00"
@.str.9 = [19 x i8] c"sas-exp%s-phy%s-%s\00"
@.str.10 = [13 x i8] c"sas-phy%s-%s\00"
@ENOMEM = global i32 0
define i32 @handle_scsi_sas(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i8*
%25 = alloca i64
%26 = alloca i8*
%27 = alloca i64
%28 = alloca i8*
%29 = alloca i64
%30 = alloca i8*
%31 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%32 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%33 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%34 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%35 = bitcast i8** %8 to i8*
store i8* null, i8** %8
%36 = bitcast i64* %9 to i8*
store i64 0, i64* %9
%37 = bitcast i8** %10 to i8*
store i8* null, i8** %10
%38 = bitcast i64* %11 to i8*
store i64 0, i64* %11
%39 = bitcast i8** %12 to i8*
store i8* null, i8** %12
%40 = bitcast i64* %13 to i8*
store i64 0, i64* %13
%41 = bitcast i8** %14 to i8*
store i8* null, i8** %14
%42 = bitcast i64* %15 to i8*
store i64 0, i64* %15
%43 = bitcast i8** %16 to i8*
store i8* null, i8** %16
%44 = bitcast i64* %17 to i8*
store i64 0, i64* %17
%45 = bitcast i8** %18 to i8*
store i8* null, i8** %18
%46 = bitcast i64* %19 to i8*
store i64 0, i64* %19
%47 = bitcast i8** %20 to i8*
store i8* null, i8** %20
%48 = bitcast i64* %21 to i8*
store i64 0, i64* %21
%49 = bitcast i8** %22 to i8*
store i8* null, i8** %22
%50 = bitcast i64* %23 to i8*
store i64 0, i64* %23
%51 = bitcast i8** %24 to i8*
store i8* null, i8** %24
%52 = bitcast i64* %25 to i8*
store i64 0, i64* %25
%53 = bitcast i8** %26 to i8*
store i8* null, i8** %26
%54 = bitcast i64* %27 to i8*
store i64 0, i64* %27
%55 = bitcast i8** %28 to i8*
store i8* null, i8** %28
%56 = bitcast i64* %29 to i8*
store i64 0, i64* %29
%57 = bitcast i8** %30 to i8*
store i8* null, i8** %30
%58 = call i32 @vdev_sysfs_get_parent_with_subsystem_devtype(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %4, i64* %5)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %197
60: ; preds = %3
%61 = load i8*, i8** %4
%62 = call i32 @vdev_sysfs_get_parent_device(i8* %61, i8** %6, i64* %7)
%63 = load i8*, i8** %4
%64 = call i32 @free(i8* %63)
%65 = icmp eq i32 %62, 0
br i1 %65, label %66, label %197
66: ; preds = %60
%67 = load i8*, i8** %6
%68 = call i32 @vdev_sysfs_get_sysname(i8* %67, i8** %8, i64* %9)
%69 = icmp eq i32 %68, 0
br i1 %69, label %73, label %70
70: ; preds = %66
%71 = load i8*, i8** %6
%72 = call i32 @free(i8* %71)
br label %197
73: ; preds = %66
%74 = load i8*, i8** %8
%75 = call i32 @vdev_sysfs_device_path_from_subsystem_sysname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %74, i8** %18, i64* %19)
%76 = load i8*, i8** %6
%77 = call i32 @free(i8* %76)
%78 = icmp eq i32 %75, 0
br i1 %78, label %79, label %197
79: ; preds = %73
%80 = load i8*, i8** %6
%81 = call i32 @vdev_sysfs_get_parent_device(i8* %80, i8** %10, i64* %11)
%82 = icmp eq i32 %81, 0
br i1 %82, label %86, label %83
83: ; preds = %79
%84 = load i8*, i8** %18
%85 = call i32 @free(i8* %84)
br label %197
86: ; preds = %79
%87 = load i8*, i8** %10
%88 = call i32 @vdev_sysfs_get_sysname(i8* %87, i8** %12, i64* %13)
%89 = icmp eq i32 %88, 0
br i1 %89, label %95, label %90
90: ; preds = %86
%91 = load i8*, i8** %18
%92 = call i32 @free(i8* %91)
%93 = load i8*, i8** %10
%94 = call i32 @free(i8* %93)
br label %197
95: ; preds = %86
%96 = load i8*, i8** %12
%97 = call i32 @vdev_sysfs_device_path_from_subsystem_sysname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %96, i8** %22, i64* %23)
%98 = load i8*, i8** %12
%99 = call i32 @free(i8* %98)
%100 = icmp eq i32 %97, 0
br i1 %100, label %106, label %101
101: ; preds = %95
%102 = load i8*, i8** %18
%103 = call i32 @free(i8* %102)
%104 = load i8*, i8** %10
%105 = call i32 @free(i8* %104)
br label %197
106: ; preds = %95
%107 = load i8*, i8** %22
%108 = call i32 @vdev_sysfs_read_attr(i8* %107, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %28, i64* %29)
%109 = icmp eq i32 %108, 0
br i1 %109, label %117, label %110
110: ; preds = %106
%111 = load i8*, i8** %18
%112 = call i32 @free(i8* %111)
%113 = load i8*, i8** %22
%114 = call i32 @free(i8* %113)
%115 = load i8*, i8** %10
%116 = call i32 @free(i8* %115)
br label %197
117: ; preds = %106
%118 = load i8*, i8** %28
%119 = call i64 @strncmp(i8* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 2)
%120 = icmp eq i64 %119, 0
br i1 %120, label %127, label %121
121: ; preds = %117
%122 = call i32 @handle_scsi_sas_wide_port(i8* %0, i8** %1, i8** %2)
%123 = load i8*, i8** %18
%124 = call i32 @free(i8* %123)
%125 = load i8*, i8** %22
%126 = call i32 @free(i8* %125)
br label %197
127: ; preds = %117
%128 = load i8*, i8** %28
%129 = call i32 @free(i8* %128)
%130 = load i8*, i8** %18
%131 = call i32 @vdev_sysfs_read_attr(i8* %130, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8** %26, i64* %27)
%132 = load i8*, i8** %18
%133 = call i32 @free(i8* %132)
%134 = icmp eq i32 %131, 0
%135 = load i8*, i8** %10
br i1 %134, label %138, label %136
136: ; preds = %127
%137 = call i32 @free(i8* %135)
br label %197
138: ; preds = %127
%139 = call i32 @vdev_sysfs_get_parent_device(i8* %135, i8** %14, i64* %15)
%140 = load i8*, i8** %10
%141 = call i32 @free(i8* %140)
%142 = icmp eq i32 %139, 0
br i1 %142, label %146, label %143
143: ; preds = %138
%144 = load i8*, i8** %26
%145 = call i32 @free(i8* %144)
br label %197
146: ; preds = %138
%147 = load i8*, i8** %14
%148 = call i32 @vdev_sysfs_get_sysname(i8* %147, i8** %16, i64* %17)
%149 = icmp eq i32 %148, 0
br i1 %149, label %155, label %150
150: ; preds = %146
%151 = load i8*, i8** %26
%152 = call i32 @free(i8* %151)
%153 = load i8*, i8** %14
%154 = call i32 @free(i8* %153)
br label %197
155: ; preds = %146
%156 = load i8*, i8** %14
%157 = call i32 @free(i8* %156)
%158 = load i8*, i8** %16
%159 = call i32 @vdev_sysfs_device_path_from_subsystem_sysname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %158, i8** %20, i64* %21)
%160 = load i8*, i8** %16
%161 = call i32 @free(i8* %160)
%162 = icmp eq i32 %159, 0
br i1 %162, label %163, label %172
163: ; preds = %155
%164 = load i8*, i8** %20
%165 = call i32 @vdev_sysfs_read_attr(i8* %164, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8** %24, i64* %25)
%166 = load i8*, i8** %20
%167 = call i32 @free(i8* %166)
%168 = icmp eq i32 %165, 0
br i1 %168, label %172, label %169
169: ; preds = %163
%170 = load i8*, i8** %26
%171 = call i32 @free(i8* %170)
br label %197
172: ; preds = %163, %155
%173 = call i32 @format_lun_number(i8* %0, i8** %30)
%174 = load i8*, i8** %24
%175 = icmp eq i8* %174, null
%176 = load i8*, i8** %26
%177 = load i8*, i8** %30
br i1 %175, label %182, label %178
178: ; preds = %172
%179 = call i32 (i8**, i8*, i8*, i8*, ...) @path_prepend(i8** %1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %174, i8* %176, i8* %177)
%180 = load i8*, i8** %24
%181 = call i32 @free(i8* %180)
br label %184
182: ; preds = %172
%183 = call i32 (i8**, i8*, i8*, i8*, ...) @path_prepend(i8** %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* %176, i8* %177)
br label %184
184: ; preds = %182, %178
%185 = load i8*, i8** %30
%186 = icmp eq i8* %185, null
br i1 %186, label %189, label %187
187: ; preds = %184
%188 = call i32 @free(i8* %185)
br label %189
189: ; preds = %187, %184
%190 = load i8*, i8** %26
%191 = call i32 @free(i8* %190)
%192 = call i8* @strdup(i8* %0)
store i8* %192, i8** %2
%193 = icmp eq i8* %192, null
br i1 %193, label %194, label %197
194: ; preds = %189
%195 = load i32, i32* @ENOMEM
%196 = sub nsw i32 0, %195
br label %197
197: ; preds = %189, %73, %60, %3, %194, %169, %150, %143, %136, %121, %110, %101, %90, %83, %70
%198 = phi i32 [ %68, %70 ], [ %81, %83 ], [ %88, %90 ], [ %97, %101 ], [ %108, %110 ], [ %122, %121 ], [ %131, %136 ], [ %139, %143 ], [ %148, %150 ], [ %165, %169 ], [ %196, %194 ], [ %58, %3 ], [ %62, %60 ], [ %75, %73 ], [ 0, %189 ]
ret i32 %198
}