#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 */
scalar_t__ ENOENT;
int /*<<< orphan*/ F_OK;
int access(char *, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, ...);
char *strerror(scalar_t__);
int unlink(char *);
int main(int argc, char **argv) {
  int rc = 0, i;
  if (argc < 2) {
    printf("Usage %s filename {filename ...}\n", argv[0]);
    return 1;
  }
  for (i = 1; i < argc; i++) {
    rc = unlink(argv[i]);
    if (rc) {
      printf("unlink(%s): %s ", argv[i], strerror(errno));
      rc = access(argv[i], F_OK);
      if (rc && errno == ENOENT)
        printf("(unlinked anyways)\n");
      else if (rc == 0)
        printf("(still exists)\n");
      else
        printf("(%s looking up)\n", strerror(errno));
    }
  }
  return rc;
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1188 <main+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <main+0x161>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    129b <main+0x15b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1288 <main+0x148>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2dc8(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1241 <main+0x101>
mov    0x2dc5(%rip),%rax
mov    (%rax),%rax
mov    0x2dab(%rip),%rcx
cmp    (%rcx),%rax
jne    1241 <main+0x101>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1283 <main+0x143>
cmpl   $0x0,-0x14(%rbp)
jne    125e <main+0x11e>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127e <main+0x13e>
mov    0x2d7b(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1283 <main+0x143>
jmp    1288 <main+0x148>
jmp    128d <main+0x14d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x4f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jge    118a <main+0x3a>
mov    (%rbx),%rsi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r12d
mov    $0x1,%r13d
mov    0x2e46(%rip),%r15
mov    0x2e27(%rip),%r14
jmp    11c7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
add    $0x1,%r13
cmp    %r13,%r12
je     1179 <main+0x29>
mov    (%rbx,%r13,8),%rdi
call   1030 <unlink@plt>
mov    $0x0,%ebp
test   %eax,%eax
je     11be <main+0x6e>
mov    (%rbx,%r13,8),%rbp
mov    (%r15),%rdi
call   1070 <strerror@plt>
lea    0xe36(%rip),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%r13,8),%rdi
mov    (%r14),%esi
call   1060 <access@plt>
test   %eax,%eax
je     11b0 <main+0x60>
mov    %eax,%ebp
mov    (%r15),%rdi
mov    0x2dbb(%rip),%rax
cmp    (%rax),%rdi
jne    1228 <main+0xd8>
lea    0xe31(%rip),%rdi
call   1040 <puts@plt>
jmp    11be <main+0x6e>
call   1070 <strerror@plt>
lea    0xdfe(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11be <main+0x6e>

LLVM IR (-O0):
@.str = [34 x i8] c"Usage %s filename {filename ...}\0A\00"
@.str.1 = [16 x i8] c"unlink(%s): %s \00"
@errno = global i64 0
@F_OK = global i32 0
@ENOENT = global i64 0
@.str.2 = [20 x i8] c"(unlinked anyways)\0A\00"
@.str.3 = [16 x i8] c"(still exists)\0A\00"
@.str.4 = [17 x i8] c"(%s looking up)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %70
15: ; preds = %2
store i32 1, i32* %7
br label %16
16: ; preds = %65, %15
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %68
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @unlink(i8* %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %64
29: ; preds = %20
%30 = load i8**, i8*** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = load i64, i64* @errno
%36 = call i8* @strerror(i64 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %36)
%38 = load i8**, i8*** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = load i32, i32* @F_OK
%44 = call i32 @access(i8* %42, i32 %43)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %29
%48 = load i64, i64* @errno
%49 = load i64, i64* @ENOENT
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %63
53: ; preds = %47, %29
%54 = load i32, i32* %6
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %62
58: ; preds = %53
%59 = load i64, i64* @errno
%60 = call i8* @strerror(i64 %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %58, %56
br label %63
63: ; preds = %62, %51
br label %64
64: ; preds = %63, %20
br label %65
65: ; preds = %64
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %16
68: ; preds = %16
%69 = load i32, i32* %6
store i32 %69, i32* %3
br label %70
70: ; preds = %68, %10
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [34 x i8] c"Usage %s filename {filename ...}\0A\00"
@.str.1 = [16 x i8] c"unlink(%s): %s \00"
@errno = global i64 0
@F_OK = global i32 0
@ENOENT = global i64 0
@.str.4 = [17 x i8] c"(%s looking up)\0A\00"
@str = [15 x i8] c"(still exists)\00"
@str.5 = [19 x i8] c"(unlinked anyways)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %39
9: ; preds = %4, %35
%10 = phi i64 [ 1, %4 ], [ %37, %35 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @unlink(i8* %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %9
%16 = load i8*, i8** %11
%17 = load i64, i64* @errno
%18 = tail call i8* @strerror(i64 %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %18)
%20 = load i8*, i8** %11
%21 = load i32, i32* @F_OK
%22 = tail call i32 @access(i8* %20, i32 %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %15
%25 = load i64, i64* @errno
%26 = load i64, i64* @ENOENT
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
br label %35
30: ; preds = %15
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %35
32: ; preds = %24
%33 = tail call i8* @strerror(i64 %25)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %9, %30, %32, %28
%36 = phi i32 [ %22, %28 ], [ 0, %30 ], [ %22, %32 ], [ 0, %9 ]
%37 = add nuw nsw i64 %10, 1
%38 = icmp eq i64 %37, %5
br i1 %38, label %39, label %9
39: ; preds = %35, %6
%40 = phi i32 [ 1, %6 ], [ %36, %35 ]
ret i32 %40
}