#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 */
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ R_OK;
int /*<<< orphan*/ W_OK;
int /*<<< orphan*/ X_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  struct stat sta;
  if (argc != 2) {
    printf("args too less\n");
    exit(1);
  }
  if (access(argv[1], F_OK) != -1) {
    if (access(argv[1], R_OK) != -1) {
      printf("readable\n");
    }
    if (access(argv[1], W_OK) != -1) {
      printf("writeable\n");
    }
    if (access(argv[1], X_OK) != -1) {
      printf("execable\n");
    }
  } else {
    printf("%s not exit\n", argv[1]);
  }
  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)
je     1168 <main+0x38>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     1213 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     11b4 <main+0x84>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     11e1 <main+0xb1>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     120e <main+0xde>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1229 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11e7 <main+0xa7>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
mov    0x8(%rbx),%rcx
cmp    $0xffffffff,%eax
je     11d2 <main+0x92>
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
mov    %rcx,%rdi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
je     118a <main+0x4a>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
je     11ad <main+0x6d>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
je     11e3 <main+0xa3>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
jmp    11e3 <main+0xa3>
lea    0xe27(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe3b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [15 x i8] c"args too less\0A\00"
@F_OK = global i32 0
@R_OK = global i32 0
@.str.1 = [10 x i8] c"readable\0A\00"
@W_OK = global i32 0
@.str.2 = [11 x i8] c"writeable\0A\00"
@X_OK = global i32 0
@.str.3 = [10 x i8] c"execable\0A\00"
@.str.4 = [13 x i8] c"%s not exit\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @F_OK
%17 = call i32 @access(i8* %15, i32 %16)
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %47
19: ; preds = %12
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i32, i32* @R_OK
%24 = call i32 @access(i8* %22, i32 %23)
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %19
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i32, i32* @W_OK
%33 = call i32 @access(i8* %31, i32 %32)
%34 = icmp ne i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %28
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = load i32, i32* @X_OK
%42 = call i32 @access(i8* %40, i32 %41)
%43 = icmp ne i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %37
br label %52
47: ; preds = %12
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %47, %46
ret i32 0
}

LLVM IR (-O2):
@F_OK = global i32 0
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
@.str.4 = [13 x i8] c"%s not exit\0A\00"
@str = [9 x i8] c"execable\00"
@str.5 = [10 x i8] c"writeable\00"
@str.6 = [9 x i8] c"readable\00"
@str.7 = [14 x i8] c"args too less\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @F_OK
%11 = tail call i32 @access(i8* %9, i32 %10)
%12 = icmp eq i32 %11, -1
%13 = load i8*, i8** %8
br i1 %12, label %34, label %14
14: ; preds = %7
%15 = load i32, i32* @R_OK
%16 = tail call i32 @access(i8* %13, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.6, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i8*, i8** %8
%22 = load i32, i32* @W_OK
%23 = tail call i32 @access(i8* %21, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %27, label %25
25: ; preds = %20
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %20
%28 = load i8*, i8** %8
%29 = load i32, i32* @X_OK
%30 = tail call i32 @access(i8* %28, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %36, label %32
32: ; preds = %27
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %36
34: ; preds = %7
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %13)
br label %36
36: ; preds = %27, %32, %34
ret i32 0
}