#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__ ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int setxattr(char const *, char *, char const *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void apply(const char *flags, size_t flags_len, const char *path) {
  if (setxattr(path, "user.pax.flags", flags, flags_len, 0) == -1) {
    if (errno != ENOENT) {
      fprintf(stderr, "could not apply attributes to %s: %m\n", path);
    }
  }
}


x86 assembly (clang, -O0):
<apply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xeb9(%rip),%rsi
xor    %r8d,%r8d
call   1040 <setxattr@plt>
cmp    $0xffffffff,%eax
jne    1190 <apply+0x70>
mov    0x2e79(%rip),%rax
mov    (%rax),%rax
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%rax
je     118b <apply+0x6b>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1190 <apply+0x70>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply>:
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0xecf(%rip),%rsi
mov    %rbx,%rdi
xor    %r8d,%r8d
call   1040 <setxattr@plt>
cmp    $0xffffffff,%eax
jne    1157 <apply+0x37>
mov    0x2e90(%rip),%rax
mov    (%rax),%rax
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%rax
jne    1159 <apply+0x39>
pop    %rbx
ret
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
mov    %rbx,%rdx
pop    %rbx
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"user.pax.flags\00"
@errno = global i64 0
@ENOENT = global i64 0
@stderr = global i32 0
@.str.1 = [38 x i8] c"could not apply attributes to %s: %m\0A\00"
define void @apply(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = load i8*, i8** %4
%9 = load i64, i64* %5
%10 = call i32 @setxattr(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %8, i64 %9, i32 0)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %21
12: ; preds = %3
%13 = load i64, i64* @errno
%14 = load i64, i64* @ENOENT
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %6
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %12
br label %21
21: ; preds = %20, %3
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"user.pax.flags\00"
@errno = global i64 0
@ENOENT = global i64 0
@stderr = global i32 0
@.str.1 = [38 x i8] c"could not apply attributes to %s: %m\0A\00"
define void @apply(i8* %0, i64 %1, i8* %2) {
%4 = tail call i32 @setxattr(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = load i64, i64* @errno
%8 = load i64, i64* @ENOENT
%9 = icmp eq i64 %7, %8
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %13
13: ; preds = %6, %10, %3
ret void
}