#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ EINVAL;
scalar_t__ ENOSYS;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int parrot_getacl(char const *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  const char *path;
  char buf[4096];
  int result;
  if (argc < 2) {
    path = ".";
  } else {
    path = argv[1];
  }
  if (argc > 2 || path[0] == '-') {
    printf("use: parrot_getacl [path]\n");
    return 0;
  }
  result = parrot_getacl(path, buf, sizeof(buf));
  if (result >= 0) {
    buf[result] = 0;
    printf("%s", buf);
    return 0;
  } else {
    if (errno == ENOSYS || errno == EINVAL) {
      fprintf(
          stderr,
          "getacl: This filesystem does not support Parrot access controls.\n");
    } else {
      fprintf(stderr, "getacl: %s\n", strerror(errno));
    }
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1173 <main+0x33>
lea    0xe96(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    117f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     1199 <main+0x59>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11b3 <main+0x73>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1297 <main+0x157>
mov    -0x18(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1030 <parrot_getacl@plt>
mov    %eax,-0x1024(%rbp)
cmpl   $0x0,-0x1024(%rbp)
jl     120b <main+0xcb>
movslq -0x1024(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1297 <main+0x157>
mov    0x2dbe(%rip),%rax
mov    (%rax),%rax
mov    0x2dcc(%rip),%rcx
cmp    (%rcx),%rax
je     123f <main+0xff>
mov    0x2da4(%rip),%rax
mov    (%rax),%rax
mov    0x2d92(%rip),%rcx
cmp    (%rcx),%rax
jne    125b <main+0x11b>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1290 <main+0x150>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1028(%rbp)
mov    0x2d5f(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x1028(%rbp),%edi
mov    %rax,%rdx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1000,%rsp
cmp    $0x2,%edi
jge    116b <main+0x1b>
lea    0xe9c(%rip),%rdi
cmpb   $0x2d,(%rdi)
je     1176 <main+0x26>
jmp    1189 <main+0x39>
jne    1176 <main+0x26>
mov    0x8(%rsi),%rdi
cmpb   $0x2d,(%rdi)
jne    1189 <main+0x39>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    120f <main+0xbf>
mov    %rsp,%rsi
mov    $0x1000,%edx
call   1040 <parrot_getacl@plt>
test   %eax,%eax
js     11b5 <main+0x65>
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe5b(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    120f <main+0xbf>
mov    0x2e14(%rip),%rax
mov    (%rax),%rdi
mov    0x2e22(%rip),%rax
mov    0x2e0b(%rip),%rcx
mov    (%rcx),%ebx
cmp    (%rax),%rdi
je     11fa <main+0xaa>
mov    0x2ded(%rip),%rax
cmp    (%rax),%rdi
je     11fa <main+0xaa>
call   1070 <strerror@plt>
lea    0xe5b(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    120a <main+0xba>
lea    0xe04(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [27 x i8] c"use: parrot_getacl [path]\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.3 = [66 x i8] c"getacl: This filesystem does not support Parrot access controls.\0A\00"
@.str.4 = [12 x i8] c"getacl: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [4096 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
br label %16
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
br label %16
16: ; preds = %12, %11
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 2
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %25, label %27
25: ; preds = %19, %16
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %56
27: ; preds = %19
%28 = load i8*, i8** %6
%29 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%30 = call i32 @parrot_getacl(i8* %28, i8* %29, i32 4096)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp sge i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %27
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %35
store i8 0, i8* %36
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 0, i32* %3
br label %56
39: ; preds = %27
%40 = load i64, i64* @errno
%41 = load i64, i64* @ENOSYS
%42 = icmp eq i64 %40, %41
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i64, i64* @errno
%45 = load i64, i64* @EINVAL
%46 = icmp eq i64 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43, %39
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0))
br label %55
50: ; preds = %43
%51 = load i32, i32* @stderr
%52 = load i64, i64* @errno
%53 = call i8* @strerror(i64 %52)
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %50, %47
store i32 1, i32* %3
br label %56
56: ; preds = %55, %33, %25
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"%s\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.3 = [66 x i8] c"getacl: This filesystem does not support Parrot access controls.\0A\00"
@.str.4 = [12 x i8] c"getacl: %s\0A\00"
@str = [26 x i8] c"use: parrot_getacl [path]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %14
10: ; preds = %2, %6
%11 = phi i8* [ %8, %6 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %14, label %16
14: ; preds = %10, %6
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %36
16: ; preds = %10
%17 = call i32 @parrot_getacl(i8* %11, i8* %4, i32 4096)
%18 = icmp sgt i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = zext i32 %17 to i64
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %36
23: ; preds = %16
%24 = load i64, i64* @errno
%25 = load i64, i64* @ENOSYS
%26 = icmp eq i64 %24, %25
%27 = load i64, i64* @EINVAL
%28 = icmp eq i64 %24, %27
%29 = select i1 %26, i1 true, i1 %28
%30 = load i32, i32* @stderr
br i1 %29, label %31, label %33
31: ; preds = %23
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0))
br label %36
33: ; preds = %23
%34 = call i8* @strerror(i64 %24)
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %31, %33, %19, %14
%37 = phi i32 [ 0, %14 ], [ 0, %19 ], [ 1, %33 ], [ 1, %31 ]
ret i32 %37
}