#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__ EINVAL;
scalar_t__ ENOSYS;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ parrot_setacl(char *, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  if (argc != 4) {
    printf("use: parrot_setacl <path> <subject> <rights>\n");
    return 0;
  }
  if (!strcmp(argv[3], "read"))
    argv[3] = "rl";
  if (!strcmp(argv[3], "write"))
    argv[3] = "rwld";
  if (!strcmp(argv[3], "admin"))
    argv[3] = "rwlda";
  if (!strcmp(argv[3], "none"))
    argv[3] = "-";
  if (parrot_setacl(argv[1], argv[2], argv[3]) >= 0) {
    return 0;
  } else {
    if (errno == ENOSYS || errno == EINVAL) {
      fprintf(
          stderr,
          "setacl: This filesystem does not support Parrot access controls.\n");
    } else {
      fprintf(stderr, "setacl: %s\n", strerror(errno));
    }
    return 1;
  }
}


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   $0x4,-0x8(%rbp)
je     1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <main+0x1a1>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe97(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11b4 <main+0x64>
mov    -0x10(%rbp),%rax
lea    0xe83(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe73(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e0 <main+0x90>
mov    -0x10(%rbp),%rax
lea    0xe60(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe52(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    120c <main+0xbc>
mov    -0x10(%rbp),%rax
lea    0xe3f(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe32(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1238 <main+0xe8>
mov    -0x10(%rbp),%rax
lea    0xe1e(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
call   1030 <parrot_setacl@plt>
cmp    $0x0,%rax
jl     126b <main+0x11b>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <main+0x1a1>
mov    0x2d5e(%rip),%rax
mov    (%rax),%rax
mov    0x2d6c(%rip),%rcx
cmp    (%rcx),%rax
je     129f <main+0x14f>
mov    0x2d44(%rip),%rax
mov    (%rax),%rax
mov    0x2d32(%rip),%rcx
cmp    (%rcx),%rax
jne    12bb <main+0x16b>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12ea <main+0x19a>
mov    0x2d16(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2d02(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    123b <main+0xeb>
mov    %rsi,%r14
mov    0x18(%rsi),%rbx
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1182 <main+0x32>
lea    0xe87(%rip),%rbx
mov    %rbx,0x18(%r14)
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11a0 <main+0x50>
lea    0xe72(%rip),%rbx
mov    %rbx,0x18(%r14)
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11be <main+0x6e>
lea    0xe5f(%rip),%rbx
mov    %rbx,0x18(%r14)
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11dc <main+0x8c>
lea    0xe4c(%rip),%rbx
mov    %rbx,0x18(%r14)
mov    0x8(%r14),%rdi
mov    0x10(%r14),%rsi
mov    %rbx,%rdx
call   1030 <parrot_setacl@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    1260 <main+0x110>
mov    0x2dd3(%rip),%rax
mov    (%rax),%rdi
mov    0x2de1(%rip),%rax
mov    0x2dca(%rip),%rcx
mov    (%rcx),%ebx
cmp    (%rax),%rdi
je     124b <main+0xfb>
mov    0x2dac(%rip),%rax
cmp    (%rax),%rdi
je     124b <main+0xfb>
call   1070 <strerror@plt>
lea    0xe3b(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    125b <main+0x10b>
lea    0xe32(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    1260 <main+0x110>
lea    0xdd4(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [46 x i8] c"use: parrot_setacl <path> <subject> <rights>\0A\00"
@.str.1 = [5 x i8] c"read\00"
@.str.2 = [3 x i8] c"rl\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [5 x i8] c"rwld\00"
@.str.5 = [6 x i8] c"admin\00"
@.str.6 = [6 x i8] c"rwlda\00"
@.str.7 = [5 x i8] c"none\00"
@.str.8 = [2 x i8] c"-\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.9 = [66 x i8] c"setacl: This filesystem does not support Parrot access controls.\0A\00"
@.str.10 = [12 x i8] c"setacl: %s\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
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 4
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %76
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 3
%13 = load i8*, i8** %12
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %18
br label %19
19: ; preds = %16, %10
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %27
br label %28
28: ; preds = %25, %19
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8** %36
br label %37
37: ; preds = %34, %28
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 3
%40 = load i8*, i8** %39
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %37
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8** %45
br label %46
46: ; preds = %43, %37
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 3
%55 = load i8*, i8** %54
%56 = call i64 @parrot_setacl(i8* %49, i8* %52, i8* %55)
%57 = icmp sge i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %46
store i32 0, i32* %3
br label %76
59: ; preds = %46
%60 = load i64, i64* @errno
%61 = load i64, i64* @ENOSYS
%62 = icmp eq i64 %60, %61
br i1 %62, label %67, label %63
63: ; preds = %59
%64 = load i64, i64* @errno
%65 = load i64, i64* @EINVAL
%66 = icmp eq i64 %64, %65
br i1 %66, label %67, label %70
67: ; preds = %63, %59
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.9, i64 0, i64 0))
br label %75
70: ; preds = %63
%71 = load i32, i32* @stderr
%72 = load i64, i64* @errno
%73 = call i8* @strerror(i64 %72)
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %73)
br label %75
75: ; preds = %70, %67
store i32 1, i32* %3
br label %76
76: ; preds = %75, %58, %8
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"read\00"
@.str.2 = [3 x i8] c"rl\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [5 x i8] c"rwld\00"
@.str.5 = [6 x i8] c"admin\00"
@.str.6 = [6 x i8] c"rwlda\00"
@.str.7 = [5 x i8] c"none\00"
@.str.8 = [2 x i8] c"-\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.9 = [66 x i8] c"setacl: This filesystem does not support Parrot access controls.\0A\00"
@.str.10 = [12 x i8] c"setacl: %s\0A\00"
@str = [45 x i8] c"use: parrot_setacl <path> <subject> <rights>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %48
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %6
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %12
12: ; preds = %11, %6
%13 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %11 ], [ %8, %6 ]
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %17
17: ; preds = %16, %12
%18 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %16 ], [ %13, %12 ]
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %22
22: ; preds = %21, %17
%23 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %21 ], [ %18, %17 ]
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %23, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8** %7
br label %27
27: ; preds = %26, %22
%28 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), %26 ], [ %23, %22 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = tail call i64 @parrot_setacl(i8* %30, i8* %32, i8* %28)
%34 = icmp sgt i64 %33, -1
br i1 %34, label %48, label %35
35: ; preds = %27
%36 = load i64, i64* @errno
%37 = load i64, i64* @ENOSYS
%38 = icmp eq i64 %36, %37
%39 = load i64, i64* @EINVAL
%40 = icmp eq i64 %36, %39
%41 = select i1 %38, i1 true, i1 %40
%42 = load i32, i32* @stderr
br i1 %41, label %43, label %45
43: ; preds = %35
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.9, i64 0, i64 0))
br label %48
45: ; preds = %35
%46 = tail call i8* @strerror(i64 %36)
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %43, %45, %27, %4
%49 = phi i32 [ 0, %4 ], [ 0, %27 ], [ 1, %45 ], [ 1, %43 ]
ret i32 %49
}