#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*/ target;
struct udev {
  int dummy;
};
struct stat {
  int st_mode;
  scalar_t__ st_rdev;
  scalar_t__ st_ino;
};
typedef int /*<<< orphan*/ slink_tmp;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
int EINVAL;
int ENOENT;
int /*<<< orphan*/ S_IFLNK;
int S_IFMT;
scalar_t__ S_ISBLK(int);
scalar_t__ S_ISCHR(int);
scalar_t__ S_ISLNK(int);
int errno;
scalar_t__ lstat(char const *, struct stat *);
int readlink(char const *, char *, int);
int rename(char *, char const *);
scalar_t__ strcmp(char *, char *);
int symlink(char *, char const *);
int /*<<< orphan*/ udev_log_null(struct udev *, char *, char const *, ...);
int /*<<< orphan*/ udev_selinux_lsetfilecon(struct udev *, char const *,
                                            int /*<<< orphan*/);
int /*<<< orphan*/ udev_selinux_resetfscreatecon(struct udev *);
int /*<<< orphan*/ udev_selinux_setfscreatecon(struct udev *, char const *,
                                               int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int util_create_path_selinux(struct udev *, char const *);
size_t util_strpcpy(char **, size_t, char *);
size_t util_strscpy(char *, size_t, char const *);
int /*<<< orphan*/ util_strscpyl(char *, int, char const *, char *,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ utimensat(int /*<<< orphan*/, char const *,
                             int /*<<< orphan*/ *, int /*<<< orphan*/);
int node_symlink(struct udev *udev, const char *node, const char *slink) {
  struct stat stats;
  char target[1024];
  char *s;
  size_t l;
  char slink_tmp[1024 + sizeof(".udev-tmp")];
  int i = 0;
  int tail = 0;
  int err = 0;
  target[0] = '\0';
  while (node[i] && (node[i] == slink[i])) {
    if (node[i] == '/')
      tail = i + 1;
    i++;
  }
  s = target;
  l = sizeof(target);
  while (slink[i] != '\0') {
    if (slink[i] == '/')
      l = util_strpcpy(&s, l, "../");
    i++;
  }
  l = util_strscpy(s, l, &node[tail]);
  if (l == 0) {
    err = -EINVAL;
    goto exit;
  }
  if (lstat(slink, &stats) == 0) {
    if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode)) {
      struct stat stats2;
      udev_log_null(udev, "found existing node instead of symlink '%s'\n",
                    slink);
      if (lstat(node, &stats2) == 0) {
        if ((stats.st_mode & S_IFMT) == (stats2.st_mode & S_IFMT) &&
            stats.st_rdev == stats2.st_rdev && stats.st_ino != stats2.st_ino) {
          udev_log_null(
              udev, "replace device node '%s' with symlink to our node '%s'\n",
              slink, node);
        } else {
          udev_log_null(udev,
                        "device node '%s' already exists, "
                        "link to '%s' will not overwrite it\n",
                        slink, node);
          goto exit;
        }
      }
    } else if (S_ISLNK(stats.st_mode)) {
      char buf[1024];
      int len;
      udev_log_null(udev, "found existing symlink '%s'\n", slink);
      len = readlink(slink, buf, sizeof(buf));
      if (len > 0 && len < (int)sizeof(buf)) {
        buf[len] = '\0';
        if (strcmp(target, buf) == 0) {
          udev_log_null(udev,
                        "preserve already existing symlink '%s' to '%s'\n",
                        slink, target);
          udev_selinux_lsetfilecon(udev, slink, S_IFLNK);
          utimensat(AT_FDCWD, slink, NULL, AT_SYMLINK_NOFOLLOW);
          goto exit;
        }
      }
    }
  } else {
    udev_log_null(udev, "creating symlink '%s' to '%s'\n", slink, target);
    do {
      err = util_create_path_selinux(udev, slink);
      if (err != 0 && err != -ENOENT)
        break;
      udev_selinux_setfscreatecon(udev, slink, S_IFLNK);
      err = symlink(target, slink);
      if (err != 0)
        err = -errno;
      udev_selinux_resetfscreatecon(udev);
    } while (err == -ENOENT);
    if (err == 0)
      goto exit;
  }
  udev_log_null(udev, "atomically replace '%s'\n", slink);
  util_strscpyl(slink_tmp, sizeof(slink_tmp), slink, ".udev-tmp", NULL);
  unlink(slink_tmp);
  do {
    err = util_create_path_selinux(udev, slink_tmp);
    if (err != 0 && err != -ENOENT)
      break;
    udev_selinux_setfscreatecon(udev, slink_tmp, S_IFLNK);
    err = symlink(target, slink_tmp);
    if (err != 0)
      err = -errno;
    udev_selinux_resetfscreatecon(udev);
  } while (err == -ENOENT);
  if (err != 0) {
    udev_log_null(udev, "symlink '%s' '%s' failed: %m\n", target, slink_tmp);
    goto exit;
  }
  err = rename(slink_tmp, slink);
  if (err != 0) {
    udev_log_null(udev, "rename '%s' '%s' failed: %m\n", slink_tmp, slink);
    unlink(slink_tmp);
  }
exit:
  return err;
}


x86 assembly (clang, -O0):
<node_symlink>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x854(%rbp)
movl   $0x0,-0x858(%rbp)
movl   $0x0,-0x85c(%rbp)
movb   $0x0,-0x430(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xc85(%rbp)
je     12a5 <node_symlink+0x85>
mov    -0x10(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x854(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0xc85(%rbp)
mov    -0xc85(%rbp),%al
test   $0x1,%al
jne    12b8 <node_symlink+0x98>
jmp    12f3 <node_symlink+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    12df <node_symlink+0xbf>
mov    -0x854(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x858(%rbp)
mov    -0x854(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x854(%rbp)
jmp    125c <node_symlink+0x3c>
lea    -0x430(%rbp),%rax
mov    %rax,-0x438(%rbp)
movq   $0x400,-0x440(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1371 <node_symlink+0x151>
mov    -0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    135d <node_symlink+0x13d>
mov    -0x440(%rbp),%rsi
lea    -0x438(%rbp),%rdi
lea    0xcaf(%rip),%rdx
call   10d0 <util_strpcpy@plt>
mov    %rax,-0x440(%rbp)
mov    -0x854(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x854(%rbp)
jmp    130c <node_symlink+0xec>
mov    -0x438(%rbp),%rdi
mov    -0x440(%rbp),%rsi
mov    -0x10(%rbp),%rdx
movslq -0x858(%rbp),%rax
add    %rax,%rdx
call   1040 <util_strscpy@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    13bd <node_symlink+0x19d>
xor    %eax,%eax
mov    0x2c18(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x85c(%rbp)
jmp    1803 <node_symlink+0x5e3>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <lstat@plt>
cmp    $0x0,%rax
jne    15ac <node_symlink+0x38c>
mov    -0x30(%rbp),%edi
call   10f0 <S_ISBLK@plt>
cmp    $0x0,%rax
jne    13f8 <node_symlink+0x1d8>
mov    -0x30(%rbp),%edi
call   10e0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     14b5 <node_symlink+0x295>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xbfd(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
mov    -0x10(%rbp),%rdi
lea    -0x878(%rbp),%rsi
call   10a0 <lstat@plt>
cmp    $0x0,%rax
jne    14b0 <node_symlink+0x290>
mov    -0x30(%rbp),%eax
mov    0x2ba6(%rip),%rcx
and    (%rcx),%eax
mov    -0x878(%rbp),%ecx
mov    0x2b97(%rip),%rdx
and    (%rdx),%ecx
cmp    %ecx,%eax
jne    148c <node_symlink+0x26c>
mov    -0x28(%rbp),%rax
cmp    -0x870(%rbp),%rax
jne    148c <node_symlink+0x26c>
mov    -0x20(%rbp),%rax
cmp    -0x868(%rbp),%rax
je     148c <node_symlink+0x26c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xbb1(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
jmp    14ab <node_symlink+0x28b>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xbca(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
jmp    1803 <node_symlink+0x5e3>
jmp    14b0 <node_symlink+0x290>
jmp    15a7 <node_symlink+0x387>
mov    -0x30(%rbp),%edi
call   1060 <S_ISLNK@plt>
cmp    $0x0,%rax
je     15a2 <node_symlink+0x382>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xbd8(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
mov    -0x18(%rbp),%rdi
lea    -0xc80(%rbp),%rsi
mov    $0x400,%edx
call   1070 <readlink@plt>
mov    %eax,-0xc84(%rbp)
cmpl   $0x0,-0xc84(%rbp)
jle    159d <node_symlink+0x37d>
cmpl   $0x400,-0xc84(%rbp)
jge    159d <node_symlink+0x37d>
movslq -0xc84(%rbp),%rax
movb   $0x0,-0xc80(%rbp,%rax,1)
lea    -0x430(%rbp),%rdi
lea    -0xc80(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1598 <node_symlink+0x378>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x430(%rbp),%rcx
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2a7b(%rip),%rax
mov    (%rax),%edx
call   1140 <udev_selinux_lsetfilecon@plt>
mov    0x2a2d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    0x2a38(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edx
call   1030 <utimensat@plt>
jmp    1803 <node_symlink+0x5e3>
jmp    159d <node_symlink+0x37d>
jmp    15a2 <node_symlink+0x382>
jmp    15a7 <node_symlink+0x387>
jmp    168a <node_symlink+0x46a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x430(%rbp),%rcx
lea    0xb39(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <util_create_path_selinux@plt>
mov    %eax,-0x85c(%rbp)
cmpl   $0x0,-0x85c(%rbp)
je     1607 <node_symlink+0x3e7>
mov    -0x85c(%rbp),%eax
xor    %ecx,%ecx
mov    0x29b8(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
je     1607 <node_symlink+0x3e7>
jmp    1673 <node_symlink+0x453>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x29d2(%rip),%rax
mov    (%rax),%edx
call   1100 <udev_selinux_setfscreatecon@plt>
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <symlink@plt>
mov    %eax,-0x85c(%rbp)
cmpl   $0x0,-0x85c(%rbp)
je     1651 <node_symlink+0x431>
xor    %eax,%eax
mov    0x2987(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x85c(%rbp)
mov    -0x8(%rbp),%rdi
call   10c0 <udev_selinux_resetfscreatecon@plt>
mov    -0x85c(%rbp),%eax
xor    %ecx,%ecx
mov    0x2947(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
je     15c9 <node_symlink+0x3a9>
cmpl   $0x0,-0x85c(%rbp)
jne    1685 <node_symlink+0x465>
jmp    1803 <node_symlink+0x5e3>
jmp    168a <node_symlink+0x46a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xa81(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
lea    -0x850(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x40a,%esi
lea    0xa7c(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1120 <util_strscpyl@plt>
lea    -0x850(%rbp),%rdi
call   1050 <unlink@plt>
mov    -0x8(%rbp),%rdi
lea    -0x850(%rbp),%rsi
call   1110 <util_create_path_selinux@plt>
mov    %eax,-0x85c(%rbp)
cmpl   $0x0,-0x85c(%rbp)
je     170e <node_symlink+0x4ee>
mov    -0x85c(%rbp),%eax
xor    %ecx,%ecx
mov    0x28b1(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
je     170e <node_symlink+0x4ee>
jmp    1780 <node_symlink+0x560>
mov    -0x8(%rbp),%rdi
lea    -0x850(%rbp),%rsi
mov    0x28c8(%rip),%rax
mov    (%rax),%edx
call   1100 <udev_selinux_setfscreatecon@plt>
lea    -0x430(%rbp),%rdi
lea    -0x850(%rbp),%rsi
call   1090 <symlink@plt>
mov    %eax,-0x85c(%rbp)
cmpl   $0x0,-0x85c(%rbp)
je     175e <node_symlink+0x53e>
xor    %eax,%eax
mov    0x287a(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x85c(%rbp)
mov    -0x8(%rbp),%rdi
call   10c0 <udev_selinux_resetfscreatecon@plt>
mov    -0x85c(%rbp),%eax
xor    %ecx,%ecx
mov    0x283a(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
je     16cd <node_symlink+0x4ad>
cmpl   $0x0,-0x85c(%rbp)
je     17b2 <node_symlink+0x592>
mov    -0x8(%rbp),%rdi
lea    -0x430(%rbp),%rdx
lea    -0x850(%rbp),%rcx
lea    0x997(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
jmp    1803 <node_symlink+0x5e3>
lea    -0x850(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1130 <rename@plt>
mov    %eax,-0x85c(%rbp)
cmpl   $0x0,-0x85c(%rbp)
je     17fe <node_symlink+0x5de>
mov    -0x8(%rbp),%rdi
lea    -0x850(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0x970(%rip),%rsi
mov    $0x0,%al
call   1080 <udev_log_null@plt>
lea    -0x850(%rbp),%rdi
call   1050 <unlink@plt>
jmp    1803 <node_symlink+0x5e3>
mov    -0x85c(%rbp),%eax
add    $0xc90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<node_symlink>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x848,%rsp
mov    %rdx,%r14
mov    %rdi,%r12
movb   $0x0,0x440(%rsp)
mov    (%rsi),%cl
test   %cl,%cl
mov    %rsi,0x10(%rsp)
je     1270 <node_symlink+0x50>
xor    %eax,%eax
xor    %ebp,%ebp
xchg   %ax,%ax
cmp    (%r14,%rax,1),%cl
jne    1274 <node_symlink+0x54>
lea    0x1(%rax),%rdx
cmp    $0x2f,%cl
cmove  %edx,%ebp
movzbl 0x1(%rsi,%rax,1),%ecx
mov    %rdx,%rax
test   %cl,%cl
jne    1250 <node_symlink+0x30>
mov    %edx,%eax
jmp    1274 <node_symlink+0x54>
xor    %eax,%eax
xor    %ebp,%ebp
lea    0x440(%rsp),%rcx
mov    %rcx,0x8(%rsp)
mov    %eax,%r15d
add    %r14,%r15
mov    $0x400,%esi
lea    0xd6d(%rip),%r13
lea    0x8(%rsp),%rbx
jmp    12b2 <node_symlink+0x92>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rdx
call   10d0 <util_strpcpy@plt>
mov    %rax,%rsi
add    $0x1,%r15
movzbl (%r15),%eax
cmp    $0x2f,%al
je     12a0 <node_symlink+0x80>
test   %al,%al
jne    12ae <node_symlink+0x8e>
mov    0x8(%rsp),%rdi
movslq %ebp,%rdx
mov    0x10(%rsp),%rbp
add    %rbp,%rdx
call   1040 <util_strscpy@plt>
test   %rax,%rax
je     1381 <node_symlink+0x161>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   10a0 <lstat@plt>
test   %rax,%rax
je     139b <node_symlink+0x17b>
lea    0xe02(%rip),%rsi
lea    0x440(%rsp),%rcx
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <udev_log_null@plt>
mov    0x2cd3(%rip),%r13
mov    0x2cb4(%rip),%rbx
mov    0x2c8d(%rip),%rbp
jmp    136b <node_symlink+0x14b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1100 <udev_selinux_setfscreatecon@plt>
lea    0x440(%rsp),%rdi
mov    %r14,%rsi
call   1090 <symlink@plt>
xor    %r15d,%r15d
sub    (%rbx),%r15d
test   %eax,%eax
cmove  %eax,%r15d
mov    %r12,%rdi
call   10c0 <udev_selinux_resetfscreatecon@plt>
mov    0x0(%rbp),%eax
add    %r15d,%eax
jne    1391 <node_symlink+0x171>
mov    %r12,%rdi
mov    %r14,%rsi
call   1110 <util_create_path_selinux@plt>
test   %eax,%eax
je     1330 <node_symlink+0x110>
add    0x0(%rbp),%eax
je     1330 <node_symlink+0x110>
jmp    13e5 <node_symlink+0x1c5>
mov    0x2c40(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
jmp    14e8 <node_symlink+0x2c8>
test   %r15d,%r15d
jne    13e5 <node_symlink+0x1c5>
jmp    14e6 <node_symlink+0x2c6>
mov    0x18(%rsp),%ebx
mov    %ebx,%edi
call   10f0 <S_ISBLK@plt>
test   %rax,%rax
jne    13bb <node_symlink+0x19b>
mov    %ebx,%edi
call   10e0 <S_ISCHR@plt>
test   %rax,%rax
je     153e <node_symlink+0x31e>
lea    0xc42(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <udev_log_null@plt>
lea    0x30(%rsp),%rsi
mov    %rbp,%rdi
call   10a0 <lstat@plt>
test   %rax,%rax
je     14fc <node_symlink+0x2dc>
lea    0xd2e(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <udev_log_null@plt>
lea    0xd33(%rip),%rcx
lea    0x30(%rsp),%r15
mov    %r15,%rdi
mov    $0x40a,%esi
mov    %r14,%rdx
xor    %r8d,%r8d
call   1120 <util_strscpyl@plt>
mov    %r15,%rdi
call   1050 <unlink@plt>
mov    0x2ba9(%rip),%rbp
mov    0x2b82(%rip),%r13
jmp    146e <node_symlink+0x24e>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1100 <udev_selinux_setfscreatecon@plt>
lea    0x440(%rsp),%rdi
mov    %r15,%rsi
call   1090 <symlink@plt>
xor    %ebx,%ebx
sub    0x0(%rbp),%ebx
test   %eax,%eax
cmove  %eax,%ebx
mov    %r12,%rdi
call   10c0 <udev_selinux_resetfscreatecon@plt>
mov    0x0(%r13),%eax
add    %ebx,%eax
jne    1489 <node_symlink+0x269>
mov    %r12,%rdi
mov    %r15,%rsi
call   1110 <util_create_path_selinux@plt>
test   %eax,%eax
je     1430 <node_symlink+0x210>
mov    %eax,%ebx
mov    0x0(%r13),%eax
add    %ebx,%eax
je     1430 <node_symlink+0x210>
jmp    148d <node_symlink+0x26d>
test   %ebx,%ebx
je     14ad <node_symlink+0x28d>
lea    0xca9(%rip),%rsi
lea    0x440(%rsp),%rdx
lea    0x30(%rsp),%rcx
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <udev_log_null@plt>
jmp    14e8 <node_symlink+0x2c8>
lea    0x30(%rsp),%rdi
mov    %r14,%rsi
call   1130 <rename@plt>
test   %eax,%eax
je     14e6 <node_symlink+0x2c6>
mov    %eax,%ebx
lea    0xc94(%rip),%rsi
lea    0x30(%rsp),%r15
mov    %r12,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <udev_log_null@plt>
mov    %r15,%rdi
call   1050 <unlink@plt>
jmp    14e8 <node_symlink+0x2c8>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x848,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ad5(%rip),%rax
xor    0x30(%rsp),%ebx
test   %ebx,(%rax)
jne    1527 <node_symlink+0x307>
mov    0x20(%rsp),%rax
cmp    0x38(%rsp),%rax
jne    1527 <node_symlink+0x307>
mov    0x28(%rsp),%rax
cmp    0x40(%rsp),%rax
jne    15f8 <node_symlink+0x3d8>
lea    0xb3b(%rip),%rsi
xor    %ebx,%ebx
mov    %r12,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
jmp    14a4 <node_symlink+0x284>
mov    %ebx,%edi
call   1060 <S_ISLNK@plt>
test   %rax,%rax
je     13e5 <node_symlink+0x1c5>
lea    0xb59(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <udev_log_null@plt>
lea    0x30(%rsp),%rsi
mov    %r14,%rdi
mov    $0x400,%edx
call   1070 <readlink@plt>
lea    -0x1(%rax),%ecx
cmp    $0x3fe,%ecx
ja     13e5 <node_symlink+0x1c5>
mov    %eax,%eax
movb   $0x0,0x30(%rsp,%rax,1)
lea    0x440(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    13e5 <node_symlink+0x1c5>
lea    0xb1f(%rip),%rsi
xor    %ebx,%ebx
lea    0x440(%rsp),%rcx
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <udev_log_null@plt>
mov    0x2a1e(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1140 <udev_selinux_lsetfilecon@plt>
mov    0x29ca(%rip),%rax
mov    (%rax),%edi
mov    0x29d9(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <utimensat@plt>
jmp    14e8 <node_symlink+0x2c8>
lea    0xa32(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1080 <udev_log_null@plt>
jmp    13e5 <node_symlink+0x1c5>

LLVM IR (-O0):
%struct.udev = type { i32 }
%struct.stat = type { i32, i64, i64 }
@.str = [4 x i8] c"../\00"
@EINVAL = global i32 0
@.str.1 = [45 x i8] c"found existing node instead of symlink '%s'\0A\00"
@S_IFMT = global i32 0
@.str.2 = [56 x i8] c"replace device node '%s' with symlink to our node '%s'\0A\00"
@.str.3 = [69 x i8] c"device node '%s' already exists, link to '%s' will not overwrite it\0A\00"
@.str.4 = [29 x i8] c"found existing symlink '%s'\0A\00"
@.str.5 = [48 x i8] c"preserve already existing symlink '%s' to '%s'\0A\00"
@S_IFLNK = global i32 0
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@.str.6 = [31 x i8] c"creating symlink '%s' to '%s'\0A\00"
@ENOENT = global i32 0
@errno = global i32 0
@.str.7 = [25 x i8] c"atomically replace '%s'\0A\00"
@.str.8 = [10 x i8] c".udev-tmp\00"
@.str.9 = [30 x i8] c"symlink '%s' '%s' failed: %m\0A\00"
@.str.10 = [29 x i8] c"rename '%s' '%s' failed: %m\0A\00"
define i32 @node_symlink(%struct.udev* %0, i8* %1, i8* %2) {
%4 = alloca %struct.udev*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.stat
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca i64
%11 = alloca [1034 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.stat
%16 = alloca [1024 x i8]
%17 = alloca i32
store %struct.udev* %0, %struct.udev** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
store i8 0, i8* %18
br label %19
19: ; preds = %54, %3
%20 = load i8*, i8** %5
%21 = load i32, i32* %12
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %41
27: ; preds = %19
%28 = load i8*, i8** %5
%29 = load i32, i32* %12
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = load i8*, i8** %6
%35 = load i32, i32* %12
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %33, %39
br label %41
41: ; preds = %27, %19
%42 = phi i1 [ false, %19 ], [ %40, %27 ]
br i1 %42, label %43, label %57
43: ; preds = %41
%44 = load i8*, i8** %5
%45 = load i32, i32* %12
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 47
br i1 %50, label %51, label %54
51: ; preds = %43
%52 = load i32, i32* %12
%53 = add nsw i32 %52, 1
store i32 %53, i32* %13
br label %54
54: ; preds = %51, %43
%55 = load i32, i32* %12
%56 = add nsw i32 %55, 1
store i32 %56, i32* %12
br label %19
57: ; preds = %41
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
store i8* %58, i8** %9
store i64 1024, i64* %10
br label %59
59: ; preds = %78, %57
%60 = load i8*, i8** %6
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %81
67: ; preds = %59
%68 = load i8*, i8** %6
%69 = load i32, i32* %12
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 47
br i1 %74, label %75, label %78
75: ; preds = %67
%76 = load i64, i64* %10
%77 = call i64 @util_strpcpy(i8** %9, i64 %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i64 %77, i64* %10
br label %78
78: ; preds = %75, %67
%79 = load i32, i32* %12
%80 = add nsw i32 %79, 1
store i32 %80, i32* %12
br label %59
81: ; preds = %59
%82 = load i8*, i8** %9
%83 = load i64, i64* %10
%84 = load i8*, i8** %5
%85 = load i32, i32* %13
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = call i64 @util_strscpy(i8* %82, i64 %83, i8* %87)
store i64 %88, i64* %10
%89 = load i64, i64* %10
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %81
%92 = load i32, i32* @EINVAL
%93 = sub nsw i32 0, %92
store i32 %93, i32* %14
br label %298
94: ; preds = %81
%95 = load i8*, i8** %6
%96 = call i64 @lstat(i8* %95, %struct.stat* %7)
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %191
98: ; preds = %94
%99 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%100 = load i32, i32* %99
%101 = call i64 @S_ISBLK(i32 %100)
%102 = icmp ne i64 %101, 0
br i1 %102, label %108, label %103
103: ; preds = %98
%104 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%105 = load i32, i32* %104
%106 = call i64 @S_ISCHR(i32 %105)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %149
108: ; preds = %103, %98
%109 = load %struct.udev*, %struct.udev** %4
%110 = load i8*, i8** %6
%111 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %109, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %110)
%112 = load i8*, i8** %5
%113 = call i64 @lstat(i8* %112, %struct.stat* %15)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %148
115: ; preds = %108
%116 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%117 = load i32, i32* %116
%118 = load i32, i32* @S_IFMT
%119 = and i32 %117, %118
%120 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%121 = load i32, i32* %120
%122 = load i32, i32* @S_IFMT
%123 = and i32 %121, %122
%124 = icmp eq i32 %119, %123
br i1 %124, label %125, label %142
125: ; preds = %115
%126 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%127 = load i64, i64* %126
%128 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%129 = load i64, i64* %128
%130 = icmp eq i64 %127, %129
br i1 %130, label %131, label %142
131: ; preds = %125
%132 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%133 = load i64, i64* %132
%134 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 2
%135 = load i64, i64* %134
%136 = icmp ne i64 %133, %135
br i1 %136, label %137, label %142
137: ; preds = %131
%138 = load %struct.udev*, %struct.udev** %4
%139 = load i8*, i8** %6
%140 = load i8*, i8** %5
%141 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %138, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i8* %139, i8* %140)
br label %147
142: ; preds = %131, %125, %115
%143 = load %struct.udev*, %struct.udev** %4
%144 = load i8*, i8** %6
%145 = load i8*, i8** %5
%146 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %143, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i8* %144, i8* %145)
br label %298
147: ; preds = %137
br label %148
148: ; preds = %147, %108
br label %190
149: ; preds = %103
%150 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%151 = load i32, i32* %150
%152 = call i64 @S_ISLNK(i32 %151)
%153 = icmp ne i64 %152, 0
br i1 %153, label %154, label %189
154: ; preds = %149
%155 = load %struct.udev*, %struct.udev** %4
%156 = load i8*, i8** %6
%157 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %155, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %156)
%158 = load i8*, i8** %6
%159 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%160 = call i32 @readlink(i8* %158, i8* %159, i32 1024)
store i32 %160, i32* %17
%161 = load i32, i32* %17
%162 = icmp sgt i32 %161, 0
br i1 %162, label %163, label %188
163: ; preds = %154
%164 = load i32, i32* %17
%165 = icmp slt i32 %164, 1024
br i1 %165, label %166, label %188
166: ; preds = %163
%167 = load i32, i32* %17
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 %168
store i8 0, i8* %169
%170 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%171 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%172 = call i64 @strcmp(i8* %170, i8* %171)
%173 = icmp eq i64 %172, 0
br i1 %173, label %174, label %187
174: ; preds = %166
%175 = load %struct.udev*, %struct.udev** %4
%176 = load i8*, i8** %6
%177 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%178 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %175, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %176, i8* %177)
%179 = load %struct.udev*, %struct.udev** %4
%180 = load i8*, i8** %6
%181 = load i32, i32* @S_IFLNK
%182 = call i32 @udev_selinux_lsetfilecon(%struct.udev* %179, i8* %180, i32 %181)
%183 = load i32, i32* @AT_FDCWD
%184 = load i8*, i8** %6
%185 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%186 = call i32 @utimensat(i32 %183, i8* %184, i32* null, i32 %185)
br label %298
187: ; preds = %166
br label %188
188: ; preds = %187, %163, %154
br label %189
189: ; preds = %188, %149
br label %190
190: ; preds = %189, %148
br label %234
191: ; preds = %94
%192 = load %struct.udev*, %struct.udev** %4
%193 = load i8*, i8** %6
%194 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%195 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %192, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %193, i8* %194)
br label %196
196: ; preds = %224, %191
%197 = load %struct.udev*, %struct.udev** %4
%198 = load i8*, i8** %6
%199 = call i32 @util_create_path_selinux(%struct.udev* %197, i8* %198)
store i32 %199, i32* %14
%200 = load i32, i32* %14
%201 = icmp ne i32 %200, 0
br i1 %201, label %202, label %208
202: ; preds = %196
%203 = load i32, i32* %14
%204 = load i32, i32* @ENOENT
%205 = sub nsw i32 0, %204
%206 = icmp ne i32 %203, %205
br i1 %206, label %207, label %208
207: ; preds = %202
br label %229
208: ; preds = %202, %196
%209 = load %struct.udev*, %struct.udev** %4
%210 = load i8*, i8** %6
%211 = load i32, i32* @S_IFLNK
%212 = call i32 @udev_selinux_setfscreatecon(%struct.udev* %209, i8* %210, i32 %211)
%213 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%214 = load i8*, i8** %6
%215 = call i32 @symlink(i8* %213, i8* %214)
store i32 %215, i32* %14
%216 = load i32, i32* %14
%217 = icmp ne i32 %216, 0
br i1 %217, label %218, label %221
218: ; preds = %208
%219 = load i32, i32* @errno
%220 = sub nsw i32 0, %219
store i32 %220, i32* %14
br label %221
221: ; preds = %218, %208
%222 = load %struct.udev*, %struct.udev** %4
%223 = call i32 @udev_selinux_resetfscreatecon(%struct.udev* %222)
br label %224
224: ; preds = %221
%225 = load i32, i32* %14
%226 = load i32, i32* @ENOENT
%227 = sub nsw i32 0, %226
%228 = icmp eq i32 %225, %227
br i1 %228, label %196, label %229
229: ; preds = %224, %207
%230 = load i32, i32* %14
%231 = icmp eq i32 %230, 0
br i1 %231, label %232, label %233
232: ; preds = %229
br label %298
233: ; preds = %229
br label %234
234: ; preds = %233, %190
%235 = load %struct.udev*, %struct.udev** %4
%236 = load i8*, i8** %6
%237 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %235, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %236)
%238 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%239 = load i8*, i8** %6
%240 = call i32 @util_strscpyl(i8* %238, i32 1034, i8* %239, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32* null)
%241 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%242 = call i32 @unlink(i8* %241)
br label %243
243: ; preds = %271, %234
%244 = load %struct.udev*, %struct.udev** %4
%245 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%246 = call i32 @util_create_path_selinux(%struct.udev* %244, i8* %245)
store i32 %246, i32* %14
%247 = load i32, i32* %14
%248 = icmp ne i32 %247, 0
br i1 %248, label %249, label %255
249: ; preds = %243
%250 = load i32, i32* %14
%251 = load i32, i32* @ENOENT
%252 = sub nsw i32 0, %251
%253 = icmp ne i32 %250, %252
br i1 %253, label %254, label %255
254: ; preds = %249
br label %276
255: ; preds = %249, %243
%256 = load %struct.udev*, %struct.udev** %4
%257 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%258 = load i32, i32* @S_IFLNK
%259 = call i32 @udev_selinux_setfscreatecon(%struct.udev* %256, i8* %257, i32 %258)
%260 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%261 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%262 = call i32 @symlink(i8* %260, i8* %261)
store i32 %262, i32* %14
%263 = load i32, i32* %14
%264 = icmp ne i32 %263, 0
br i1 %264, label %265, label %268
265: ; preds = %255
%266 = load i32, i32* @errno
%267 = sub nsw i32 0, %266
store i32 %267, i32* %14
br label %268
268: ; preds = %265, %255
%269 = load %struct.udev*, %struct.udev** %4
%270 = call i32 @udev_selinux_resetfscreatecon(%struct.udev* %269)
br label %271
271: ; preds = %268
%272 = load i32, i32* %14
%273 = load i32, i32* @ENOENT
%274 = sub nsw i32 0, %273
%275 = icmp eq i32 %272, %274
br i1 %275, label %243, label %276
276: ; preds = %271, %254
%277 = load i32, i32* %14
%278 = icmp ne i32 %277, 0
br i1 %278, label %279, label %284
279: ; preds = %276
%280 = load %struct.udev*, %struct.udev** %4
%281 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%282 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%283 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %280, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* %281, i8* %282)
br label %298
284: ; preds = %276
%285 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%286 = load i8*, i8** %6
%287 = call i32 @rename(i8* %285, i8* %286)
store i32 %287, i32* %14
%288 = load i32, i32* %14
%289 = icmp ne i32 %288, 0
br i1 %289, label %290, label %297
290: ; preds = %284
%291 = load %struct.udev*, %struct.udev** %4
%292 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%293 = load i8*, i8** %6
%294 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %291, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %292, i8* %293)
%295 = getelementptr inbounds [1034 x i8], [1034 x i8]* %11, i64 0, i64 0
%296 = call i32 @unlink(i8* %295)
br label %297
297: ; preds = %290, %284
br label %298
298: ; preds = %297, %279, %232, %174, %142, %91
%299 = load i32, i32* %14
ret i32 %299
}

LLVM IR (-O2):
%struct.udev = type { i32 }
%struct.stat = type { i32, i64, i64 }
@.str = [4 x i8] c"../\00"
@EINVAL = global i32 0
@.str.1 = [45 x i8] c"found existing node instead of symlink '%s'\0A\00"
@S_IFMT = global i32 0
@.str.2 = [56 x i8] c"replace device node '%s' with symlink to our node '%s'\0A\00"
@.str.3 = [69 x i8] c"device node '%s' already exists, link to '%s' will not overwrite it\0A\00"
@.str.4 = [29 x i8] c"found existing symlink '%s'\0A\00"
@.str.5 = [48 x i8] c"preserve already existing symlink '%s' to '%s'\0A\00"
@S_IFLNK = global i32 0
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@.str.6 = [31 x i8] c"creating symlink '%s' to '%s'\0A\00"
@ENOENT = global i32 0
@errno = global i32 0
@.str.7 = [25 x i8] c"atomically replace '%s'\0A\00"
@.str.8 = [10 x i8] c".udev-tmp\00"
@.str.9 = [30 x i8] c"symlink '%s' '%s' failed: %m\0A\00"
@.str.10 = [29 x i8] c"rename '%s' '%s' failed: %m\0A\00"
define i32 @node_symlink(%struct.udev* %0, i8* %1, i8* %2) {
%4 = alloca %struct.stat
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca [1034 x i8]
%8 = alloca %struct.stat
%9 = alloca [1024 x i8]
%10 = bitcast %struct.stat* %4 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = bitcast i8** %6 to i8*
%13 = getelementptr inbounds [1034 x i8], [1034 x i8]* %7, i64 0, i64 0
store i8 0, i8* %11
%14 = load i8, i8* %1
%15 = icmp eq i8 %14, 0
br i1 %15, label %35, label %16
16: ; preds = %3, %24
%17 = phi i64 [ %26, %24 ], [ 0, %3 ]
%18 = phi i8 [ %31, %24 ], [ %14, %3 ]
%19 = phi i32 [ %29, %24 ], [ 0, %3 ]
%20 = phi i32 [ %27, %24 ], [ 0, %3 ]
%21 = getelementptr inbounds i8, i8* %2, i64 %17
%22 = load i8, i8* %21
%23 = icmp eq i8 %18, %22
br i1 %23, label %24, label %33
24: ; preds = %16
%25 = icmp eq i8 %18, 47
%26 = add nuw i64 %17, 1
%27 = add nuw nsw i32 %20, 1
%28 = trunc i64 %26 to i32
%29 = select i1 %25, i32 %28, i32 %19
%30 = getelementptr inbounds i8, i8* %1, i64 %26
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %35, label %16
33: ; preds = %16
%34 = trunc i64 %17 to i32
br label %35
35: ; preds = %24, %33, %3
%36 = phi i32 [ 0, %3 ], [ %34, %33 ], [ %27, %24 ]
%37 = phi i32 [ 0, %3 ], [ %19, %33 ], [ %29, %24 ]
store i8* %11, i8** %6
%38 = zext i32 %36 to i64
br label %39
39: ; preds = %46, %35
%40 = phi i64 [ %48, %46 ], [ %38, %35 ]
%41 = phi i64 [ %47, %46 ], [ 1024, %35 ]
%42 = getelementptr inbounds i8, i8* %2, i64 %40
%43 = load i8, i8* %42
switch i8 %43, label %46 [
i8 0, label %49
i8 47, label %44
]
44: ; preds = %39
%45 = call i64 @util_strpcpy(i8** %6, i64 %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %46
46: ; preds = %39, %44
%47 = phi i64 [ %45, %44 ], [ %41, %39 ]
%48 = add nuw i64 %40, 1
br label %39
49: ; preds = %39
%50 = load i8*, i8** %6
%51 = sext i32 %37 to i64
%52 = getelementptr inbounds i8, i8* %1, i64 %51
%53 = call i64 @util_strscpy(i8* %50, i64 %41, i8* %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = load i32, i32* @EINVAL
%57 = sub nsw i32 0, %56
br label %177
58: ; preds = %49
%59 = call i64 @lstat(i8* %2, %struct.stat* %4)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %120
61: ; preds = %58
%62 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%63 = load i32, i32* %62
%64 = call i64 @S_ISBLK(i32 %63)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = call i64 @S_ISCHR(i32 %63)
%68 = icmp eq i64 %67, 0
br i1 %68, label %98, label %69
69: ; preds = %66, %61
%70 = bitcast %struct.stat* %8 to i8*
%71 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%72 = call i64 @lstat(i8* %1, %struct.stat* %8)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %95
74: ; preds = %69
%75 = load i32, i32* @S_IFMT
%76 = getelementptr inbounds %struct.stat, %struct.stat* %8, i64 0, i32 0
%77 = load i32, i32* %76
%78 = xor i32 %77, %63
%79 = and i32 %78, %75
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %96
81: ; preds = %74
%82 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%83 = load i64, i64* %82
%84 = getelementptr inbounds %struct.stat, %struct.stat* %8, i64 0, i32 1
%85 = load i64, i64* %84
%86 = icmp eq i64 %83, %85
br i1 %86, label %87, label %96
87: ; preds = %81
%88 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 2
%89 = load i64, i64* %88
%90 = getelementptr inbounds %struct.stat, %struct.stat* %8, i64 0, i32 2
%91 = load i64, i64* %90
%92 = icmp eq i64 %89, %91
br i1 %92, label %96, label %93
93: ; preds = %87
%94 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %1)
br label %95
95: ; preds = %93, %69
br label %143
96: ; preds = %74, %81, %87
%97 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %1)
br label %177
98: ; preds = %66
%99 = call i64 @S_ISLNK(i32 %63)
%100 = icmp eq i64 %99, 0
br i1 %100, label %143, label %101
101: ; preds = %98
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%103 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%104 = call i32 @readlink(i8* %2, i8* %102, i32 1024)
%105 = add i32 %104, -1
%106 = icmp ult i32 %105, 1023
br i1 %106, label %107, label %112
107: ; preds = %101
%108 = zext i32 %104 to i64
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 %108
store i8 0, i8* %109
%110 = call i64 @strcmp(i8* %11, i8* %102)
%111 = icmp eq i64 %110, 0
br i1 %111, label %113, label %112
112: ; preds = %107, %101
br label %143
113: ; preds = %107
%114 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* %11)
%115 = load i32, i32* @S_IFLNK
%116 = call i32 @udev_selinux_lsetfilecon(%struct.udev* %0, i8* %2, i32 %115)
%117 = load i32, i32* @AT_FDCWD
%118 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%119 = call i32 @utimensat(i32 %117, i8* %2, i32* null, i32 %118)
br label %177
120: ; preds = %58
%121 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %2, i8* %11)
br label %122
122: ; preds = %129, %120
%123 = call i32 @util_create_path_selinux(%struct.udev* %0, i8* %2)
%124 = icmp eq i32 %123, 0
br i1 %124, label %129, label %125
125: ; preds = %122
%126 = load i32, i32* @ENOENT
%127 = sub nsw i32 0, %126
%128 = icmp eq i32 %123, %127
br i1 %128, label %129, label %143
129: ; preds = %125, %122
%130 = load i32, i32* @S_IFLNK
%131 = call i32 @udev_selinux_setfscreatecon(%struct.udev* %0, i8* %2, i32 %130)
%132 = call i32 @symlink(i8* %11, i8* %2)
%133 = icmp eq i32 %132, 0
%134 = load i32, i32* @errno
%135 = sub nsw i32 0, %134
%136 = select i1 %133, i32 0, i32 %135
%137 = call i32 @udev_selinux_resetfscreatecon(%struct.udev* %0)
%138 = load i32, i32* @ENOENT
%139 = sub nsw i32 0, %138
%140 = icmp eq i32 %136, %139
br i1 %140, label %122, label %141
141: ; preds = %129
%142 = icmp eq i32 %136, 0
br i1 %142, label %177, label %143
143: ; preds = %125, %112, %95, %141, %98
%144 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%145 = call i32 @util_strscpyl(i8* %13, i32 1034, i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32* null)
%146 = call i32 @unlink(i8* %13)
br label %147
147: ; preds = %154, %143
%148 = call i32 @util_create_path_selinux(%struct.udev* %0, i8* %13)
%149 = icmp eq i32 %148, 0
br i1 %149, label %154, label %150
150: ; preds = %147
%151 = load i32, i32* @ENOENT
%152 = sub nsw i32 0, %151
%153 = icmp eq i32 %148, %152
br i1 %153, label %154, label %168
154: ; preds = %150, %147
%155 = load i32, i32* @S_IFLNK
%156 = call i32 @udev_selinux_setfscreatecon(%struct.udev* %0, i8* %13, i32 %155)
%157 = call i32 @symlink(i8* %11, i8* %13)
%158 = icmp eq i32 %157, 0
%159 = load i32, i32* @errno
%160 = sub nsw i32 0, %159
%161 = select i1 %158, i32 0, i32 %160
%162 = call i32 @udev_selinux_resetfscreatecon(%struct.udev* %0)
%163 = load i32, i32* @ENOENT
%164 = sub nsw i32 0, %163
%165 = icmp eq i32 %161, %164
br i1 %165, label %147, label %166
166: ; preds = %154
%167 = icmp eq i32 %161, 0
br i1 %167, label %171, label %168
168: ; preds = %150, %166
%169 = phi i32 [ %161, %166 ], [ %148, %150 ]
%170 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* %11, i8* %13)
br label %177
171: ; preds = %166
%172 = call i32 @rename(i8* %13, i8* %2)
%173 = icmp eq i32 %172, 0
br i1 %173, label %177, label %174
174: ; preds = %171
%175 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %13, i8* %2)
%176 = call i32 @unlink(i8* %13)
br label %177
177: ; preds = %113, %96, %55, %168, %141, %174, %171
%178 = phi i32 [ %57, %55 ], [ 0, %96 ], [ %169, %168 ], [ %172, %174 ], [ 0, %171 ], [ 0, %113 ], [ 0, %141 ]
ret i32 %178
}