#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 */
int BUFSIZ;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ helpAndLeave(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pexit(char *);
int setxattr(char *, char *, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  if (argc != 4) {
    helpAndLeave(argv[0], EXIT_FAILURE);
  }
  char ea_name[BUFSIZ];
  char *name, *value, *file;
  name = argv[1];
  value = argv[2];
  file = argv[3];
  snprintf(ea_name, BUFSIZ, "user.%s", name);
  if (setxattr(file, ea_name, value, strlen(ea_name), 0) == -1) {
    pexit("setxattr");
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1195 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
call   1050 <helpAndLeave@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rcx
lea    0xe07(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1070 <setxattr@plt>
cmp    $0xffffffff,%eax
jne    1242 <main+0xe2>
lea    0xdcb(%rip),%rdi
call   1080 <pexit@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x4,%edi
je     1183 <main+0x23>
mov    (%r14),%rdi
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
call   1050 <helpAndLeave@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x8(%r14),%rcx
mov    0x10(%r14),%r15
mov    0x18(%r14),%r14
lea    0xe4d(%rip),%rdx
mov    %rbx,%rdi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1070 <setxattr@plt>
cmp    $0xffffffff,%eax
jne    11e7 <main+0x87>
lea    0xe26(%rip),%rdi
call   1080 <pexit@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@BUFSIZ = global i32 0
@.str = [8 x i8] c"user.%s\00"
@.str.1 = [9 x i8] c"setxattr\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 4
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @helpAndLeave(i8* %16, i32 %17)
br label %19
19: ; preds = %13, %2
%20 = load i32, i32* @BUFSIZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %6
%23 = alloca i8, i64 %21
store i64 %21, i64* %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %8
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
store i8* %29, i8** %9
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
store i8* %32, i8** %10
%33 = load i32, i32* @BUFSIZ
%34 = load i8*, i8** %8
%35 = call i32 @snprintf(i8* %23, i32 %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %10
%37 = load i8*, i8** %9
%38 = call i32 @strlen(i8* %23)
%39 = call i32 @setxattr(i8* %36, i8* %23, i8* %37, i32 %38, i32 0)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %19
%42 = call i32 @pexit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %41, %19
%44 = load i32, i32* @EXIT_SUCCESS
%45 = call i32 @exit(i32 %44)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@BUFSIZ = global i32 0
@.str = [8 x i8] c"user.%s\00"
@.str.1 = [9 x i8] c"setxattr\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @helpAndLeave(i8* %5, i32 %6)
br label %8
8: ; preds = %4, %2
%9 = load i32, i32* @BUFSIZ
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = call i32 @snprintf(i8* %11, i32 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %13)
%19 = call i32 @strlen(i8* %11)
%20 = call i32 @setxattr(i8* %17, i8* %11, i8* %15, i32 %19, i32 0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %8
%23 = call i32 @pexit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %8
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
}