#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 stat {
  scalar_t__ st_dev;
};
struct dirent {
  scalar_t__ d_type;
  int /*<<< orphan*/ d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ AT_REMOVEDIR;
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
scalar_t__ DT_DIR;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int dirfd(int /*<<< orphan*/ *);
int /*<<< orphan*/ errmsg(int /*<<< orphan*/, int /*<<< orphan*/, int, char *,
                          ...);
scalar_t__ errno;
int /*<<< orphan*/ *fdopendir(int);
scalar_t__ fstat(int, struct stat *);
scalar_t__ fstatat(int, int /*<<< orphan*/, struct stat *, int /*<<< orphan*/);
int openat(int, int /*<<< orphan*/, int /*<<< orphan*/);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
scalar_t__ unlinkat(int, int /*<<< orphan*/, int /*<<< orphan*/);
int recursiveRemove(int fd) {
  struct stat rb;
  DIR *dir;
  int rc = -1;
  int dfd;
  if (!(dir = fdopendir(fd))) {
    errmsg(0, 0, 1, "failed to open directory");
    goto done;
  }
  dfd = dirfd(dir);
  if (fstat(dfd, &rb)) {
    errmsg(0, 0, 1, "failed to stat directory");
    goto done;
  }
  while (1) {
    struct dirent *d;
    errno = 0;
    if (!(d = readdir(dir))) {
      if (errno) {
        errmsg(0, 0, 1, "failed to read directory");
        goto done;
      }
      break;
    }
    if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
      continue;
    if (d->d_type == DT_DIR) {
      struct stat sb;
      if (fstatat(dfd, d->d_name, &sb, AT_SYMLINK_NOFOLLOW)) {
        errmsg(0, 0, 1, "failed to stat %s", d->d_name);
        continue;
      }
      if (sb.st_dev == rb.st_dev) {
        int cfd;
        cfd = openat(dfd, d->d_name, O_RDONLY);
        if (cfd >= 0) {
          recursiveRemove(cfd);
          close(cfd);
        }
      } else
        continue;
    }
    if (unlinkat(dfd, d->d_name, d->d_type == DT_DIR ? AT_REMOVEDIR : 0))
      errmsg(0, 0, 1, "failed to unlink %s", d->d_name);
  }
  rc = 0;
done:
  if (dir)
    closedir(dir);
  return rc;
}


x86 assembly (clang, -O0):
<recursiveRemove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
call   10c0 <fdopendir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1204 <recursiveRemove+0x44>
xor    %esi,%esi
mov    $0x1,%edx
lea    0xe0a(%rip),%rcx
mov    %esi,%edi
mov    $0x0,%al
call   10a0 <errmsg@plt>
jmp    1413 <recursiveRemove+0x253>
mov    -0x18(%rbp),%rdi
call   1080 <dirfd@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   10d0 <fstat@plt>
cmp    $0x0,%rax
je     1242 <recursiveRemove+0x82>
xor    %esi,%esi
mov    $0x1,%edx
lea    0xde5(%rip),%rcx
mov    %esi,%edi
mov    $0x0,%al
call   10a0 <errmsg@plt>
jmp    1413 <recursiveRemove+0x253>
jmp    1247 <recursiveRemove+0x87>
mov    0x2d7a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1090 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    129e <recursiveRemove+0xde>
mov    0x2d55(%rip),%rax
cmpq   $0x0,(%rax)
je     1299 <recursiveRemove+0xd9>
xor    %esi,%esi
mov    $0x1,%edx
lea    0xda7(%rip),%rcx
mov    %esi,%edi
mov    $0x0,%al
call   10a0 <errmsg@plt>
jmp    1413 <recursiveRemove+0x253>
jmp    140c <recursiveRemove+0x24c>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xda0(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     12d6 <recursiveRemove+0x116>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xd83(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12db <recursiveRemove+0x11b>
jmp    1247 <recursiveRemove+0x87>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2ce7(%rip),%rcx
cmp    (%rcx),%rax
jne    138e <recursiveRemove+0x1ce>
mov    -0x20(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%esi
mov    0x2cbd(%rip),%rax
mov    (%rax),%ecx
lea    -0x30(%rbp),%rdx
call   10e0 <fstatat@plt>
cmp    $0x0,%rax
je     133c <recursiveRemove+0x17c>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%r8d
xor    %esi,%esi
mov    $0x1,%edx
lea    0xd20(%rip),%rcx
mov    %esi,%edi
mov    $0x0,%al
call   10a0 <errmsg@plt>
jmp    1247 <recursiveRemove+0x87>
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1384 <recursiveRemove+0x1c4>
mov    -0x20(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%esi
mov    0x2c8d(%rip),%rax
mov    (%rax),%edx
call   1040 <openat@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     137f <recursiveRemove+0x1bf>
mov    -0x34(%rbp),%edi
call   10b0 <recursiveRemove@plt>
mov    -0x34(%rbp),%edi
call   1050 <close@plt>
jmp    1389 <recursiveRemove+0x1c9>
jmp    1247 <recursiveRemove+0x87>
jmp    138e <recursiveRemove+0x1ce>
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2c24(%rip),%rcx
cmp    (%rcx),%rax
jne    13c6 <recursiveRemove+0x206>
mov    0x2c1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    13d0 <recursiveRemove+0x210>
xor    %eax,%eax
mov    %eax,-0x40(%rbp)
jmp    13d0 <recursiveRemove+0x210>
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%edx
call   1030 <unlinkat@plt>
cmp    $0x0,%rax
je     1407 <recursiveRemove+0x247>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%r8d
xor    %esi,%esi
mov    $0x1,%edx
lea    0xc62(%rip),%rcx
mov    %esi,%edi
mov    $0x0,%al
call   10a0 <errmsg@plt>
jmp    1247 <recursiveRemove+0x87>
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1427 <recursiveRemove+0x267>
mov    -0x18(%rbp),%rdi
call   1060 <closedir@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursiveRemove>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
call   10c0 <fdopendir@plt>
test   %rax,%rax
je     1202 <recursiveRemove+0x42>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <dirfd@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rsi
mov    %eax,%edi
call   10d0 <fstat@plt>
test   %rax,%rax
je     1223 <recursiveRemove+0x63>
lea    0xe1c(%rip),%rcx
jmp    137c <recursiveRemove+0x1bc>
lea    0xdf7(%rip),%rcx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   10a0 <errmsg@plt>
mov    $0xffffffff,%ebp
jmp    1399 <recursiveRemove+0x1d9>
mov    0x2d9e(%rip),%r15
movq   $0x0,(%r15)
mov    %rbx,%rdi
call   1090 <readdir@plt>
test   %rax,%rax
je     136f <recursiveRemove+0x1af>
mov    %rax,%r13
mov    0x10(%rsp),%r12
lea    0xdfb(%rip),%r14
mov    %r12,(%rsp)
jmp    12af <recursiveRemove+0xef>
mov    0x8(%r13),%esi
mov    0x2d5e(%rip),%rax
mov    (%rax),%ecx
mov    %ebp,%edi
lea    0x8(%rsp),%rdx
call   10e0 <fstatat@plt>
test   %rax,%rax
je     1323 <recursiveRemove+0x163>
mov    0x8(%r13),%r8d
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
lea    0xdc1(%rip),%rcx
xor    %eax,%eax
call   10a0 <errmsg@plt>
movq   $0x0,(%r15)
mov    %rbx,%rdi
call   1090 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
je     136f <recursiveRemove+0x1af>
mov    0x8(%r13),%edi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1294 <recursiveRemove+0xd4>
mov    0x8(%r13),%edi
lea    0xd81(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1294 <recursiveRemove+0xd4>
mov    0x0(%r13),%rax
mov    0x2cf2(%rip),%rcx
mov    (%rcx),%rcx
cmp    %rcx,%rax
je     1257 <recursiveRemove+0x97>
mov    0x8(%r13),%esi
xor    %edx,%edx
cmp    %rcx,%rax
jne    12fe <recursiveRemove+0x13e>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1030 <unlinkat@plt>
test   %rax,%rax
je     1294 <recursiveRemove+0xd4>
mov    0x8(%r13),%r8d
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
lea    0xd42(%rip),%rcx
jmp    128d <recursiveRemove+0xcd>
cmp    %r12,0x8(%rsp)
jne    1294 <recursiveRemove+0xd4>
mov    0x8(%r13),%esi
mov    0x2caf(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1040 <openat@plt>
test   %eax,%eax
js     1358 <recursiveRemove+0x198>
mov    %eax,%r12d
mov    %eax,%edi
call   10b0 <recursiveRemove@plt>
mov    %r12d,%edi
call   1050 <close@plt>
mov    0x0(%r13),%rax
mov    0x2c6d(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rsp),%r12
jmp    12ea <recursiveRemove+0x12a>
cmpq   $0x0,(%r15)
je     13aa <recursiveRemove+0x1ea>
lea    0xcb6(%rip),%rcx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   10a0 <errmsg@plt>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1060 <closedir@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
jmp    1391 <recursiveRemove+0x1d1>

LLVM IR (-O0):
%struct.stat = type { i64 }
%struct.dirent = type { i64, i32 }
@.str = [25 x i8] c"failed to open directory\00"
@.str.1 = [25 x i8] c"failed to stat directory\00"
@errno = global i64 0
@.str.2 = [25 x i8] c"failed to read directory\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"..\00"
@DT_DIR = global i64 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@.str.5 = [18 x i8] c"failed to stat %s\00"
@O_RDONLY = global i32 0
@AT_REMOVEDIR = global i32 0
@.str.6 = [20 x i8] c"failed to unlink %s\00"
define i32 @recursiveRemove(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.stat
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.dirent*
%8 = alloca %struct.stat
%9 = alloca i32
store i32 %0, i32* %2
store i32 -1, i32* %5
%10 = load i32, i32* %2
%11 = call i32* @fdopendir(i32 %10)
store i32* %11, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %15, label %13
13: ; preds = %1
%14 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %113
15: ; preds = %1
%16 = load i32*, i32** %4
%17 = call i32 @dirfd(i32* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = call i64 @fstat(i32 %18, %struct.stat* %3)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %113
23: ; preds = %15
br label %24
24: ; preds = %23, %46, %61, %87, %111
store i64 0, i64* @errno
%25 = load i32*, i32** %4
%26 = call %struct.dirent* @readdir(i32* %25)
store %struct.dirent* %26, %struct.dirent** %7
%27 = icmp ne %struct.dirent* %26, null
br i1 %27, label %34, label %28
28: ; preds = %24
%29 = load i64, i64* @errno
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %113
33: ; preds = %28
br label %112
34: ; preds = %24
%35 = load %struct.dirent*, %struct.dirent** %7
%36 = getelementptr inbounds %struct.dirent, %struct.dirent* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = call i32 @strcmp(i32 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = load %struct.dirent*, %struct.dirent** %7
%42 = getelementptr inbounds %struct.dirent, %struct.dirent* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = call i32 @strcmp(i32 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %40, %34
br label %24
47: ; preds = %40
%48 = load %struct.dirent*, %struct.dirent** %7
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i32 0, i32 0
%50 = load i64, i64* %49
%51 = load i64, i64* @DT_DIR
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %89
53: ; preds = %47
%54 = load i32, i32* %6
%55 = load %struct.dirent*, %struct.dirent** %7
%56 = getelementptr inbounds %struct.dirent, %struct.dirent* %55, i32 0, i32 1
%57 = load i32, i32* %56
%58 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%59 = call i64 @fstatat(i32 %54, i32 %57, %struct.stat* %8, i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %53
%62 = load %struct.dirent*, %struct.dirent** %7
%63 = getelementptr inbounds %struct.dirent, %struct.dirent* %62, i32 0, i32 1
%64 = load i32, i32* %63
%65 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %64)
br label %24
66: ; preds = %53
%67 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%68 = load i64, i64* %67
%69 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%70 = load i64, i64* %69
%71 = icmp eq i64 %68, %70
br i1 %71, label %72, label %87
72: ; preds = %66
%73 = load i32, i32* %6
%74 = load %struct.dirent*, %struct.dirent** %7
%75 = getelementptr inbounds %struct.dirent, %struct.dirent* %74, i32 0, i32 1
%76 = load i32, i32* %75
%77 = load i32, i32* @O_RDONLY
%78 = call i32 @openat(i32 %73, i32 %76, i32 %77)
store i32 %78, i32* %9
%79 = load i32, i32* %9
%80 = icmp sge i32 %79, 0
br i1 %80, label %81, label %86
81: ; preds = %72
%82 = load i32, i32* %9
%83 = call i32 @recursiveRemove(i32 %82)
%84 = load i32, i32* %9
%85 = call i32 @close(i32 %84)
br label %86
86: ; preds = %81, %72
br label %88
87: ; preds = %66
br label %24
88: ; preds = %86
br label %89
89: ; preds = %88, %47
%90 = load i32, i32* %6
%91 = load %struct.dirent*, %struct.dirent** %7
%92 = getelementptr inbounds %struct.dirent, %struct.dirent* %91, i32 0, i32 1
%93 = load i32, i32* %92
%94 = load %struct.dirent*, %struct.dirent** %7
%95 = getelementptr inbounds %struct.dirent, %struct.dirent* %94, i32 0, i32 0
%96 = load i64, i64* %95
%97 = load i64, i64* @DT_DIR
%98 = icmp eq i64 %96, %97
br i1 %98, label %99, label %101
99: ; preds = %89
%100 = load i32, i32* @AT_REMOVEDIR
br label %102
101: ; preds = %89
br label %102
102: ; preds = %101, %99
%103 = phi i32 [ %100, %99 ], [ 0, %101 ]
%104 = call i64 @unlinkat(i32 %90, i32 %93, i32 %103)
%105 = icmp ne i64 %104, 0
br i1 %105, label %106, label %111
106: ; preds = %102
%107 = load %struct.dirent*, %struct.dirent** %7
%108 = getelementptr inbounds %struct.dirent, %struct.dirent* %107, i32 0, i32 1
%109 = load i32, i32* %108
%110 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %109)
br label %111
111: ; preds = %106, %102
br label %24
112: ; preds = %33
store i32 0, i32* %5
br label %113
113: ; preds = %112, %31, %21, %13
%114 = load i32*, i32** %4
%115 = icmp ne i32* %114, null
br i1 %115, label %116, label %119
116: ; preds = %113
%117 = load i32*, i32** %4
%118 = call i32 @closedir(i32* %117)
br label %119
119: ; preds = %116, %113
%120 = load i32, i32* %5
ret i32 %120
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.dirent = type { i64, i32 }
@.str = [25 x i8] c"failed to open directory\00"
@.str.1 = [25 x i8] c"failed to stat directory\00"
@errno = global i64 0
@.str.2 = [25 x i8] c"failed to read directory\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"..\00"
@DT_DIR = global i64 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@.str.5 = [18 x i8] c"failed to stat %s\00"
@O_RDONLY = global i32 0
@AT_REMOVEDIR = global i32 0
@.str.6 = [20 x i8] c"failed to unlink %s\00"
define i32 @recursiveRemove(i32 %0) {
%2 = alloca %struct.stat
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %2 to i8*
%5 = tail call i32* @fdopendir(i32 %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %84
9: ; preds = %1
%10 = tail call i32 @dirfd(i32* %5)
%11 = call i64 @fstat(i32 %10, %struct.stat* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %9
store i64 0, i64* @errno
%14 = call %struct.dirent* @readdir(i32* %5)
%15 = icmp eq %struct.dirent* %14, null
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = bitcast %struct.stat* %3 to i8*
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%20 = load i64, i64* %19
br label %28
21: ; preds = %9
%22 = tail call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %81
23: ; preds = %78, %13
%24 = load i64, i64* @errno
%25 = icmp eq i64 %24, 0
br i1 %25, label %81, label %26
26: ; preds = %23
%27 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %81
28: ; preds = %16, %78
%29 = phi %struct.dirent* [ %14, %16 ], [ %79, %78 ]
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i64 0, i32 1
%31 = load i32, i32* %30
%32 = call i32 @strcmp(i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %78, label %34
34: ; preds = %28
%35 = load i32, i32* %30
%36 = call i32 @strcmp(i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i32 %36, 0
br i1 %37, label %78, label %38
38: ; preds = %34
%39 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i64 0, i32 0
%40 = load i64, i64* %39
%41 = load i64, i64* @DT_DIR
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %66
43: ; preds = %38
%44 = load i32, i32* %30
%45 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%46 = call i64 @fstatat(i32 %10, i32 %44, %struct.stat* %3, i32 %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %43
%49 = load i32, i32* %30
%50 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %49)
br label %65
51: ; preds = %43
%52 = load i64, i64* %18
%53 = icmp eq i64 %52, %20
br i1 %53, label %54, label %65
54: ; preds = %51
%55 = load i32, i32* %30
%56 = load i32, i32* @O_RDONLY
%57 = call i32 @openat(i32 %10, i32 %55, i32 %56)
%58 = icmp sgt i32 %57, -1
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = call i32 @recursiveRemove(i32 %57)
%61 = call i32 @close(i32 %57)
br label %62
62: ; preds = %59, %54
%63 = load i64, i64* %39
%64 = load i64, i64* @DT_DIR
br label %66
65: ; preds = %51, %48
br label %78
66: ; preds = %62, %38
%67 = phi i64 [ %64, %62 ], [ %41, %38 ]
%68 = phi i64 [ %63, %62 ], [ %40, %38 ]
%69 = load i32, i32* %30
%70 = icmp eq i64 %68, %67
%71 = load i32, i32* @AT_REMOVEDIR
%72 = select i1 %70, i32 %71, i32 0
%73 = call i64 @unlinkat(i32 %10, i32 %69, i32 %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %78, label %75
75: ; preds = %66
%76 = load i32, i32* %30
%77 = call i32 (i32, i32, i32, i8*, ...) @errmsg(i32 0, i32 0, i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %65, %66, %75, %28, %34
store i64 0, i64* @errno
%79 = call %struct.dirent* @readdir(i32* %5)
%80 = icmp eq %struct.dirent* %79, null
br i1 %80, label %23, label %28
81: ; preds = %26, %23, %21
%82 = phi i32 [ -1, %21 ], [ -1, %26 ], [ 0, %23 ]
%83 = call i32 @closedir(i32* %5)
br label %84
84: ; preds = %7, %81
%85 = phi i32 [ %82, %81 ], [ -1, %7 ]
ret i32 %85
}