#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 */
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ image;
typedef int /*<<< orphan*/ fname;
typedef int /*<<< orphan*/ dev;
typedef int /*<<< orphan*/ cookie;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int ENODEV;
int ENOENT;
int /*<<< orphan*/ ENOMEM;
int /*<<< orphan*/ F_OK;
int PATH_MAX;
int /*<<< orphan*/ __ploop_err(int, char *, ...);
scalar_t__ access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int errno;
int /*<<< orphan*/ *opendir(char *);
scalar_t__ ploop_find_top_delta_name_and_format(char *, char *, int,
                                                int /*<<< orphan*/ *,
                                                int /*<<< orphan*/);
int /*<<< orphan*/ ploop_free_array(char **);
int ploop_global_lock();
int /*<<< orphan*/ ploop_log(int /*<<< orphan*/, char *, char *);
int read_line_quiet(char *, char *, int);
struct dirent *readdir(int /*<<< orphan*/ *);
char **realloc(char **, int);
int /*<<< orphan*/ *realpath(char const *, char *);
int snprintf(char *, int, char *, ...);
scalar_t__ strcmp(char *, char const *);
char *strdup(char *);
scalar_t__ strncmp(char const *, char *, int);
int ploop_get_dev_by_delta(const char *delta, const char *topdelta,
                           const char *component_name, char **out[]) {
  char fname[PATH_MAX];
  char delta_r[PATH_MAX];
  char image[PATH_MAX];
  char dev[64];
  DIR *dp;
  struct dirent *de;
  int ret = -1;
  char cookie[64];
  int lckfd;
  int nelem = 1;
  *out = NULL;
  if (access(delta, F_OK) && errno == ENOENT)
    return 1;
  if (realpath(delta, delta_r) == NULL) {
    __ploop_err(errno, "Can't resolve %s", delta);
    return -1;
  }
  lckfd = ploop_global_lock();
  if (lckfd == -1)
    return -1;
  snprintf(fname, sizeof(fname) - 1, "/sys/block/");
  dp = opendir(fname);
  if (dp == NULL) {
    __ploop_err(errno, "Can't opendir %s", fname);
    goto err;
  }
  while ((de = readdir(dp)) != NULL) {
    int err;
    char **t;
    if (strncmp("ploop", de->d_name, 5))
      continue;
    snprintf(fname, sizeof(fname), "/sys/block/%s/pdelta/0/image", de->d_name);
    err = read_line_quiet(fname, image, sizeof(image));
    if (err) {
      if (err == ENOENT || err == ENODEV)
        continue;
      __ploop_err(err, "Can't open or read %s", fname);
      goto err;
    }
    if (strcmp(image, delta_r))
      continue;
    if (topdelta != NULL) {
      if (!(ploop_find_top_delta_name_and_format(de->d_name, image,
                                                 sizeof(image), NULL, 0) == 0 &&
            strcmp(image, topdelta) == 0))
        continue;
    }
    snprintf(fname, sizeof(fname), "/sys/block/%s/pstate/cookie", de->d_name);
    err = read_line_quiet(fname, cookie, sizeof(cookie));
    if (err) {
      if (err == ENOENT || err == ENODEV)
        continue;
      __ploop_err(err, "Can't open or read %s", fname);
      if ((errno == ENOENT) && component_name)
        __ploop_err(0, "ERROR: OpenVZ kernel with ploop cookie support "
                       "(i.e. 042stab061.1 or greater) is required");
      goto err;
    }
    if (component_name && strncmp(component_name, cookie, sizeof(cookie)))
      continue;
    if (snprintf(dev, sizeof(dev), "/dev/%s", de->d_name) >= sizeof(dev)) {
      ploop_log(0,
                "Warning: skipping bad entry "
                "in /dev: %s\n",
                de->d_name);
      continue;
    }
    t = realloc(*out, (nelem + 1) * sizeof(char *));
    if (t == NULL) {
      __ploop_err(ENOMEM, "Memory allocation failed");
      goto err;
    }
    *out = t;
    if ((t[nelem - 1] = strdup(dev)) == NULL) {
      __ploop_err(ENOMEM, "Memory allocation failed");
      goto err;
    }
    t[nelem++] = NULL;
    if (component_name)
      break;
  }
  ret = 0;
err:
  if (dp)
    closedir(dp);
  close(lckfd);
  if (ret) {
    ploop_free_array(*out);
    *out = NULL;
    return ret;
  }
  return (nelem == 1);
}


x86 assembly (clang, -O0):
<ploop_get_dev_by_delta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    0x2dbe(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x130(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x128(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
mov    (%rax),%ecx
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x120(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x40(%rbp)
mov    (%rax),%eax
mov    %rax,-0x118(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x110(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0xffffffff,-0xa4(%rbp)
ff ff ff
movl   $0x1,-0xf8(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    0x2cdc(%rip),%rax
mov    (%rax),%esi
call   1100 <access@plt>
cmp    $0x0,%rax
je     1313 <ploop_get_dev_by_delta+0x103>
mov    0x2ce4(%rip),%rax
mov    (%rax),%eax
mov    0x2cc3(%rip),%rcx
cmp    (%rcx),%eax
jne    1313 <ploop_get_dev_by_delta+0x103>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xfc(%rbp)
jmp    181c <ploop_get_dev_by_delta+0x60c>
mov    -0x120(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   10c0 <realpath@plt>
cmp    $0x0,%rax
jne    135e <ploop_get_dev_by_delta+0x14e>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xcbf(%rip),%rsi
mov    $0x0,%al
call   1130 <__ploop_err@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xfc(%rbp)
jmp    181c <ploop_get_dev_by_delta+0x60c>
mov    $0x0,%al
call   1070 <ploop_global_lock@plt>
mov    %eax,-0xf4(%rbp)
cmpl   $0xffffffff,-0xf4(%rbp)
jne    138e <ploop_get_dev_by_delta+0x17e>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xfc(%rbp)
jmp    181c <ploop_get_dev_by_delta+0x60c>
mov    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%esi
lea    0xc68(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    -0x128(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    13f4 <ploop_get_dev_by_delta+0x1e4>
mov    -0x128(%rbp),%rdx
mov    0x2bf1(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
mov    $0x0,%al
call   1130 <__ploop_err@plt>
jmp    179f <ploop_get_dev_by_delta+0x58f>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
mov    -0x98(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0xa0(%rbp)
cmp    $0x0,%rax
je     1795 <ploop_get_dev_by_delta+0x585>
mov    -0xa0(%rbp),%rax
mov    (%rax),%rsi
lea    0xc07(%rip),%rdi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1440 <ploop_get_dev_by_delta+0x230>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
mov    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rax
mov    %eax,%esi
mov    -0xa0(%rbp),%rax
mov    (%rax),%rcx
lea    0xbd3(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    -0x128(%rbp),%rdi
mov    -0x110(%rbp),%rsi
mov    -0x118(%rbp),%rax
mov    %eax,%edx
call   1060 <read_line_quiet@plt>
mov    %eax,-0x100(%rbp)
cmpl   $0x0,-0x100(%rbp)
je     14e6 <ploop_get_dev_by_delta+0x2d6>
mov    -0x100(%rbp),%eax
mov    0x2b14(%rip),%rcx
cmp    (%rcx),%eax
je     14c1 <ploop_get_dev_by_delta+0x2b1>
mov    -0x100(%rbp),%eax
mov    0x2b0f(%rip),%rcx
cmp    (%rcx),%eax
jne    14c6 <ploop_get_dev_by_delta+0x2b6>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
mov    -0x128(%rbp),%rdx
mov    -0x100(%rbp),%edi
lea    0xb77(%rip),%rsi
mov    $0x0,%al
call   1130 <__ploop_err@plt>
jmp    179f <ploop_get_dev_by_delta+0x58f>
mov    -0x120(%rbp),%rsi
mov    -0x110(%rbp),%rdi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1508 <ploop_get_dev_by_delta+0x2f8>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
cmpq   $0x0,-0x18(%rbp)
je     1567 <ploop_get_dev_by_delta+0x357>
mov    -0x110(%rbp),%rsi
mov    -0x118(%rbp),%rax
mov    -0xa0(%rbp),%rcx
mov    (%rcx),%rdi
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
call   10e0 <ploop_find_top_delta_name_and_format@plt>
cmp    $0x0,%rax
jne    155d <ploop_get_dev_by_delta+0x34d>
mov    -0x110(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1562 <ploop_get_dev_by_delta+0x352>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
jmp    1567 <ploop_get_dev_by_delta+0x357>
mov    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rax
mov    %eax,%esi
mov    -0xa0(%rbp),%rax
mov    (%rax),%rcx
lea    0xadf(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    -0x128(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    $0x40,%edx
call   1060 <read_line_quiet@plt>
mov    %eax,-0x100(%rbp)
cmpl   $0x0,-0x100(%rbp)
je     163c <ploop_get_dev_by_delta+0x42c>
mov    -0x100(%rbp),%eax
mov    0x29f1(%rip),%rcx
cmp    (%rcx),%eax
je     15e4 <ploop_get_dev_by_delta+0x3d4>
mov    -0x100(%rbp),%eax
mov    0x29ec(%rip),%rcx
cmp    (%rcx),%eax
jne    15e9 <ploop_get_dev_by_delta+0x3d9>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
mov    -0x128(%rbp),%rdx
mov    -0x100(%rbp),%edi
lea    0xa54(%rip),%rsi
mov    $0x0,%al
call   1130 <__ploop_err@plt>
mov    0x29c5(%rip),%rax
mov    (%rax),%eax
mov    0x29a4(%rip),%rcx
cmp    (%rcx),%eax
jne    1637 <ploop_get_dev_by_delta+0x427>
cmpq   $0x0,-0x20(%rbp)
je     1637 <ploop_get_dev_by_delta+0x427>
xor    %edi,%edi
lea    0xa53(%rip),%rsi
mov    $0x0,%al
call   1130 <__ploop_err@plt>
jmp    179f <ploop_get_dev_by_delta+0x58f>
cmpq   $0x0,-0x20(%rbp)
je     166b <ploop_get_dev_by_delta+0x45b>
mov    -0x20(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    $0x40,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     166b <ploop_get_dev_by_delta+0x45b>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
lea    -0x90(%rbp),%rdi
mov    -0xa0(%rbp),%rax
mov    (%rax),%rcx
mov    $0x40,%esi
lea    0xa55(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
cltq
cmp    $0x40,%rax
jb     16b8 <ploop_get_dev_by_delta+0x4a8>
mov    -0xa0(%rbp),%rax
mov    (%rax),%rdx
xor    %edi,%edi
lea    0xa37(%rip),%rsi
call   1110 <ploop_log@plt>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   10f0 <realloc@plt>
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x108(%rbp)
jne    1706 <ploop_get_dev_by_delta+0x4f6>
mov    0x28e7(%rip),%rax
mov    (%rax),%edi
lea    0xa14(%rip),%rsi
mov    $0x0,%al
call   1130 <__ploop_err@plt>
jmp    179f <ploop_get_dev_by_delta+0x58f>
mov    -0x108(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x90(%rbp),%rdi
call   1120 <strdup@plt>
mov    -0x108(%rbp),%rcx
mov    -0xf8(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    175d <ploop_get_dev_by_delta+0x54d>
mov    0x2890(%rip),%rax
mov    (%rax),%edi
lea    0x9bd(%rip),%rsi
mov    $0x0,%al
call   1130 <__ploop_err@plt>
jmp    179f <ploop_get_dev_by_delta+0x58f>
mov    -0x108(%rbp),%rax
mov    -0xf8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0xf8(%rbp)
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
cmpq   $0x0,-0x20(%rbp)
je     1790 <ploop_get_dev_by_delta+0x580>
jmp    1795 <ploop_get_dev_by_delta+0x585>
jmp    13f9 <ploop_get_dev_by_delta+0x1e9>
movl   $0x0,-0xa4(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     17b9 <ploop_get_dev_by_delta+0x5a9>
mov    -0x98(%rbp),%rdi
call   10a0 <closedir@plt>
mov    -0xf4(%rbp),%edi
call   1090 <close@plt>
cmpl   $0x0,-0xa4(%rbp)
je     1800 <ploop_get_dev_by_delta+0x5f0>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1030 <ploop_free_array@plt>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0xa4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0xfc(%rbp)
jmp    181c <ploop_get_dev_by_delta+0x60c>
cmpl   $0x1,-0xf8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0xfc(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ploop_get_dev_by_delta>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rcx,%r13
mov    %rdx,-0x58(%rbp)
mov    %rsi,-0x60(%rbp)
mov    %rdi,%rbx
mov    0x2db7(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
mov    %rax,-0x50(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
movq   $0x0,0x0(%r13)
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
call   1100 <access@plt>
test   %rax,%rax
je     129e <ploop_get_dev_by_delta+0x8e>
mov    0x2d48(%rip),%rax
mov    (%rax),%edx
mov    0x2d27(%rip),%rcx
mov    $0x1,%eax
cmp    (%rcx),%edx
je     15b7 <ploop_get_dev_by_delta+0x3a7>
mov    %rbx,%rdi
mov    -0x68(%rbp),%rsi
call   10c0 <realpath@plt>
test   %rax,%rax
je     131b <ploop_get_dev_by_delta+0x10b>
xor    %eax,%eax
call   1070 <ploop_global_lock@plt>
mov    %eax,%ebx
mov    $0xffffffff,%eax
cmp    $0xffffffff,%ebx
je     15b7 <ploop_get_dev_by_delta+0x3a7>
mov    -0x50(%rbp),%rax
lea    -0x1(%rax),%esi
lea    0xd3d(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r15,%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     133a <ploop_get_dev_by_delta+0x12a>
mov    %r13,-0x48(%rbp)
mov    %rax,-0x30(%rbp)
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     1360 <ploop_get_dev_by_delta+0x150>
mov    %rax,%r13
mov    %ebx,-0x34(%rbp)
mov    $0x1,%eax
mov    %rax,-0x40(%rbp)
lea    0xd18(%rip),%rbx
jmp    13a5 <ploop_get_dev_by_delta+0x195>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
lea    0xcd5(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1130 <__ploop_err@plt>
jmp    15b2 <ploop_get_dev_by_delta+0x3a2>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
lea    0xcd3(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1130 <__ploop_err@plt>
mov    %ebx,%edi
call   1090 <close@plt>
jmp    15a1 <ploop_get_dev_by_delta+0x391>
mov    $0x1,%r14d
mov    -0x48(%rbp),%r13
mov    -0x30(%rbp),%rdi
jmp    1582 <ploop_get_dev_by_delta+0x372>
mov    0x0(%r13),%rdx
xor    %edi,%edi
lea    0xd65(%rip),%rsi
call   1110 <ploop_log@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x30(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
je     1573 <ploop_get_dev_by_delta+0x363>
mov    0x0(%r13),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1390 <ploop_get_dev_by_delta+0x180>
mov    %rbx,%r14
mov    0x0(%r13),%rcx
mov    %r15,%rdi
mov    -0x50(%rbp),%rbx
mov    %ebx,%esi
lea    0xc62(%rip),%rdx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1060 <read_line_quiet@plt>
test   %eax,%eax
je     1409 <ploop_get_dev_by_delta+0x1f9>
mov    0x2bc7(%rip),%rcx
cmp    (%rcx),%eax
je     141a <ploop_get_dev_by_delta+0x20a>
mov    0x2bcc(%rip),%rcx
cmp    (%rcx),%eax
jne    15c6 <ploop_get_dev_by_delta+0x3b6>
mov    %r14,%rbx
jmp    1390 <ploop_get_dev_by_delta+0x180>
mov    %r12,%rdi
mov    -0x68(%rbp),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1426 <ploop_get_dev_by_delta+0x216>
mov    -0x30(%rbp),%rdi
mov    %r14,%rbx
jmp    1394 <ploop_get_dev_by_delta+0x184>
cmpq   $0x0,-0x60(%rbp)
mov    %r14,%rbx
je     1463 <ploop_get_dev_by_delta+0x253>
mov    0x0(%r13),%rdi
mov    %r12,%rsi
mov    -0x50(%rbp),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <ploop_find_top_delta_name_and_format@plt>
test   %rax,%rax
jne    1390 <ploop_get_dev_by_delta+0x180>
mov    %r12,%rdi
mov    -0x60(%rbp),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1390 <ploop_get_dev_by_delta+0x180>
mov    0x0(%r13),%rcx
mov    %r15,%rdi
mov    -0x50(%rbp),%rsi
lea    0xbf2(%rip),%rdx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r15,%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x40,%edx
call   1060 <read_line_quiet@plt>
test   %eax,%eax
je     14b7 <ploop_get_dev_by_delta+0x2a7>
mov    0x2b1d(%rip),%rcx
cmp    (%rcx),%eax
je     1390 <ploop_get_dev_by_delta+0x180>
mov    0x2b1e(%rip),%rcx
cmp    (%rcx),%eax
je     1390 <ploop_get_dev_by_delta+0x180>
jmp    15ed <ploop_get_dev_by_delta+0x3dd>
mov    -0x58(%rbp),%rdi
test   %rdi,%rdi
je     14da <ploop_get_dev_by_delta+0x2ca>
lea    -0xb0(%rbp),%rsi
mov    $0x40,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1390 <ploop_get_dev_by_delta+0x180>
mov    0x0(%r13),%rcx
lea    -0xf0(%rbp),%rdi
mov    $0x40,%esi
lea    0xbec(%rip),%rdx
xor    %eax,%eax
call   1080 <snprintf@plt>
cmp    $0x40,%eax
jae    1373 <ploop_get_dev_by_delta+0x163>
mov    -0x48(%rbp),%rax
mov    %rax,%r14
mov    (%rax),%rdi
mov    -0x40(%rbp),%rax
lea    0x8(,%rax,8),%esi
call   10f0 <realloc@plt>
test   %rax,%rax
je     163b <ploop_get_dev_by_delta+0x42b>
mov    %rax,%r13
mov    %rax,(%r14)
lea    -0xf0(%rbp),%rdi
call   1120 <strdup@plt>
mov    -0x40(%rbp),%r14
movslq %r14d,%rcx
mov    %rax,-0x8(%r13,%rcx,8)
test   %rax,%rax
je     165a <ploop_get_dev_by_delta+0x44a>
lea    0x1(%rcx),%eax
mov    %rax,-0x40(%rbp)
movq   $0x0,0x0(%r13,%rcx,8)
cmpq   $0x0,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
je     1394 <ploop_get_dev_by_delta+0x184>
mov    -0x48(%rbp),%r13
mov    -0x34(%rbp),%ebx
jmp    157e <ploop_get_dev_by_delta+0x36e>
mov    -0x48(%rbp),%r13
mov    -0x34(%rbp),%ebx
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%r14
mov    $0x1,%r12b
call   10a0 <closedir@plt>
mov    %ebx,%edi
call   1090 <close@plt>
test   %r12b,%r12b
je     15a1 <ploop_get_dev_by_delta+0x391>
xor    %eax,%eax
cmp    $0x1,%r14d
sete   %al
jmp    15b7 <ploop_get_dev_by_delta+0x3a7>
mov    0x0(%r13),%rdi
call   1030 <ploop_free_array@plt>
movq   $0x0,0x0(%r13)
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa84(%rip),%rsi
xor    %r12d,%r12d
mov    %eax,%edi
mov    %r15,%rdx
xor    %eax,%eax
call   1130 <__ploop_err@plt>
mov    -0x48(%rbp),%r13
mov    -0x34(%rbp),%ebx
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%r14
jmp    1585 <ploop_get_dev_by_delta+0x375>
lea    0xa5d(%rip),%rsi
xor    %r12d,%r12d
mov    %eax,%edi
mov    %r15,%rdx
xor    %eax,%eax
call   1130 <__ploop_err@plt>
cmpq   $0x0,-0x58(%rbp)
je     15dc <ploop_get_dev_by_delta+0x3cc>
mov    0x29bf(%rip),%rax
mov    0x29a0(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,(%rax)
mov    -0x48(%rbp),%r13
mov    -0x40(%rbp),%r14
jne    1678 <ploop_get_dev_by_delta+0x468>
lea    0xa56(%rip),%rsi
xor    %r12d,%r12d
xor    %edi,%edi
xor    %eax,%eax
call   1130 <__ploop_err@plt>
jmp    1678 <ploop_get_dev_by_delta+0x468>
mov    0x2996(%rip),%rax
mov    (%rax),%edi
lea    0xac3(%rip),%rsi
xor    %r12d,%r12d
xor    %eax,%eax
call   1130 <__ploop_err@plt>
mov    %r14,%r13
jmp    15e0 <ploop_get_dev_by_delta+0x3d0>
mov    0x2977(%rip),%rax
mov    (%rax),%edi
lea    0xaa4(%rip),%rsi
xor    %r12d,%r12d
xor    %eax,%eax
call   1130 <__ploop_err@plt>
mov    -0x48(%rbp),%r13
mov    -0x34(%rbp),%ebx
mov    -0x30(%rbp),%rdi
jmp    1585 <ploop_get_dev_by_delta+0x375>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@PATH_MAX = global i32 0
@F_OK = global i32 0
@errno = global i32 0
@ENOENT = global i32 0
@.str = [17 x i8] c"Can't resolve %s\00"
@.str.1 = [12 x i8] c"/sys/block/\00"
@.str.2 = [17 x i8] c"Can't opendir %s\00"
@.str.3 = [6 x i8] c"ploop\00"
@.str.4 = [29 x i8] c"/sys/block/%s/pdelta/0/image\00"
@ENODEV = global i32 0
@.str.5 = [22 x i8] c"Can't open or read %s\00"
@.str.6 = [28 x i8] c"/sys/block/%s/pstate/cookie\00"
@.str.7 = [90 x i8] c"ERROR: OpenVZ kernel with ploop cookie support (i.e. 042stab061.1 or greater) is required\00"
@.str.8 = [8 x i8] c"/dev/%s\00"
@.str.9 = [41 x i8] c"Warning: skipping bad entry in /dev: %s\0A\00"
@ENOMEM = global i32 0
@.str.10 = [25 x i8] c"Memory allocation failed\00"
define i32 @ploop_get_dev_by_delta(i8* %0, i8* %1, i8* %2, i8*** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8***
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca [64 x i8]
%15 = alloca i32*
%16 = alloca %struct.dirent*
%17 = alloca i32
%18 = alloca [64 x i8]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i8**
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8*** %3, i8**** %9
%24 = load i32, i32* @PATH_MAX
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %10
%27 = alloca i8, i64 %25
store i64 %25, i64* %11
%28 = load i32, i32* @PATH_MAX
%29 = zext i32 %28 to i64
%30 = alloca i8, i64 %29
store i64 %29, i64* %12
%31 = load i32, i32* @PATH_MAX
%32 = zext i32 %31 to i64
%33 = alloca i8, i64 %32
store i64 %32, i64* %13
store i32 -1, i32* %17
store i32 1, i32* %20
%34 = load i8***, i8**** %9
store i8** null, i8*** %34
%35 = load i8*, i8** %6
%36 = load i32, i32* @F_OK
%37 = call i64 @access(i8* %35, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %4
%40 = load i32, i32* @errno
%41 = load i32, i32* @ENOENT
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 1, i32* %5
store i32 1, i32* %21
br label %234
44: ; preds = %39, %4
%45 = load i8*, i8** %6
%46 = call i32* @realpath(i8* %45, i8* %30)
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = load i32, i32* @errno
%50 = load i8*, i8** %6
%51 = call i32 (i32, i8*, ...) @__ploop_err(i32 %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %50)
store i32 -1, i32* %5
store i32 1, i32* %21
br label %234
52: ; preds = %44
%53 = call i32 (...) @ploop_global_lock()
store i32 %53, i32* %19
%54 = load i32, i32* %19
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 -1, i32* %5
store i32 1, i32* %21
br label %234
57: ; preds = %52
%58 = sub i64 %25, 1
%59 = trunc i64 %58 to i32
%60 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %27, i32 %59, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%61 = call i32* @opendir(i8* %27)
store i32* %61, i32** %15
%62 = load i32*, i32** %15
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = load i32, i32* @errno
%66 = call i32 (i32, i8*, ...) @__ploop_err(i32 %65, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %213
67: ; preds = %57
br label %68
68: ; preds = %211, %169, %160, %139, %119, %104, %97, %78, %67
%69 = load i32*, i32** %15
%70 = call %struct.dirent* @readdir(i32* %69)
store %struct.dirent* %70, %struct.dirent** %16
%71 = icmp ne %struct.dirent* %70, null
br i1 %71, label %72, label %212
72: ; preds = %68
%73 = load %struct.dirent*, %struct.dirent** %16
%74 = getelementptr inbounds %struct.dirent, %struct.dirent* %73, i32 0, i32 0
%75 = load i8*, i8** %74
%76 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %75, i32 5)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %72
br label %68
79: ; preds = %72
%80 = trunc i64 %25 to i32
%81 = load %struct.dirent*, %struct.dirent** %16
%82 = getelementptr inbounds %struct.dirent, %struct.dirent* %81, i32 0, i32 0
%83 = load i8*, i8** %82
%84 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %27, i32 %80, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %83)
%85 = trunc i64 %32 to i32
%86 = call i32 @read_line_quiet(i8* %27, i8* %33, i32 %85)
store i32 %86, i32* %22
%87 = load i32, i32* %22
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %101
89: ; preds = %79
%90 = load i32, i32* %22
%91 = load i32, i32* @ENOENT
%92 = icmp eq i32 %90, %91
br i1 %92, label %97, label %93
93: ; preds = %89
%94 = load i32, i32* %22
%95 = load i32, i32* @ENODEV
%96 = icmp eq i32 %94, %95
br i1 %96, label %97, label %98
97: ; preds = %93, %89
br label %68
98: ; preds = %93
%99 = load i32, i32* %22
%100 = call i32 (i32, i8*, ...) @__ploop_err(i32 %99, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %27)
br label %213
101: ; preds = %79
%102 = call i64 @strcmp(i8* %33, i8* %30)
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %105
104: ; preds = %101
br label %68
105: ; preds = %101
%106 = load i8*, i8** %7
%107 = icmp ne i8* %106, null
br i1 %107, label %108, label %121
108: ; preds = %105
%109 = load %struct.dirent*, %struct.dirent** %16
%110 = getelementptr inbounds %struct.dirent, %struct.dirent* %109, i32 0, i32 0
%111 = load i8*, i8** %110
%112 = trunc i64 %32 to i32
%113 = call i64 @ploop_find_top_delta_name_and_format(i8* %111, i8* %33, i32 %112, i32* null, i32 0)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %119
115: ; preds = %108
%116 = load i8*, i8** %7
%117 = call i64 @strcmp(i8* %33, i8* %116)
%118 = icmp eq i64 %117, 0
br i1 %118, label %120, label %119
119: ; preds = %115, %108
br label %68
120: ; preds = %115
br label %121
121: ; preds = %120, %105
%122 = trunc i64 %25 to i32
%123 = load %struct.dirent*, %struct.dirent** %16
%124 = getelementptr inbounds %struct.dirent, %struct.dirent* %123, i32 0, i32 0
%125 = load i8*, i8** %124
%126 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %27, i32 %122, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %125)
%127 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%128 = call i32 @read_line_quiet(i8* %27, i8* %127, i32 64)
store i32 %128, i32* %22
%129 = load i32, i32* %22
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %152
131: ; preds = %121
%132 = load i32, i32* %22
%133 = load i32, i32* @ENOENT
%134 = icmp eq i32 %132, %133
br i1 %134, label %139, label %135
135: ; preds = %131
%136 = load i32, i32* %22
%137 = load i32, i32* @ENODEV
%138 = icmp eq i32 %136, %137
br i1 %138, label %139, label %140
139: ; preds = %135, %131
br label %68
140: ; preds = %135
%141 = load i32, i32* %22
%142 = call i32 (i32, i8*, ...) @__ploop_err(i32 %141, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %27)
%143 = load i32, i32* @errno
%144 = load i32, i32* @ENOENT
%145 = icmp eq i32 %143, %144
br i1 %145, label %146, label %151
146: ; preds = %140
%147 = load i8*, i8** %8
%148 = icmp ne i8* %147, null
br i1 %148, label %149, label %151
149: ; preds = %146
%150 = call i32 (i32, i8*, ...) @__ploop_err(i32 0, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.7, i64 0, i64 0))
br label %151
151: ; preds = %149, %146, %140
br label %213
152: ; preds = %121
%153 = load i8*, i8** %8
%154 = icmp ne i8* %153, null
br i1 %154, label %155, label %161
155: ; preds = %152
%156 = load i8*, i8** %8
%157 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%158 = call i64 @strncmp(i8* %156, i8* %157, i32 64)
%159 = icmp ne i64 %158, 0
br i1 %159, label %160, label %161
160: ; preds = %155
br label %68
161: ; preds = %155, %152
%162 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%163 = load %struct.dirent*, %struct.dirent** %16
%164 = getelementptr inbounds %struct.dirent, %struct.dirent* %163, i32 0, i32 0
%165 = load i8*, i8** %164
%166 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %162, i32 64, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %165)
%167 = sext i32 %166 to i64
%168 = icmp uge i64 %167, 64
br i1 %168, label %169, label %174
169: ; preds = %161
%170 = load %struct.dirent*, %struct.dirent** %16
%171 = getelementptr inbounds %struct.dirent, %struct.dirent* %170, i32 0, i32 0
%172 = load i8*, i8** %171
%173 = call i32 @ploop_log(i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8* %172)
br label %68
174: ; preds = %161
%175 = load i8***, i8**** %9
%176 = load i8**, i8*** %175
%177 = load i32, i32* %20
%178 = add nsw i32 %177, 1
%179 = sext i32 %178 to i64
%180 = mul i64 %179, 8
%181 = trunc i64 %180 to i32
%182 = call i8** @realloc(i8** %176, i32 %181)
store i8** %182, i8*** %23
%183 = load i8**, i8*** %23
%184 = icmp eq i8** %183, null
br i1 %184, label %185, label %188
185: ; preds = %174
%186 = load i32, i32* @ENOMEM
%187 = call i32 (i32, i8*, ...) @__ploop_err(i32 %186, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %213
188: ; preds = %174
%189 = load i8**, i8*** %23
%190 = load i8***, i8**** %9
store i8** %189, i8*** %190
%191 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%192 = call i8* @strdup(i8* %191)
%193 = load i8**, i8*** %23
%194 = load i32, i32* %20
%195 = sub nsw i32 %194, 1
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds i8*, i8** %193, i64 %196
store i8* %192, i8** %197
%198 = icmp eq i8* %192, null
br i1 %198, label %199, label %202
199: ; preds = %188
%200 = load i32, i32* @ENOMEM
%201 = call i32 (i32, i8*, ...) @__ploop_err(i32 %200, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %213
202: ; preds = %188
%203 = load i8**, i8*** %23
%204 = load i32, i32* %20
%205 = add nsw i32 %204, 1
store i32 %205, i32* %20
%206 = sext i32 %204 to i64
%207 = getelementptr inbounds i8*, i8** %203, i64 %206
store i8* null, i8** %207
%208 = load i8*, i8** %8
%209 = icmp ne i8* %208, null
br i1 %209, label %210, label %211
210: ; preds = %202
br label %212
211: ; preds = %202
br label %68
212: ; preds = %210, %68
store i32 0, i32* %17
br label %213
213: ; preds = %212, %199, %185, %151, %98, %64
%214 = load i32*, i32** %15
%215 = icmp ne i32* %214, null
br i1 %215, label %216, label %219
216: ; preds = %213
%217 = load i32*, i32** %15
%218 = call i32 @closedir(i32* %217)
br label %219
219: ; preds = %216, %213
%220 = load i32, i32* %19
%221 = call i32 @close(i32 %220)
%222 = load i32, i32* %17
%223 = icmp ne i32 %222, 0
br i1 %223, label %224, label %230
224: ; preds = %219
%225 = load i8***, i8**** %9
%226 = load i8**, i8*** %225
%227 = call i32 @ploop_free_array(i8** %226)
%228 = load i8***, i8**** %9
store i8** null, i8*** %228
%229 = load i32, i32* %17
store i32 %229, i32* %5
store i32 1, i32* %21
br label %234
230: ; preds = %219
%231 = load i32, i32* %20
%232 = icmp eq i32 %231, 1
%233 = zext i1 %232 to i32
store i32 %233, i32* %5
store i32 1, i32* %21
br label %234
234: ; preds = %230, %224, %56, %48, %43
%235 = load i8*, i8** %10
%236 = load i32, i32* %5
ret i32 %236
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@PATH_MAX = global i32 0
@F_OK = global i32 0
@errno = global i32 0
@ENOENT = global i32 0
@.str = [17 x i8] c"Can't resolve %s\00"
@.str.1 = [12 x i8] c"/sys/block/\00"
@.str.2 = [17 x i8] c"Can't opendir %s\00"
@.str.3 = [6 x i8] c"ploop\00"
@.str.4 = [29 x i8] c"/sys/block/%s/pdelta/0/image\00"
@ENODEV = global i32 0
@.str.5 = [22 x i8] c"Can't open or read %s\00"
@.str.6 = [28 x i8] c"/sys/block/%s/pstate/cookie\00"
@.str.7 = [90 x i8] c"ERROR: OpenVZ kernel with ploop cookie support (i.e. 042stab061.1 or greater) is required\00"
@.str.8 = [8 x i8] c"/dev/%s\00"
@.str.9 = [41 x i8] c"Warning: skipping bad entry in /dev: %s\0A\00"
@ENOMEM = global i32 0
@.str.10 = [25 x i8] c"Memory allocation failed\00"
define i32 @ploop_get_dev_by_delta(i8* %0, i8* %1, i8* %2, i8*** nocapture %3) {
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
%7 = load i32, i32* @PATH_MAX
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = alloca i8, i64 %8
%11 = alloca i8, i64 %8
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
store i8** null, i8*** %3
%14 = load i32, i32* @F_OK
%15 = tail call i64 @access(i8* %0, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %4
%18 = load i32, i32* @errno
%19 = load i32, i32* @ENOENT
%20 = icmp eq i32 %18, %19
br i1 %20, label %143, label %21
21: ; preds = %17, %4
%22 = call i32* @realpath(i8* %0, i8* %10)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @errno
%26 = call i32 (i32, i8*, ...) @__ploop_err(i32 %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %143
27: ; preds = %21
%28 = call i32 (...) @ploop_global_lock()
%29 = icmp eq i32 %28, -1
br i1 %29, label %143, label %30
30: ; preds = %27
%31 = add i32 %7, -1
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32* @opendir(i8* %9)
%34 = icmp eq i32* %33, null
br i1 %34, label %41, label %35
35: ; preds = %30
%36 = call %struct.dirent* @readdir(i32* %33)
%37 = icmp eq %struct.dirent* %36, null
br i1 %37, label %132, label %38
38: ; preds = %35
%39 = icmp eq i8* %1, null
%40 = icmp eq i8* %2, null
br label %45
41: ; preds = %30
%42 = load i32, i32* @errno
%43 = call i32 (i32, i8*, ...) @__ploop_err(i32 %42, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%44 = call i32 @close(i32 %28)
br label %137
45: ; preds = %38, %128
%46 = phi %struct.dirent* [ %36, %38 ], [ %130, %128 ]
%47 = phi i32 [ 1, %38 ], [ %129, %128 ]
%48 = getelementptr inbounds %struct.dirent, %struct.dirent* %46, i64 0, i32 0
%49 = load i8*, i8** %48
%50 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %49, i32 5)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %128
52: ; preds = %45
%53 = load i8*, i8** %48
%54 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %53)
%55 = call i32 @read_line_quiet(i8* %9, i8* %11, i32 %7)
%56 = icmp eq i32 %55, 0
br i1 %56, label %65, label %57
57: ; preds = %52
%58 = load i32, i32* @ENOENT
%59 = icmp eq i32 %55, %58
%60 = load i32, i32* @ENODEV
%61 = icmp eq i32 %55, %60
%62 = select i1 %59, i1 true, i1 %61
br i1 %62, label %128, label %63
63: ; preds = %57
%64 = call i32 (i32, i8*, ...) @__ploop_err(i32 %55, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %9)
br label %132
65: ; preds = %52
%66 = call i64 @strcmp(i8* %11, i8* %10)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %128
68: ; preds = %65
br i1 %39, label %76, label %69
69: ; preds = %68
%70 = load i8*, i8** %48
%71 = call i64 @ploop_find_top_delta_name_and_format(i8* %70, i8* %11, i32 %7, i32* null, i32 0)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %128
73: ; preds = %69
%74 = call i64 @strcmp(i8* %11, i8* %1)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %128
76: ; preds = %73, %68
%77 = load i8*, i8** %48
%78 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %77)
%79 = call i32 @read_line_quiet(i8* %9, i8* %13, i32 64)
%80 = icmp eq i32 %79, 0
br i1 %80, label %96, label %81
81: ; preds = %76
%82 = load i32, i32* @ENOENT
%83 = icmp eq i32 %79, %82
%84 = load i32, i32* @ENODEV
%85 = icmp eq i32 %79, %84
%86 = select i1 %83, i1 true, i1 %85
br i1 %86, label %128, label %87
87: ; preds = %81
%88 = call i32 (i32, i8*, ...) @__ploop_err(i32 %79, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%89 = load i32, i32* @errno
%90 = load i32, i32* @ENOENT
%91 = icmp eq i32 %89, %90
%92 = icmp ne i8* %2, null
%93 = and i1 %92, %91
br i1 %93, label %94, label %132
94: ; preds = %87
%95 = call i32 (i32, i8*, ...) @__ploop_err(i32 0, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.7, i64 0, i64 0))
br label %132
96: ; preds = %76
br i1 %40, label %100, label %97
97: ; preds = %96
%98 = call i64 @strncmp(i8* %2, i8* %13, i32 64)
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %128
100: ; preds = %97, %96
%101 = load i8*, i8** %48
%102 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %12, i32 64, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %101)
%103 = icmp ugt i32 %102, 63
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = load i8*, i8** %48
%106 = call i32 @ploop_log(i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8* %105)
br label %128
107: ; preds = %100
%108 = load i8**, i8*** %3
%109 = add nsw i32 %47, 1
%110 = shl i32 %109, 3
%111 = call i8** @realloc(i8** %108, i32 %110)
%112 = icmp eq i8** %111, null
br i1 %112, label %113, label %116
113: ; preds = %107
%114 = load i32, i32* @ENOMEM
%115 = call i32 (i32, i8*, ...) @__ploop_err(i32 %114, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %132
116: ; preds = %107
store i8** %111, i8*** %3
%117 = call i8* @strdup(i8* %12)
%118 = add nsw i32 %47, -1
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8*, i8** %111, i64 %119
store i8* %117, i8** %120
%121 = icmp eq i8* %117, null
br i1 %121, label %122, label %125
122: ; preds = %116
%123 = load i32, i32* @ENOMEM
%124 = call i32 (i32, i8*, ...) @__ploop_err(i32 %123, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %132
125: ; preds = %116
%126 = sext i32 %47 to i64
%127 = getelementptr inbounds i8*, i8** %111, i64 %126
store i8* null, i8** %127
br i1 %40, label %128, label %132
128: ; preds = %125, %97, %81, %69, %73, %65, %57, %45, %104
%129 = phi i32 [ %47, %104 ], [ %47, %45 ], [ %47, %57 ], [ %47, %65 ], [ %47, %73 ], [ %47, %69 ], [ %47, %81 ], [ %47, %97 ], [ %109, %125 ]
%130 = call %struct.dirent* @readdir(i32* %33)
%131 = icmp eq %struct.dirent* %130, null
br i1 %131, label %132, label %45
132: ; preds = %125, %128, %63, %113, %122, %94, %87, %35
%133 = phi i1 [ false, %63 ], [ false, %113 ], [ false, %122 ], [ false, %94 ], [ false, %87 ], [ true, %35 ], [ true, %128 ], [ true, %125 ]
%134 = phi i32 [ %47, %63 ], [ %47, %113 ], [ %47, %122 ], [ %47, %94 ], [ %47, %87 ], [ 1, %35 ], [ %109, %125 ], [ %129, %128 ]
%135 = call i32 @closedir(i32* %33)
%136 = call i32 @close(i32 %28)
br i1 %133, label %140, label %137
137: ; preds = %132, %41
%138 = load i8**, i8*** %3
%139 = call i32 @ploop_free_array(i8** %138)
store i8** null, i8*** %3
br label %143
140: ; preds = %132
%141 = icmp eq i32 %134, 1
%142 = zext i1 %141 to i32
br label %143
143: ; preds = %27, %17, %140, %137, %24
%144 = phi i32 [ -1, %24 ], [ -1, %137 ], [ %142, %140 ], [ 1, %17 ], [ -1, %27 ]
ret i32 %144
}