#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 */
#define EACCES 137
#define EBUSY 136
#define EFAULT 135
#define EIO 134
#define ELOOP 133
#define ENAMETOOLONG 132
#define ENOENT 131
#define ENOTDIR 130
#define EPERM 129
#define EROFS 128
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ unlink(char *);
int main(int argc, char **argv) {
  while (*++argv != NULL) {
    if (unlink(*argv)) {
      switch (errno) {
      case ENOTDIR:
        fprintf(stderr, "%s not a directory\n", *argv);
        break;
      case ENAMETOOLONG:
        fprintf(stderr, "%s name too long\n", *argv);
        break;
      case ENOENT:
        fprintf(stderr, "%s doesnt exist\n", *argv);
        break;
      case EACCES:
        fprintf(stderr, "%s: permission denied\n", *argv);
        break;
      case ELOOP:
        fprintf(stderr, "%s: too many symbolic links\n", *argv);
        break;
      case EPERM:
        fprintf(stderr, "%s: permission denied\n", *argv);
        break;
      case EBUSY:
        fprintf(stderr, "%s: busy\n", *argv);
        break;
      case EIO:
        fprintf(stderr, "%s: I/O error\n", *argv);
        break;
      case EROFS:
        fprintf(stderr, "%s: R/O file system\n", *argv);
        break;
      case EFAULT:
        fprintf(stderr, "%s: Bad path\n", *argv);
        break;
      }
    }
  }
}


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)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     12e4 <main+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     12df <main+0x1bf>
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     12da <main+0x1ba>
mov    -0x18(%rbp),%rax
lea    0xe74(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6f(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe60(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe50(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe46(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe0e(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe21(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe0a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf8(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <main+0x1ba>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdec(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12df <main+0x1bf>
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1189 <main+0x69>
mov    %rsi,%rbx
add    $0x10,%rbx
mov    0x2e99(%rip),%r14
lea    0xf62(%rip),%r15
mov    0x2e93(%rip),%r12
jmp    115c <main+0x3c>
nop
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1189 <main+0x69>
call   1030 <unlink@plt>
test   %rax,%rax
je     1150 <main+0x30>
mov    (%r14),%eax
add    $0xffffff80,%eax
cmp    $0x9,%eax
ja     1150 <main+0x30>
cltq
movslq (%r15,%rax,4),%rsi
add    %r15,%rsi
mov    (%r12),%edi
mov    -0x8(%rbx),%rdx
call   1040 <fprintf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"%s not a directory\0A\00"
@.str.1 = [18 x i8] c"%s name too long\0A\00"
@.str.2 = [17 x i8] c"%s doesnt exist\0A\00"
@.str.3 = [23 x i8] c"%s: permission denied\0A\00"
@.str.4 = [29 x i8] c"%s: too many symbolic links\0A\00"
@.str.5 = [10 x i8] c"%s: busy\0A\00"
@.str.6 = [15 x i8] c"%s: I/O error\0A\00"
@.str.7 = [21 x i8] c"%s: R/O file system\0A\00"
@.str.8 = [14 x i8] c"%s: Bad path\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %6
6: ; preds = %69, %2
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i32 1
store i8** %8, i8*** %5
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %70
11: ; preds = %6
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = call i64 @unlink(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %69
16: ; preds = %11
%17 = load i32, i32* @errno
switch i32 %17, label %68 [
i32 130, label %18
i32 132, label %23
i32 131, label %28
i32 137, label %33
i32 133, label %38
i32 129, label %43
i32 136, label %48
i32 134, label %53
i32 128, label %58
i32 135, label %63
]
18: ; preds = %16
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %68
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = load i8*, i8** %25
%27 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %68
28: ; preds = %16
%29 = load i32, i32* @stderr
%30 = load i8**, i8*** %5
%31 = load i8*, i8** %30
%32 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %68
33: ; preds = %16
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = load i8*, i8** %35
%37 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %36)
br label %68
38: ; preds = %16
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = load i8*, i8** %40
%42 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %41)
br label %68
43: ; preds = %16
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = load i8*, i8** %45
%47 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %46)
br label %68
48: ; preds = %16
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = load i8*, i8** %50
%52 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %51)
br label %68
53: ; preds = %16
%54 = load i32, i32* @stderr
%55 = load i8**, i8*** %5
%56 = load i8*, i8** %55
%57 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %56)
br label %68
58: ; preds = %16
%59 = load i32, i32* @stderr
%60 = load i8**, i8*** %5
%61 = load i8*, i8** %60
%62 = call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %61)
br label %68
63: ; preds = %16
%64 = load i32, i32* @stderr
%65 = load i8**, i8*** %5
%66 = load i8*, i8** %65
%67 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %16, %63, %58, %53, %48, %43, %38, %33, %28, %23, %18
br label %69
69: ; preds = %68, %11
br label %6
70: ; preds = %6
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@errno = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"%s not a directory\0A\00"
@.str.1 = [18 x i8] c"%s name too long\0A\00"
@.str.2 = [17 x i8] c"%s doesnt exist\0A\00"
@.str.3 = [23 x i8] c"%s: permission denied\0A\00"
@.str.4 = [29 x i8] c"%s: too many symbolic links\0A\00"
@.str.5 = [10 x i8] c"%s: busy\0A\00"
@.str.6 = [15 x i8] c"%s: I/O error\0A\00"
@.str.7 = [21 x i8] c"%s: R/O file system\0A\00"
@.str.8 = [14 x i8] c"%s: Bad path\0A\00"
@reltable.main = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %26, label %6
6: ; preds = %2, %22
%7 = phi i8* [ %24, %22 ], [ %4, %2 ]
%8 = phi i8** [ %23, %22 ], [ %3, %2 ]
%9 = tail call i64 @unlink(i8* %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %6
%12 = load i32, i32* @errno
%13 = add i32 %12, -128
%14 = icmp ult i32 %13, 10
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = sext i32 %13 to i64
%17 = shl i64 %16, 2
%18 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.main to i8*), i64 %17)
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %8
%21 = tail call i32 @fprintf(i32 %19, i8* %18, i8* %20)
br label %22
22: ; preds = %11, %15, %6
%23 = getelementptr inbounds i8*, i8** %8, i64 1
%24 = load i8*, i8** %23
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %6
26: ; preds = %22, %2
ret i32 0
}