#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int PATH_MAX;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ rmdir(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strrchr(char *, char);
char *strstr(char *, char *);
int unlink(char *);
void delete (const char *fn) {
  FILE *fpi;
  char buf[PATH_MAX];
  char dir[PATH_MAX];
  char *dow[] = {" Sun ", " Mon ", " Tue ", " Wed ", " Thu ", " Fri ", " Sat "};
  char *cp;
  int badformat, i;
  if (!(fpi = fopen(fn, "r"))) {
    perror(fn);
    exit(EXIT_FAILURE);
  }
  dir[0] = 0;
  while (fgets(buf, PATH_MAX, fpi)) {
    badformat = 1;
    for (i = 0; i < 7; i++) {
      cp = strstr(buf, dow[i]);
      if (cp) {
        badformat = 0;
        break;
      }
    }
    if (badformat) {
      fprintf(stderr, "Mal formed data line: %s\n", buf);
      exit(EXIT_FAILURE);
    }
    *cp = 0;
    cp = strrchr(buf, '/');
    *cp = 0;
    if (strcmp(dir, buf) != 0) {
      if (strlen(dir))
        rmdir(dir);
      strcpy(dir, buf);
    }
    *cp = '/';
    if (unlink(buf) == -1) {
      perror(buf);
    }
  }
}


x86 assembly (clang, -O0):
<delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e0a(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x80(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2b9c(%rip),%rsi
mov    $0x38,%edx
call   10b0 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1273 <delete+0xa3>
mov    -0x8(%rbp),%rdi
call   10d0 <perror@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x78(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x80(%rbp),%rdi
mov    0x2d6b(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13aa <delete+0x1da>
movl   $0x1,-0x6c(%rbp)
movl   $0x0,-0x70(%rbp)
cmpl   $0x7,-0x70(%rbp)
jge    12f2 <delete+0x122>
mov    -0x80(%rbp),%rdi
movslq -0x70(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rsi
call   10f0 <strstr@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     12df <delete+0x10f>
movl   $0x0,-0x6c(%rbp)
jmp    12f2 <delete+0x122>
jmp    12e4 <delete+0x114>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    12a8 <delete+0xd8>
cmpl   $0x0,-0x6c(%rbp)
je     1323 <delete+0x153>
mov    -0x80(%rbp),%rdx
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
lea    0xd1c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x80(%rbp),%rdi
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1383 <delete+0x1b3>
mov    -0x78(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
je     1376 <delete+0x1a6>
mov    -0x78(%rbp),%rdi
call   1050 <rmdir@plt>
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rdi
call   1040 <strcpy@plt>
mov    -0x80(%rbp),%rdi
mov    -0x68(%rbp),%rax
movb   $0x2f,(%rax)
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
jne    13a5 <delete+0x1d5>
mov    -0x80(%rbp),%rdi
call   10d0 <perror@plt>
jmp    127a <delete+0xaa>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
mov    0x2e28(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
lea    0xe3d(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     133d <delete+0x18d>
mov    %rax,%rbx
movb   $0x0,(%r14)
mov    0x0(%r13),%esi
jmp    1238 <delete+0x88>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
movb   $0x2f,0x0(%r13)
mov    %r15,%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     1321 <delete+0x171>
mov    %r12,%r13
mov    (%r12),%esi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     132e <delete+0x17e>
mov    %r13,%r12
mov    %r15,%rdi
lea    0xda7(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    12e0 <delete+0x130>
mov    %r15,%rdi
lea    0xd95(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    12e0 <delete+0x130>
mov    %r15,%rdi
lea    0xd87(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    12e0 <delete+0x130>
mov    %r15,%rdi
lea    0xd79(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    12e0 <delete+0x130>
mov    %r15,%rdi
lea    0xd6b(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    12e0 <delete+0x130>
mov    %r15,%rdi
lea    0xd5d(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    12e0 <delete+0x130>
mov    %r15,%rdi
lea    0xd4f(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     1353 <delete+0x1a3>
nop
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,%r13
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     121b <delete+0x6b>
cmpb   $0x0,(%r14)
je     1210 <delete+0x60>
mov    %r14,%rdi
call   1050 <rmdir@plt>
jmp    1210 <delete+0x60>
mov    %r15,%rdi
call   10b0 <perror@plt>
jmp    1231 <delete+0x81>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
call   10b0 <perror@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edi
lea    0xcc9(%rip),%rsi
mov    %r15,%rdx
call   1090 <fprintf@plt>
jmp    1345 <delete+0x195>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [6 x i8] c" Sun \00"
@.str.1 = [6 x i8] c" Mon \00"
@.str.2 = [6 x i8] c" Tue \00"
@.str.3 = [6 x i8] c" Wed \00"
@.str.4 = [6 x i8] c" Thu \00"
@.str.5 = [6 x i8] c" Fri \00"
@.str.6 = [6 x i8] c" Sat \00"
@__const.delete.dow = [7 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.8 = [26 x i8] c"Mal formed data line: %s\0A\00"
define void @delete(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [7 x i8*]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %2
%11 = load i32, i32* @PATH_MAX
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %4
%14 = alloca i8, i64 %12
store i64 %12, i64* %5
%15 = load i32, i32* @PATH_MAX
%16 = zext i32 %15 to i64
%17 = alloca i8, i64 %16
store i64 %16, i64* %6
%18 = bitcast [7 x i8*]* %7 to i8*
%19 = load i8*, i8** %2
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %20, i32** %3
%21 = icmp ne i32* %20, null
br i1 %21, label %27, label %22
22: ; preds = %1
%23 = load i8*, i8** %2
%24 = call i32 @perror(i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %1
%28 = getelementptr inbounds i8, i8* %17, i64 0
store i8 0, i8* %28
br label %29
29: ; preds = %78, %27
%30 = load i32, i32* @PATH_MAX
%31 = load i32*, i32** %3
%32 = call i64 @fgets(i8* %14, i32 %30, i32* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %79
34: ; preds = %29
store i32 1, i32* %9
store i32 0, i32* %10
br label %35
35: ; preds = %48, %34
%36 = load i32, i32* %10
%37 = icmp slt i32 %36, 7
br i1 %37, label %38, label %51
38: ; preds = %35
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = call i8* @strstr(i8* %14, i8* %42)
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %47
46: ; preds = %38
store i32 0, i32* %9
br label %51
47: ; preds = %38
br label %48
48: ; preds = %47
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %35
51: ; preds = %46, %35
%52 = load i32, i32* %9
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %14)
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %51
%60 = load i8*, i8** %8
store i8 0, i8* %60
%61 = call i8* @strrchr(i8* %14, i8 signext 47)
store i8* %61, i8** %8
%62 = load i8*, i8** %8
store i8 0, i8* %62
%63 = call i64 @strcmp(i8* %17, i8* %14)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %72
65: ; preds = %59
%66 = call i64 @strlen(i8* %17)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 @rmdir(i8* %17)
br label %70
70: ; preds = %68, %65
%71 = call i32 @strcpy(i8* %17, i8* %14)
br label %72
72: ; preds = %70, %59
%73 = load i8*, i8** %8
store i8 47, i8* %73
%74 = call i32 @unlink(i8* %14)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = call i32 @perror(i8* %14)
br label %78
78: ; preds = %76, %72
br label %29
79: ; preds = %29
%80 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [6 x i8] c" Sun \00"
@.str.1 = [6 x i8] c" Mon \00"
@.str.2 = [6 x i8] c" Tue \00"
@.str.3 = [6 x i8] c" Wed \00"
@.str.4 = [6 x i8] c" Thu \00"
@.str.5 = [6 x i8] c" Fri \00"
@.str.6 = [6 x i8] c" Sat \00"
@.str.7 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.8 = [26 x i8] c"Mal formed data line: %s\0A\00"
define void @delete(i8* nocapture %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = alloca i8, i64 %3
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = tail call i32 @perror(i8* %0)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
store i8 0, i8* %5
%13 = load i32, i32* @PATH_MAX
%14 = call i64 @fgets(i8* %4, i32 %13, i32* %6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %63, label %16
16: ; preds = %12, %59
%17 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %42
19: ; preds = %16
%20 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %42
22: ; preds = %19
%23 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %42
25: ; preds = %22
%26 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %42
28: ; preds = %25
%29 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %42
31: ; preds = %28
%32 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %4)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %34, %31, %28, %25, %22, %19, %16
%43 = phi i8* [ %17, %16 ], [ %20, %19 ], [ %23, %22 ], [ %26, %25 ], [ %29, %28 ], [ %32, %31 ], [ %35, %34 ]
store i8 0, i8* %43
%44 = call i8* @strrchr(i8* %4, i8 signext 47)
store i8 0, i8* %44
%45 = call i64 @strcmp(i8* %5, i8* %4)
%46 = icmp eq i64 %45, 0
br i1 %46, label %54, label %47
47: ; preds = %42
%48 = load i8, i8* %5
%49 = icmp eq i8 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 @rmdir(i8* %5)
br label %52
52: ; preds = %50, %47
%53 = call i32 @strcpy(i8* %5, i8* %4)
br label %54
54: ; preds = %52, %42
store i8 47, i8* %44
%55 = call i32 @unlink(i8* %4)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @perror(i8* %4)
br label %59
59: ; preds = %57, %54
%60 = load i32, i32* @PATH_MAX
%61 = call i64 @fgets(i8* %4, i32 %60, i32* %6)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %16
63: ; preds = %59, %12
ret void
}