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

/* Variables and functions */
int XATTR_CREATE;
int /*<<< orphan*/ close(int);
int creat(char *, int);
int /*<<< orphan*/ fgetxattr(int, char *, char *, size_t);
int /*<<< orphan*/ flistxattr(int, char *, size_t);
int /*<<< orphan*/ fremovexattr(int, char *);
int /*<<< orphan*/ fsetxattr(int, char *, ...);
int main() {
  char buffer[1024];
  int fd;
  unsigned int array[5] = {0xdeadbeef, 2, 3, 4, 5};
  fd = creat("foobar", 0666);
  fsetxattr(fd, "user.systemtap.test", "testing", sizeof("testing"),
            XATTR_CREATE);
  fsetxattr(fd,
            "user.systemtap.test"
            "2",
            array, sizeof(array), XATTR_CREATE);
  fgetxattr(fd, "user.systemtap.test", buffer, sizeof(buffer));
  flistxattr(fd, buffer, sizeof(buffer));
  fremovexattr(fd, "user.systemtap.test");
  fsetxattr(-1, "user.systemtap.test", "testing", sizeof("testing"),
            XATTR_CREATE);
  fsetxattr(fd, (char *)-1, "testing", sizeof("testing"), XATTR_CREATE);
  fsetxattr(fd, "user.systemtap.test", (void *)-1, sizeof("testing"),
            XATTR_CREATE);
  fsetxattr(fd, "user.systemtap.test", NULL, (size_t)-1, XATTR_CREATE);
  fsetxattr(fd, "user.systemtap.test", "testing", sizeof("testing"), -1);
  fgetxattr(-1, "user.systemtap.test", buffer, sizeof(buffer));
  fgetxattr(fd, (char *)-1, buffer, sizeof(buffer));
  fgetxattr(fd, "user.systemtap.test", (void *)-1, sizeof(buffer));
  fgetxattr(fd, "user.systemtap.test", buffer, (size_t)-1);
  flistxattr(-1, buffer, sizeof(buffer));
  flistxattr(fd, (char *)-1, sizeof(buffer));
  flistxattr(fd, NULL, (size_t)-1);
  fremovexattr(-1, "user.systemtap.test");
  fremovexattr(fd, (char *)-1);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x430(%rbp)
mov    0xe81(%rip),%rax
mov    %rax,-0x428(%rbp)
mov    0xe7c(%rip),%eax
mov    %eax,-0x420(%rbp)
lea    0xe73(%rip),%rdi
mov    $0x1b6,%esi
call   1080 <creat@plt>
mov    %eax,-0x414(%rbp)
mov    -0x414(%rbp),%edi
mov    0x2e2a(%rip),%rax
mov    (%rax),%r8d
lea    0xe53(%rip),%rsi
lea    0xe60(%rip),%rdx
mov    $0x8,%ecx
mov    $0x0,%al
call   1040 <fsetxattr@plt>
mov    -0x414(%rbp),%edi
lea    -0x430(%rbp),%rdx
mov    0x2df9(%rip),%rax
mov    (%rax),%r8d
lea    0xe3e(%rip),%rsi
mov    $0x14,%ecx
mov    $0x0,%al
call   1040 <fsetxattr@plt>
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rdx
lea    0xe02(%rip),%rsi
mov    $0x400,%ecx
call   1070 <fgetxattr@plt>
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1030 <flistxattr@plt>
mov    -0x414(%rbp),%edi
lea    0xdd4(%rip),%rsi
call   1050 <fremovexattr@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%r8d
mov    $0xffffffff,%edi
lea    0xdb9(%rip),%rsi
lea    0xdc6(%rip),%rdx
mov    $0x8,%ecx
mov    $0x0,%al
call   1040 <fsetxattr@plt>
mov    -0x414(%rbp),%edi
mov    0x2d66(%rip),%rax
mov    (%rax),%r8d
mov    $0xffffffffffffffff,%rsi
lea    0xd9c(%rip),%rdx
mov    $0x8,%ecx
mov    $0x0,%al
call   1040 <fsetxattr@plt>
mov    -0x414(%rbp),%edi
mov    0x2d3c(%rip),%rax
mov    (%rax),%r8d
lea    0xd65(%rip),%rsi
mov    $0xffffffffffffffff,%rdx
mov    $0x8,%ecx
mov    $0x0,%al
call   1040 <fsetxattr@plt>
mov    -0x414(%rbp),%edi
mov    0x2d12(%rip),%rax
mov    (%rax),%r8d
lea    0xd3b(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0xffffffffffffffff,%rcx
mov    $0x0,%al
call   1040 <fsetxattr@plt>
mov    -0x414(%rbp),%edi
lea    0xd1c(%rip),%rsi
lea    0xd29(%rip),%rdx
mov    $0x8,%ecx
mov    $0xffffffff,%r8d
mov    $0x0,%al
call   1040 <fsetxattr@plt>
lea    -0x410(%rbp),%rdx
mov    $0xffffffff,%edi
lea    0xcf0(%rip),%rsi
mov    $0x400,%ecx
call   1070 <fgetxattr@plt>
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rdx
mov    $0xffffffffffffffff,%rsi
mov    $0x400,%ecx
call   1070 <fgetxattr@plt>
mov    -0x414(%rbp),%edi
lea    0xcbb(%rip),%rsi
mov    $0xffffffffffffffff,%rdx
mov    $0x400,%ecx
call   1070 <fgetxattr@plt>
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rdx
lea    0xc96(%rip),%rsi
mov    $0xffffffffffffffff,%rcx
call   1070 <fgetxattr@plt>
lea    -0x410(%rbp),%rsi
mov    $0xffffffff,%edi
mov    $0x400,%edx
call   1030 <flistxattr@plt>
mov    -0x414(%rbp),%edi
mov    $0xffffffffffffffff,%rsi
mov    $0x400,%edx
call   1030 <flistxattr@plt>
mov    -0x414(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xffffffffffffffff,%rdx
call   1030 <flistxattr@plt>
mov    $0xffffffff,%edi
lea    0xc3b(%rip),%rsi
call   1050 <fremovexattr@plt>
mov    -0x414(%rbp),%edi
mov    $0xffffffffffffffff,%rsi
call   1050 <fremovexattr@plt>
mov    -0x414(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x420,%rsp
mov    0xe9a(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe88(%rip),%rdi
mov    $0x1b6,%esi
call   1080 <creat@plt>
mov    %eax,%ebx
mov    0x2e49(%rip),%r13
mov    0x0(%r13),%r8d
lea    0xe71(%rip),%r14
lea    0xe7e(%rip),%r12
mov    $0x8,%ecx
mov    %eax,%edi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fsetxattr@plt>
mov    0x0(%r13),%r8d
lea    0xe67(%rip),%rsi
mov    %rsp,%rdx
mov    $0x14,%ecx
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <fsetxattr@plt>
lea    0x20(%rsp),%r15
mov    $0x400,%ecx
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <fgetxattr@plt>
mov    $0x400,%edx
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <flistxattr@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <fremovexattr@plt>
mov    0x0(%r13),%r8d
mov    $0x8,%ecx
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fsetxattr@plt>
mov    0x0(%r13),%r8d
mov    $0x8,%ecx
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fsetxattr@plt>
mov    0x0(%r13),%r8d
mov    $0x8,%ecx
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xffffffffffffffff,%rdx
xor    %eax,%eax
call   1040 <fsetxattr@plt>
mov    0x0(%r13),%r8d
mov    %ebx,%edi
mov    %r14,%rsi
xor    %edx,%edx
mov    $0xffffffffffffffff,%rcx
xor    %eax,%eax
call   1040 <fsetxattr@plt>
mov    $0x8,%ecx
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r12,%rdx
mov    $0xffffffff,%r8d
xor    %eax,%eax
call   1040 <fsetxattr@plt>
mov    $0x400,%ecx
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <fgetxattr@plt>
mov    $0x400,%ecx
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rsi
mov    %r15,%rdx
call   1070 <fgetxattr@plt>
mov    $0x400,%ecx
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xffffffffffffffff,%rdx
call   1070 <fgetxattr@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0xffffffffffffffff,%rcx
call   1070 <fgetxattr@plt>
mov    $0x400,%edx
mov    $0xffffffff,%edi
mov    %r15,%rsi
call   1030 <flistxattr@plt>
mov    $0x400,%edx
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rsi
call   1030 <flistxattr@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    $0xffffffffffffffff,%rdx
call   1030 <flistxattr@plt>
mov    $0xffffffff,%edi
mov    %r14,%rsi
call   1050 <fremovexattr@plt>
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rsi
call   1050 <fremovexattr@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.array = [5 x i32] [i32 -559038737, i32 2, i32 3, i32 4, i32 5]
@.str = [7 x i8] c"foobar\00"
@.str.1 = [20 x i8] c"user.systemtap.test\00"
@.str.2 = [8 x i8] c"testing\00"
@XATTR_CREATE = global i32 0
@.str.3 = [21 x i8] c"user.systemtap.test2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca [5 x i32]
store i32 0, i32* %1
%5 = bitcast [5 x i32]* %4 to i8*
%6 = call i32 @creat(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 438)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* @XATTR_CREATE
%9 = call i32 (i32, i8*, ...) @fsetxattr(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 %8)
%10 = load i32, i32* %3
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%12 = load i32, i32* @XATTR_CREATE
%13 = call i32 (i32, i8*, ...) @fsetxattr(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32* %11, i64 20, i32 %12)
%14 = load i32, i32* %3
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%16 = call i32 @fgetxattr(i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %15, i64 1024)
%17 = load i32, i32* %3
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%19 = call i32 @flistxattr(i32 %17, i8* %18, i64 1024)
%20 = load i32, i32* %3
%21 = call i32 @fremovexattr(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @XATTR_CREATE
%23 = call i32 (i32, i8*, ...) @fsetxattr(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 %22)
%24 = load i32, i32* %3
%25 = load i32, i32* @XATTR_CREATE
%26 = call i32 (i32, i8*, ...) @fsetxattr(i32 %24, i8* inttoptr (i64 -1 to i8*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 %25)
%27 = load i32, i32* %3
%28 = load i32, i32* @XATTR_CREATE
%29 = call i32 (i32, i8*, ...) @fsetxattr(i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 -1 to i8*), i64 8, i32 %28)
%30 = load i32, i32* %3
%31 = load i32, i32* @XATTR_CREATE
%32 = call i32 (i32, i8*, ...) @fsetxattr(i32 %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* null, i64 -1, i32 %31)
%33 = load i32, i32* %3
%34 = call i32 (i32, i8*, ...) @fsetxattr(i32 %33, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 -1)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%36 = call i32 @fgetxattr(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %35, i64 1024)
%37 = load i32, i32* %3
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%39 = call i32 @fgetxattr(i32 %37, i8* inttoptr (i64 -1 to i8*), i8* %38, i64 1024)
%40 = load i32, i32* %3
%41 = call i32 @fgetxattr(i32 %40, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 -1 to i8*), i64 1024)
%42 = load i32, i32* %3
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%44 = call i32 @fgetxattr(i32 %42, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %43, i64 -1)
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%46 = call i32 @flistxattr(i32 -1, i8* %45, i64 1024)
%47 = load i32, i32* %3
%48 = call i32 @flistxattr(i32 %47, i8* inttoptr (i64 -1 to i8*), i64 1024)
%49 = load i32, i32* %3
%50 = call i32 @flistxattr(i32 %49, i8* null, i64 -1)
%51 = call i32 @fremovexattr(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%52 = load i32, i32* %3
%53 = call i32 @fremovexattr(i32 %52, i8* inttoptr (i64 -1 to i8*))
%54 = load i32, i32* %3
%55 = call i32 @close(i32 %54)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = [5 x i32] [i32 -559038737, i32 2, i32 3, i32 4, i32 5]
@.str = [7 x i8] c"foobar\00"
@.str.1 = [20 x i8] c"user.systemtap.test\00"
@.str.2 = [8 x i8] c"testing\00"
@XATTR_CREATE = global i32 0
@.str.3 = [21 x i8] c"user.systemtap.test2\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [5 x i32]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = bitcast [5 x i32]* %2 to i8*
%5 = tail call i32 @creat(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 438)
%6 = load i32, i32* @XATTR_CREATE
%7 = tail call i32 (i32, i8*, ...) @fsetxattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 %6)
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%9 = load i32, i32* @XATTR_CREATE
%10 = call i32 (i32, i8*, ...) @fsetxattr(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32* %8, i64 20, i32 %9)
%11 = call i32 @fgetxattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %3, i64 1024)
%12 = call i32 @flistxattr(i32 %5, i8* %3, i64 1024)
%13 = call i32 @fremovexattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @XATTR_CREATE
%15 = call i32 (i32, i8*, ...) @fsetxattr(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 %14)
%16 = load i32, i32* @XATTR_CREATE
%17 = call i32 (i32, i8*, ...) @fsetxattr(i32 %5, i8* inttoptr (i64 -1 to i8*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 %16)
%18 = load i32, i32* @XATTR_CREATE
%19 = call i32 (i32, i8*, ...) @fsetxattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 -1 to i8*), i64 8, i32 %18)
%20 = load i32, i32* @XATTR_CREATE
%21 = call i32 (i32, i8*, ...) @fsetxattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* null, i64 -1, i32 %20)
%22 = call i32 (i32, i8*, ...) @fsetxattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 8, i32 -1)
%23 = call i32 @fgetxattr(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %3, i64 1024)
%24 = call i32 @fgetxattr(i32 %5, i8* inttoptr (i64 -1 to i8*), i8* %3, i64 1024)
%25 = call i32 @fgetxattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 -1 to i8*), i64 1024)
%26 = call i32 @fgetxattr(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %3, i64 -1)
%27 = call i32 @flistxattr(i32 -1, i8* %3, i64 1024)
%28 = call i32 @flistxattr(i32 %5, i8* inttoptr (i64 -1 to i8*), i64 1024)
%29 = call i32 @flistxattr(i32 %5, i8* null, i64 -1)
%30 = call i32 @fremovexattr(i32 -1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @fremovexattr(i32 %5, i8* inttoptr (i64 -1 to i8*))
%32 = call i32 @close(i32 %5)
ret i32 0
}