#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*/ dirs;
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
int PATH_MAX;
int WEXITSTATUS(int);
int /*<<< orphan*/ stest_add_error(char *, char const *, ...);
int system(char *);
scalar_t__ zsnprintf(char *, int, char *, char const *, char const *);
void fuse1_test_cleanup(const char *fdir) {
  int ret;
  size_t i;
  const char *dir;
  const char *dirs[] = {"dir1", "dir2"};
  char cmd[PATH_MAX];
  for (i = 0; i < sizeof(dirs) / sizeof(dirs[0]); ++i) {
    dir = dirs[i];
    if (zsnprintf(cmd, sizeof(cmd), "rm -rf '%s/%s'\n", fdir, dir)) {
      stest_add_error("failed to remove %s: -ENAMETOOLONG\n", dir);
      return;
    }
    ret = system(cmd);
    if (ret < 0) {
      stest_add_error("failed to remove %s: system(3) "
                      "failed.\n",
                      dir);
      return;
    }
    ret = WEXITSTATUS(ret);
    if (ret != 0) {
      stest_add_error("failed to remove %s: system(3) "
                      "returned exit status %d\n",
                      dir, ret);
      return;
    }
  }
}


x86 assembly (clang, -O0):
<fuse1_test_cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movaps 0x2cad(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x58(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
jae    126d <fuse1_test_cleanup+0x12d>
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp,%rcx,8),%rcx
mov    %rcx,-0x20(%rbp)
mov    %eax,%esi
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe4a(%rip),%rdx
call   1050 <zsnprintf@plt>
cmp    $0x0,%rax
je     11ed <fuse1_test_cleanup+0xad>
mov    -0x20(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <stest_add_error@plt>
movl   $0x1,-0x44(%rbp)
jmp    1274 <fuse1_test_cleanup+0x134>
mov    -0x50(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1221 <fuse1_test_cleanup+0xe1>
mov    -0x20(%rbp),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <stest_add_error@plt>
movl   $0x1,-0x44(%rbp)
jmp    1274 <fuse1_test_cleanup+0x134>
mov    -0xc(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1257 <fuse1_test_cleanup+0x117>
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <stest_add_error@plt>
movl   $0x1,-0x44(%rbp)
jmp    1274 <fuse1_test_cleanup+0x134>
jmp    125c <fuse1_test_cleanup+0x11c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    118f <fuse1_test_cleanup+0x4f>
movl   $0x0,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fuse1_test_cleanup>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2e9b(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
mov    %r15,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe97(%rip),%rdx
lea    0xe86(%rip),%r12
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rcx
mov    %r12,%r8
call   1050 <zsnprintf@plt>
test   %rax,%rax
je     11ae <fuse1_test_cleanup+0x6e>
lea    0xe83(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <stest_add_error@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
js     11de <fuse1_test_cleanup+0x9e>
mov    %eax,%edi
call   1060 <WEXITSTATUS@plt>
test   %eax,%eax
je     11ee <fuse1_test_cleanup+0xae>
lea    0xe34(%rip),%rsi
lea    0xe93(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <stest_add_error@plt>
jmp    11a1 <fuse1_test_cleanup+0x61>
lea    0xe1b(%rip),%rsi
lea    0xe52(%rip),%rdi
jmp    119a <fuse1_test_cleanup+0x5a>
lea    0xe15(%rip),%rdx
lea    0xe09(%rip),%r12
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rcx
mov    %r12,%r8
call   1050 <zsnprintf@plt>
test   %rax,%rax
jne    1190 <fuse1_test_cleanup+0x50>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
js     123a <fuse1_test_cleanup+0xfa>
mov    %eax,%edi
call   1060 <WEXITSTATUS@plt>
test   %eax,%eax
je     11a1 <fuse1_test_cleanup+0x61>
lea    0xdcd(%rip),%rsi
jmp    11cc <fuse1_test_cleanup+0x8c>
lea    0xdc4(%rip),%rsi
jmp    11e5 <fuse1_test_cleanup+0xa5>

LLVM IR (-O0):
@.str = [5 x i8] c"dir1\00"
@.str.1 = [5 x i8] c"dir2\00"
@__const.fuse1_test_cleanup.dirs = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0)]
@PATH_MAX = global i32 0
@.str.2 = [16 x i8] c"rm -rf '%s/%s'\0A\00"
@.str.3 = [36 x i8] c"failed to remove %s: -ENAMETOOLONG\0A\00"
@.str.4 = [40 x i8] c"failed to remove %s: system(3) failed.\0A\00"
@.str.5 = [56 x i8] c"failed to remove %s: system(3) returned exit status %d\0A\00"
define void @fuse1_test_cleanup(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca [2 x i8*]
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %2
%10 = bitcast [2 x i8*]* %6 to i8*
%11 = load i32, i32* @PATH_MAX
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i8, i64 %12
store i64 %12, i64* %8
store i64 0, i64* %4
br label %15
15: ; preds = %47, %1
%16 = load i64, i64* %4
%17 = icmp ult i64 %16, 2
br i1 %17, label %18, label %50
18: ; preds = %15
%19 = load i64, i64* %4
%20 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 %19
%21 = load i8*, i8** %20
store i8* %21, i8** %5
%22 = trunc i64 %12 to i32
%23 = load i8*, i8** %2
%24 = load i8*, i8** %5
%25 = call i64 @zsnprintf(i8* %14, i32 %22, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %18
%28 = load i8*, i8** %5
%29 = call i32 (i8*, i8*, ...) @stest_add_error(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %28)
store i32 1, i32* %9
br label %51
30: ; preds = %18
%31 = call i32 @system(i8* %14)
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i8*, i8** %5
%36 = call i32 (i8*, i8*, ...) @stest_add_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %35)
store i32 1, i32* %9
br label %51
37: ; preds = %30
%38 = load i32, i32* %3
%39 = call i32 @WEXITSTATUS(i32 %38)
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i8*, i8** %5
%44 = load i32, i32* %3
%45 = call i32 (i8*, i8*, ...) @stest_add_error(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %43, i32 %44)
store i32 1, i32* %9
br label %51
46: ; preds = %37
br label %47
47: ; preds = %46
%48 = load i64, i64* %4
%49 = add i64 %48, 1
store i64 %49, i64* %4
br label %15
50: ; preds = %15
store i32 0, i32* %9
br label %51
51: ; preds = %50, %42, %34, %27
%52 = load i8*, i8** %7
%53 = load i32, i32* %9
switch i32 %53, label %55 [
i32 0, label %54
i32 1, label %54
]
54: ; preds = %51, %51
ret void
55: ; preds = %51
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"dir1\00"
@.str.1 = [5 x i8] c"dir2\00"
@PATH_MAX = global i32 0
@.str.2 = [16 x i8] c"rm -rf '%s/%s'\0A\00"
@.str.3 = [36 x i8] c"failed to remove %s: -ENAMETOOLONG\0A\00"
@.str.4 = [40 x i8] c"failed to remove %s: system(3) failed.\0A\00"
@.str.5 = [56 x i8] c"failed to remove %s: system(3) returned exit status %d\0A\00"
define void @fuse1_test_cleanup(i8* %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i64 @zsnprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %19, label %16
7: ; preds = %25
%8 = call i64 @zsnprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = call i32 @system(i8* %4)
%12 = icmp slt i32 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = call i32 @WEXITSTATUS(i32 %11)
%15 = icmp eq i32 %14, 0
br i1 %15, label %32, label %28
16: ; preds = %7, %1
%17 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %7 ]
%18 = call i32 (i8*, i8*, ...) @stest_add_error(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %32
19: ; preds = %1
%20 = call i32 @system(i8* %4)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %10, %19
%23 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %19 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %10 ]
%24 = call i32 (i8*, i8*, ...) @stest_add_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %23)
br label %32
25: ; preds = %19
%26 = call i32 @WEXITSTATUS(i32 %20)
%27 = icmp eq i32 %26, 0
br i1 %27, label %7, label %28
28: ; preds = %13, %25
%29 = phi i32 [ %26, %25 ], [ %14, %13 ]
%30 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %25 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %13 ]
%31 = call i32 (i8*, i8*, ...) @stest_add_error(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %30, i32 %29)
br label %32
32: ; preds = %13, %28, %22, %16
ret void
}