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

/* Variables and functions */
int /*<<< orphan*/ AT_REMOVEDIR;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int errno;
int /*<<< orphan*/ *fdopendir(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
scalar_t__ fstat(int, struct stat *);
int open(char const *, int /*<<< orphan*/);
int openat(int, char const *, int /*<<< orphan*/);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *terror(int);
scalar_t__ unlinkat(int, char const *, int /*<<< orphan*/);
int recursive_unlink_helper(int dirfd, const char *name) {
  int fd = -1, ret = 0;
  DIR *dfd = NULL;
  struct stat stat;
  struct dirent *de;
  if (dirfd >= 0) {
    fd = openat(dirfd, name, O_RDONLY);
  } else {
    fd = open(name, O_RDONLY);
  }
  if (fd < 0) {
    ret = errno;
    fprintf(stderr, "error opening %s: %s\n", name, terror(ret));
    goto done;
  }
  if (fstat(fd, &stat) < 0) {
    ret = errno;
    fprintf(stderr, "failed to stat %s: %s\n", name, terror(ret));
    goto done;
  }
  if (!(S_ISDIR(stat.st_mode))) {
    if (unlinkat(dirfd, name, 0)) {
      ret = errno;
      fprintf(stderr, "failed to unlink %s: %s\n", name, terror(ret));
      goto done;
    }
  } else {
    dfd = fdopendir(fd);
    if (!dfd) {
      ret = errno;
      fprintf(stderr, "fopendir(%s) failed: %s\n", name, terror(ret));
      goto done;
    }
    while ((de = readdir(dfd))) {
      if (!strcmp(de->d_name, "."))
        continue;
      if (!strcmp(de->d_name, ".."))
        continue;
      ret = recursive_unlink_helper(fd, de->d_name);
      if (ret)
        goto done;
    }
    if (unlinkat(dirfd, name, AT_REMOVEDIR) < 0) {
      ret = errno;
      goto done;
    }
  }
done:
  if (fd >= 0) {
    close(fd);
  }
  if (dfd) {
    closedir(dfd);
  }
  return -ret;
}


x86 assembly (clang, -O0):
<recursive_unlink_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     121c <recursive_unlink_helper+0x4c>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
call   1040 <openat@plt>
mov    %eax,-0x14(%rbp)
jmp    1231 <recursive_unlink_helper+0x61>
mov    -0x10(%rbp),%rdi
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    127e <recursive_unlink_helper+0xae>
mov    0x2d86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
call   10b0 <terror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xd8c(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1460 <recursive_unlink_helper+0x290>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10f0 <fstat@plt>
cmp    $0x0,%rax
jge    12d7 <recursive_unlink_helper+0x107>
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%edi
call   10b0 <terror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xd49(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1460 <recursive_unlink_helper+0x290>
mov    -0x28(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    1348 <recursive_unlink_helper+0x178>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <unlinkat@plt>
cmp    $0x0,%rax
je     1343 <recursive_unlink_helper+0x173>
mov    0x2cc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2cc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%edi
call   10b0 <terror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xcf4(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1460 <recursive_unlink_helper+0x290>
jmp    145b <recursive_unlink_helper+0x28b>
mov    -0x14(%rbp),%edi
call   10d0 <fdopendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    13a2 <recursive_unlink_helper+0x1d2>
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2c66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%edi
call   10b0 <terror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xcae(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1460 <recursive_unlink_helper+0x290>
jmp    13a7 <recursive_unlink_helper+0x1d7>
mov    -0x20(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1426 <recursive_unlink_helper+0x256>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xc94(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    13df <recursive_unlink_helper+0x20f>
jmp    13a7 <recursive_unlink_helper+0x1d7>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xc72(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1400 <recursive_unlink_helper+0x230>
jmp    13a7 <recursive_unlink_helper+0x1d7>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
call   10e0 <recursive_unlink_helper@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1421 <recursive_unlink_helper+0x251>
jmp    1460 <recursive_unlink_helper+0x290>
jmp    13a7 <recursive_unlink_helper+0x1d7>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2b9c(%rip),%rax
mov    (%rax),%edx
call   1030 <unlinkat@plt>
cmp    $0x0,%rax
jge    1456 <recursive_unlink_helper+0x286>
mov    0x2b7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    1460 <recursive_unlink_helper+0x290>
jmp    145b <recursive_unlink_helper+0x28b>
jmp    1460 <recursive_unlink_helper+0x290>
cmpl   $0x0,-0x14(%rbp)
jl     1472 <recursive_unlink_helper+0x2a2>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
cmpq   $0x0,-0x20(%rbp)
je     1486 <recursive_unlink_helper+0x2b6>
mov    -0x20(%rbp),%rdi
call   1070 <closedir@plt>
xor    %eax,%eax
sub    -0x18(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursive_unlink_helper>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
test   %edi,%edi
js     11fb <recursive_unlink_helper+0x2b>
mov    %r15d,%edi
mov    %r14,%rsi
call   1040 <openat@plt>
jmp    1205 <recursive_unlink_helper+0x35>
mov    %r14,%rdi
mov    %edx,%esi
call   10c0 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
js     12b9 <recursive_unlink_helper+0xe9>
mov    %rsp,%rsi
mov    %r12d,%edi
call   10f0 <fstat@plt>
test   %rax,%rax
js     12eb <recursive_unlink_helper+0x11b>
mov    (%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %eax,%eax
je     12f4 <recursive_unlink_helper+0x124>
mov    %r12d,%edi
call   10d0 <fdopendir@plt>
test   %rax,%rax
je     133c <recursive_unlink_helper+0x16c>
mov    %rax,%rbp
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     1311 <recursive_unlink_helper+0x141>
lea    0xe00(%rip),%r13
jmp    1281 <recursive_unlink_helper+0xb1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     1311 <recursive_unlink_helper+0x141>
mov    (%rax),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1270 <recursive_unlink_helper+0xa0>
mov    %rbx,%rdi
lea    0xdc2(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1270 <recursive_unlink_helper+0xa0>
mov    %r12d,%edi
mov    %rbx,%rsi
call   10e0 <recursive_unlink_helper@plt>
test   %eax,%eax
je     1270 <recursive_unlink_helper+0xa0>
mov    %eax,%ebx
jmp    1335 <recursive_unlink_helper+0x165>
mov    0x2d08(%rip),%rax
mov    (%rax),%ebx
mov    0x2d0f(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   10b0 <terror@plt>
lea    0xd27(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1090 <fprintf@plt>
jmp    1383 <recursive_unlink_helper+0x1b3>
lea    0xd24(%rip),%r15
jmp    1343 <recursive_unlink_helper+0x173>
xor    %ebx,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <unlinkat@plt>
test   %rax,%rax
je     136c <recursive_unlink_helper+0x19c>
lea    0xd1e(%rip),%r15
jmp    1343 <recursive_unlink_helper+0x173>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <unlinkat@plt>
mov    %rax,%rbx
mov    0x2c99(%rip),%rax
sar    $0x3f,%rbx
and    (%rax),%ebx
test   %r12d,%r12d
jns    136e <recursive_unlink_helper+0x19e>
jmp    1376 <recursive_unlink_helper+0x1a6>
lea    0xd03(%rip),%r15
mov    0x2c7e(%rip),%rax
mov    (%rax),%ebx
mov    0x2c85(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   10b0 <terror@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1090 <fprintf@plt>
xor    %ebp,%ebp
mov    %r12d,%edi
call   1060 <close@plt>
test   %rbp,%rbp
je     1383 <recursive_unlink_helper+0x1b3>
mov    %rbp,%rdi
call   1070 <closedir@plt>
neg    %ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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