#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ lstat(char *, struct stat *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  int n;
  for (n = 1; n < argc; n++) {
    struct stat s;
    if (lstat(argv[n], &s) == 0) {
      fprintf(stderr, "%s already exists. Delete it.\n", argv[n]);
      exit(1);
    } else if (errno != ENOENT) {
      fprintf(stderr, "%s: can't lstat (%s)\n", argv[n], strerror(errno));
      exit(1);
    }
    if (stat(argv[n], &s) == 0) {
      fprintf(stderr, "%s already exists. Delete it.\n", argv[n]);
      exit(1);
    } else if (errno != ENOENT) {
      fprintf(stderr, "%s: can't stat (%s)\n", argv[n], strerror(errno));
      exit(1);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12fc <main+0x1ac>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <lstat@plt>
cmp    $0x0,%rax
jne    11c5 <main+0x75>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%rax
mov    0x2df2(%rip),%rcx
cmp    (%rcx),%rax
je     122c <main+0xdc>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1231 <main+0xe1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    127d <main+0x12d>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%rax
mov    0x2d3a(%rip),%rcx
cmp    (%rcx),%rax
je     12e4 <main+0x194>
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d1e(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xd62(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    12e9 <main+0x199>
jmp    12ee <main+0x19e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x1d>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11bf <main+0x6f>
mov    %rsi,%rbx
mov    %edi,%r15d
mov    $0x1,%ebp
mov    %rsp,%r14
mov    0x2e63(%rip),%r12
mov    0x2e4c(%rip),%r13
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1030 <lstat@plt>
test   %rax,%rax
je     11c6 <main+0x76>
mov    (%r12),%rdi
cmp    0x0(%r13),%rdi
jne    11eb <main+0x9b>
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1050 <stat@plt>
test   %rax,%rax
je     11c6 <main+0x76>
mov    (%r12),%rdi
cmp    0x0(%r13),%rdi
jne    1207 <main+0xb7>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1180 <main+0x30>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%rbp,8),%rdx
lea    0xe26(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%r14d
mov    (%rbx,%rbp,8),%rbx
call   1070 <strerror@plt>
lea    0xe1a(%rip),%rsi
jmp    1221 <main+0xd1>
mov    0x2dd2(%rip),%rax
mov    (%rax),%r14d
mov    (%rbx,%rbp,8),%rbx
call   1070 <strerror@plt>
lea    0xe14(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"%s already exists. Delete it.\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [22 x i8] c"%s: can't lstat (%s)\0A\00"
@.str.2 = [21 x i8] c"%s: can't stat (%s)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %8
8: ; preds = %79, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %82
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @lstat(i8* %17, %struct.stat* %7)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %12
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %12
%30 = load i64, i64* @errno
%31 = load i64, i64* @ENOENT
%32 = icmp ne i64 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = load i64, i64* @errno
%41 = call i8* @strerror(i64 %40)
%42 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %39, i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %29
br label %45
45: ; preds = %44
%46 = load i8**, i8*** %5
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i64 @stat(i8* %50, %struct.stat* %7)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %45
%54 = load i32, i32* @stderr
%55 = load i8**, i8*** %5
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %59)
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %45
%63 = load i64, i64* @errno
%64 = load i64, i64* @ENOENT
%65 = icmp ne i64 %63, %64
br i1 %65, label %66, label %77
66: ; preds = %62
%67 = load i32, i32* @stderr
%68 = load i8**, i8*** %5
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = load i64, i64* @errno
%74 = call i8* @strerror(i64 %73)
%75 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %72, i8* %74)
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %62
br label %78
78: ; preds = %77
br label %79
79: ; preds = %78
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %8
82: ; preds = %8
%83 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"%s already exists. Delete it.\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [22 x i8] c"%s: can't lstat (%s)\0A\00"
@.str.2 = [21 x i8] c"%s: can't stat (%s)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %51
5: ; preds = %2
%6 = bitcast %struct.stat* %3 to i8*
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %5, %48
%9 = phi i64 [ 1, %5 ], [ %49, %48 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = call i64 @lstat(i8* %11, %struct.stat* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %10
%17 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %8
%20 = load i64, i64* @errno
%21 = load i64, i64* @ENOENT
%22 = icmp eq i64 %20, %21
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %10
%26 = call i8* @strerror(i64 %20)
%27 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
%30 = load i8*, i8** %10
%31 = call i64 @stat(i8* %30, %struct.stat* %3)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %10
%36 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %29
%39 = load i64, i64* @errno
%40 = load i64, i64* @ENOENT
%41 = icmp eq i64 %39, %40
br i1 %41, label %48, label %42
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %10
%45 = call i8* @strerror(i64 %39)
%46 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %44, i8* %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38
%49 = add nuw nsw i64 %9, 1
%50 = icmp eq i64 %49, %7
br i1 %50, label %51, label %8
51: ; preds = %48, %2
%52 = call i32 @exit(i32 0)
unreachable
}