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

/* Variables and functions */
scalar_t__ canread(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ isdir(char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int system(char *);
void run(char *command) {
  FILE *fp;
  char cmd[2000];
  char filename[2000];
  char line[2000];
  char curdir[2000];
  char short_filename[2000];
  char slash[2];
  int result;
  strcpy(slash, "/");
  getcwd(curdir, 2000);
  strcat(curdir, slash);
  fp = popen(command, "r");
  while (fgets(line, sizeof line, fp)) {
    if ((line[0] == '?') || (line[0] == 'M') || (line[0] == 'I')) {
      line[strlen(line) - 1] = '\0';
      strcpy(filename, curdir);
      strcpy(short_filename, line + 8);
      strcat(filename, short_filename);
      if (canread(filename) && !isdir(filename)) {
        printf("Deleting %s\n", short_filename);
        sprintf(cmd, "rm %s", filename);
        result = system(cmd);
      } else {
        printf("Deleting %s%s\n", short_filename, slash);
        sprintf(cmd, "rm -rf %s", filename);
        result = system(cmd);
        if (result != true) {
          printf("Deleting %s failed.\n", filename);
        }
      }
    }
  }
  pclose(fp);
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x2722(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x1f50(%rbp),%rdi
mov    $0x7d0,%esi
call   1090 <getcwd@plt>
lea    -0x1f50(%rbp),%rdi
lea    -0x2722(%rbp),%rsi
call   10d0 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   10c0 <popen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1780(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x7d0,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     13a9 <run+0x1e9>
movsbl -0x1780(%rbp),%eax
cmp    $0x3f,%eax
je     1269 <run+0xa9>
movsbl -0x1780(%rbp),%eax
cmp    $0x4d,%eax
je     1269 <run+0xa9>
movsbl -0x1780(%rbp),%eax
cmp    $0x49,%eax
jne    13a4 <run+0x1e4>
lea    -0x1780(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x1780(%rbp,%rax,1)
lea    -0xfb0(%rbp),%rdi
lea    -0x1f50(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x2720(%rbp),%rdi
lea    -0x1780(%rbp),%rsi
add    $0x8,%rsi
call   1030 <strcpy@plt>
lea    -0xfb0(%rbp),%rdi
lea    -0x2720(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0xfb0(%rbp),%rdi
call   1080 <canread@plt>
cmp    $0x0,%rax
je     1330 <run+0x170>
lea    -0xfb0(%rbp),%rdi
call   10b0 <isdir@plt>
cmp    $0x0,%eax
jne    1330 <run+0x170>
lea    -0x2720(%rbp),%rsi
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x7e0(%rbp),%rdi
lea    -0xfb0(%rbp),%rdx
lea    0xcfd(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x7e0(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x2728(%rbp)
jmp    139f <run+0x1df>
lea    -0x2720(%rbp),%rsi
lea    -0x2722(%rbp),%rdx
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x7e0(%rbp),%rdi
lea    -0xfb0(%rbp),%rdx
lea    0xcc5(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x7e0(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x2728(%rbp)
cmpl   $0x1,-0x2728(%rbp)
je     139a <run+0x1da>
lea    -0xfb0(%rbp),%rsi
lea    0xc9d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    139f <run+0x1df>
jmp    13a4 <run+0x1e4>
jmp    121a <run+0x5a>
mov    -0x10(%rbp),%rdi
call   1070 <pclose@plt>
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2728,%rsp
mov    %rdi,%rbx
lea    0xe25(%rip),%rsi
lea    0xe(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0x7e0(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x7d0,%esi
call   1090 <getcwd@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
lea    0xdf3(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <popen@plt>
mov    %rax,%r14
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x7d0,%esi
mov    %rax,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1361 <run+0x1a1>
mov    $0x4401,%r13d
lea    0x1780(%rsp),%rbx
lea    0xfb0(%rsp),%rbp
lea    0x1f50(%rsp),%r15
jmp    12a9 <run+0xe9>
lea    0xda5(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
lea    0xd9e(%rip),%rsi
mov    %rbx,%rdx
call   10e0 <sprintf@plt>
mov    %r15,%rdi
call   1050 <system@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    $0x7d0,%esi
mov    %r14,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1361 <run+0x1a1>
movzbl 0x10(%rsp),%eax
add    $0xc1,%al
cmp    $0xe,%al
ja     1290 <run+0xd0>
movzbl %al,%eax
bt     %rax,%r13
jae    1290 <run+0xd0>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r12,1)
mov    %rbx,%rdi
lea    0x7e0(%rsp),%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
lea    0x18(%rsp),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
call   1080 <canread@plt>
test   %rax,%rax
je     1312 <run+0x152>
mov    %rbx,%rdi
call   10b0 <isdir@plt>
test   %eax,%eax
je     1258 <run+0x98>
lea    0xcfe(%rip),%rdi
mov    %rbp,%rsi
lea    0xe(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
lea    0xcf4(%rip),%rsi
mov    %rbx,%rdx
call   10e0 <sprintf@plt>
mov    %r15,%rdi
call   1050 <system@plt>
cmp    $0x1,%eax
je     1290 <run+0xd0>
lea    0xcde(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1290 <run+0xd0>
mov    %r14,%rdi
call   1070 <pclose@plt>
add    $0x2728,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"Deleting %s\0A\00"
@.str.3 = [6 x i8] c"rm %s\00"
@.str.4 = [15 x i8] c"Deleting %s%s\0A\00"
@.str.5 = [10 x i8] c"rm -rf %s\00"
@.str.6 = [21 x i8] c"Deleting %s failed.\0A\00"
define void @run(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [2000 x i8]
%5 = alloca [2000 x i8]
%6 = alloca [2000 x i8]
%7 = alloca [2000 x i8]
%8 = alloca [2000 x i8]
%9 = alloca [2 x i8]
%10 = alloca i32
store i8* %0, i8** %2
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%14 = call i32 @getcwd(i8* %13, i32 2000)
%15 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%17 = call i32 @strcat(i8* %15, i8* %16)
%18 = load i8*, i8** %2
%19 = call i32* @popen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %3
br label %20
20: ; preds = %87, %1
%21 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%22 = load i32*, i32** %3
%23 = call i64 @fgets(i8* %21, i32 2000, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %88
25: ; preds = %20
%26 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 63
br i1 %29, label %40, label %30
30: ; preds = %25
%31 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 77
br i1 %34, label %40, label %35
35: ; preds = %30
%36 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 73
br i1 %39, label %40, label %87
40: ; preds = %35, %30, %25
%41 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 %44
store i8 0, i8* %45
%46 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%47 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%48 = call i32 @strcpy(i8* %46, i8* %47)
%49 = getelementptr inbounds [2000 x i8], [2000 x i8]* %8, i64 0, i64 0
%50 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds i8, i8* %50, i64 8
%52 = call i32 @strcpy(i8* %49, i8* %51)
%53 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%54 = getelementptr inbounds [2000 x i8], [2000 x i8]* %8, i64 0, i64 0
%55 = call i32 @strcat(i8* %53, i8* %54)
%56 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%57 = call i64 @canread(i8* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %71
59: ; preds = %40
%60 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%61 = call i32 @isdir(i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %71, label %63
63: ; preds = %59
%64 = getelementptr inbounds [2000 x i8], [2000 x i8]* %8, i64 0, i64 0
%65 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %64)
%66 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%67 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%68 = call i32 @sprintf(i8* %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %67)
%69 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%70 = call i32 @system(i8* %69)
store i32 %70, i32* %10
br label %86
71: ; preds = %59, %40
%72 = getelementptr inbounds [2000 x i8], [2000 x i8]* %8, i64 0, i64 0
%73 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%74 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %72, i8* %73)
%75 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%76 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%77 = call i32 @sprintf(i8* %75, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %76)
%78 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%79 = call i32 @system(i8* %78)
store i32 %79, i32* %10
%80 = load i32, i32* %10
%81 = icmp ne i32 %80, 1
br i1 %81, label %82, label %85
82: ; preds = %71
%83 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%84 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %83)
br label %85
85: ; preds = %82, %71
br label %86
86: ; preds = %85, %63
br label %87
87: ; preds = %86, %35
br label %20
88: ; preds = %20
%89 = load i32*, i32** %3
%90 = call i32 @pclose(i32* %89)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"Deleting %s\0A\00"
@.str.3 = [6 x i8] c"rm %s\00"
@.str.4 = [15 x i8] c"Deleting %s%s\0A\00"
@.str.5 = [10 x i8] c"rm -rf %s\00"
@.str.6 = [21 x i8] c"Deleting %s failed.\0A\00"
define void @run(i8* nocapture %0) {
%2 = alloca [2000 x i8]
%3 = alloca [2000 x i8]
%4 = alloca [2000 x i8]
%5 = alloca [2000 x i8]
%6 = alloca [2000 x i8]
%7 = alloca [2 x i8]
%8 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @getcwd(i8* %11, i32 2000)
%16 = call i32 @strcat(i8* %11, i8* %13)
%17 = call i32* @popen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = call i64 @fgets(i8* %10, i32 2000, i32* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %51, label %20
20: ; preds = %1
%21 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 8
br label %22
22: ; preds = %20, %48
%23 = load i8, i8* %10
switch i8 %23, label %48 [
i8 77, label %24
i8 73, label %24
i8 63, label %24
]
24: ; preds = %22, %22, %22
%25 = call i32 @strlen(i8* %10)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i32 @strcpy(i8* %9, i8* %11)
%30 = call i32 @strcpy(i8* %12, i8* %21)
%31 = call i32 @strcat(i8* %9, i8* %12)
%32 = call i64 @canread(i8* %9)
%33 = icmp eq i64 %32, 0
br i1 %33, label %41, label %34
34: ; preds = %24
%35 = call i32 @isdir(i8* %9)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%39 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%40 = call i32 @system(i8* %8)
br label %48
41: ; preds = %34, %24
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %12, i8* %13)
%43 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%44 = call i32 @system(i8* %8)
%45 = icmp eq i32 %44, 1
br i1 %45, label %48, label %46
46: ; preds = %41
%47 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %9)
br label %48
48: ; preds = %22, %37, %46, %41
%49 = call i64 @fgets(i8* %10, i32 2000, i32* %17)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %22
51: ; preds = %48, %1
%52 = call i32 @pclose(i32* %17)
ret void
}