#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 */

/* Variables and functions */
int /*<<< orphan*/ listFolderAndDeleteFiles(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strncmp(char *, char *, int);
scalar_t__ strstr(char *, char *);
int /*<<< orphan*/ trimLastSlash(char *);
int main(int argc, char **argv) {
  char *help = "usage: ds_clean [-v] [directory...]";
  if (argc > 1 && argc <= 3) {
    if (strncmp(argv[1], "-h", 2) == 0) {
      printf("%s\n\n", help);
      printf(" h: Help. Print this message\n");
      printf(" v: Verbose\n");
    } else if (strncmp(argv[1], "-v", 2) == 0 && argv[2] != NULL &&
               strstr(argv[2], "/")) {
      listFolderAndDeleteFiles(trimLastSlash(argv[2]), true);
    } else if (strstr(argv[1], "/")) {
      listFolderAndDeleteFiles(trimLastSlash(argv[1]), false);
    } else {
      printf("%s\n", help);
    }
  } else {
    printf("%s\n", help);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12a3 <main+0x153>
cmpl   $0x3,-0x8(%rbp)
jg     12a3 <main+0x153>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe90(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11db <main+0x8b>
mov    -0x18(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    129e <main+0x14e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1249 <main+0xf9>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1249 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe3e(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1249 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <trimLastSlash@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <listFolderAndDeleteFiles@plt>
jmp    1299 <main+0x149>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe02(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1282 <main+0x132>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <trimLastSlash@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1040 <listFolderAndDeleteFiles@plt>
jmp    1294 <main+0x144>
mov    -0x18(%rbp),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1299 <main+0x149>
jmp    129e <main+0x14e>
jmp    12b5 <main+0x165>
mov    -0x18(%rbp),%rsi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
and    $0xfffffffe,%edi
cmp    $0x2,%edi
jne    11c9 <main+0x69>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xead(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11d2 <main+0x72>
mov    0x8(%rbx),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1203 <main+0xa3>
mov    0x8(%rbx),%rdi
lea    0xe84(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     11c9 <main+0x69>
mov    0x8(%rbx),%rdi
call   1070 <trimLastSlash@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1050 <listFolderAndDeleteFiles@plt>
jmp    11ff <main+0x9f>
lea    0xe30(%rip),%rdi
jmp    11fa <main+0x9a>
lea    0xe4e(%rip),%rdi
lea    0xe20(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe43(%rip),%rdi
call   1040 <puts@plt>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x10(%rbx),%rdi
test   %rdi,%rdi
je     11a0 <main+0x40>
lea    0xe1c(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     11a0 <main+0x40>
mov    0x10(%rbx),%rdi
call   1070 <trimLastSlash@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <listFolderAndDeleteFiles@plt>
jmp    11ff <main+0x9f>

LLVM IR (-O0):
@.str = [36 x i8] c"usage: ds_clean [-v] [directory...]\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [5 x i8] c"%s\0A\0A\00"
@.str.3 = [30 x i8] c" h: Help. Print this message\0A\00"
@.str.4 = [13 x i8] c" v: Verbose\0A\00"
@.str.5 = [3 x i8] c"-v\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %64
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 3
br i1 %11, label %12, label %64
12: ; preds = %9
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %63
23: ; preds = %12
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %46
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %46
34: ; preds = %29
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i64 @strstr(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @trimLastSlash(i8* %43)
%45 = call i32 @listFolderAndDeleteFiles(i32 %44, i32 1)
br label %62
46: ; preds = %34, %29, %23
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i64 @strstr(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %46
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 @trimLastSlash(i8* %55)
%57 = call i32 @listFolderAndDeleteFiles(i32 %56, i32 0)
br label %61
58: ; preds = %46
%59 = load i8*, i8** %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %58, %52
br label %62
62: ; preds = %61, %40
br label %63
63: ; preds = %62, %18
br label %67
64: ; preds = %9, %2
%65 = load i8*, i8** %6
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %63
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"usage: ds_clean [-v] [directory...]\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [5 x i8] c"%s\0A\0A\00"
@.str.5 = [3 x i8] c"-v\00"
@.str.6 = [2 x i8] c"/\00"
@str = [29 x i8] c" h: Help. Print this message\00"
@str.8 = [12 x i8] c" v: Verbose\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = and i32 %0, -2
%4 = icmp eq i32 %3, 2
br i1 %4, label %5, label %39
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
br label %41
14: ; preds = %5
%15 = load i8*, i8** %6
%16 = tail call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %29, label %22
22: ; preds = %18
%23 = tail call i64 @strstr(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = load i8*, i8** %19
%27 = tail call i32 @trimLastSlash(i8* %26)
%28 = tail call i32 @listFolderAndDeleteFiles(i32 %27, i32 1)
br label %41
29: ; preds = %22, %18, %14
%30 = load i8*, i8** %6
%31 = tail call i64 @strstr(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8*, i8** %6
%35 = tail call i32 @trimLastSlash(i8* %34)
%36 = tail call i32 @listFolderAndDeleteFiles(i32 %35, i32 0)
br label %41
37: ; preds = %29
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %41
39: ; preds = %2
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %41
41: ; preds = %10, %33, %37, %25, %39
ret i32 0
}