#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 */
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ R_OK;
int /*<<< orphan*/ W_OK;
int /*<<< orphan*/ X_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int i;
  if (argc < 2) {
    printf("usage: access_1 file1 file2 ... fileN\n");
    exit(1);
  }
  for (i = 1; i < argc; i++) {
    if (access(argv[i], F_OK) != 0) {
      printf("%s isn't exist.\n", argv[i]);
      continue;
    }
    if (access(argv[i], R_OK) == 0)
      printf("User can read %s\n", argv[i]);
    if (access(argv[i], W_OK) == 0)
      printf("User can write %s\n", argv[i]);
    if (access(argv[i], X_OK) == 0)
      printf("User can execute %s\n", argv[i]);
  }
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1168 <main+0x38>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    128b <main+0x15b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0x0,%rax
je     11be <main+0x8e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127d <main+0x14d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0x0,%rax
jne    11fc <main+0xcc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0x0,%rax
jne    123a <main+0x10a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d93(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0x0,%rax
jne    1278 <main+0x148>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127d <main+0x14d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <main+0x3f>
xor    %eax,%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
cmp    $0x2,%edi
jl     1236 <main+0xf6>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r14d
mov    0x2e5a(%rip),%r15
mov    0x2e73(%rip),%r12
lea    0xe8c(%rip),%r13
jmp    1197 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
je     1225 <main+0xe5>
mov    (%rbx,%r14,8),%rdi
mov    (%r15),%esi
call   1050 <access@plt>
mov    (%rbx,%r14,8),%rsi
test   %rax,%rax
jne    1180 <main+0x40>
mov    0x2e1d(%rip),%rax
mov    (%rax),%eax
mov    %rsi,%rdi
mov    %eax,%esi
call   1050 <access@plt>
test   %rax,%rax
jne    11d6 <main+0x96>
mov    (%rbx,%r14,8),%rsi
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx,%r14,8),%rdi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
test   %rax,%rax
jne    11ff <main+0xbf>
mov    (%rbx,%r14,8),%rsi
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx,%r14,8),%rdi
mov    (%r12),%esi
call   1050 <access@plt>
test   %rax,%rax
jne    118a <main+0x4a>
mov    (%rbx,%r14,8),%rsi
lea    0xe16(%rip),%rdi
jmp    1183 <main+0x43>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@F_OK = global i32 0
@.str.1 = [17 x i8] c"%s isn't exist.\0A\00"
@R_OK = global i32 0
@.str.2 = [18 x i8] c"User can read %s\0A\00"
@W_OK = global i32 0
@.str.3 = [19 x i8] c"User can write %s\0A\00"
@X_OK = global i32 0
@.str.4 = [21 x i8] c"User can execute %s\0A\00"
@str = [38 x i8] c"usage: access_1 file1 file2 ... fileN\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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %4, %42
%10 = phi i64 [ 1, %4 ], [ %43, %42 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = load i32, i32* @F_OK
%14 = tail call i64 @access(i8* %12, i32 %13)
%15 = icmp eq i64 %14, 0
%16 = load i8*, i8** %11
br i1 %15, label %19, label %17
17: ; preds = %9
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %42
19: ; preds = %9
%20 = load i32, i32* @R_OK
%21 = tail call i64 @access(i8* %16, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %11
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %19
%27 = load i8*, i8** %11
%28 = load i32, i32* @W_OK
%29 = tail call i64 @access(i8* %27, i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8*, i8** %11
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %26
%35 = load i8*, i8** %11
%36 = load i32, i32* @X_OK
%37 = tail call i64 @access(i8* %35, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = load i8*, i8** %11
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %34, %39, %17
%43 = add nuw nsw i64 %10, 1
%44 = icmp eq i64 %43, %5
br i1 %44, label %45, label %9
45: ; preds = %42
ret i32 0
}