#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*/ retention;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ errno;
int lsetxattr(char *, char *, unsigned short *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, unsigned short *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  unsigned short retention;
  int status;
  char *path;
  if (argc < 3) {
    printf("Bad arguments, expected syntax: setretention <path> <retention "
           "days>\n");
    return 0;
  }
  status = sscanf(argv[2], "%hu", &retention);
  if (status == EOF) {
    printf("Bad arguments, expected syntax: setretention <path> <retention "
           "days>\n");
    return 0;
  }
  path = argv[1];
  status = lsetxattr(path, "user.Retention", &retention, sizeof(retention), 0);
  if (status < 0) {
    printf("Cannot set retention: %s\n", strerror(errno));
  } else {
    printf("Retention set\n");
  }
  return 0;
}


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   $0x3,-0x8(%rbp)
jge    117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122f <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xebd(%rip),%rsi
lea    -0x12(%rbp),%rdx
call   1040 <sscanf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%eax
jne    11c1 <main+0x81>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122f <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe72(%rip),%rsi
lea    -0x12(%rbp),%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1050 <lsetxattr@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    121a <main+0xda>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <main+0xe8>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jle    117d <main+0x2d>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
lea    0xe98(%rip),%rsi
lea    0xe(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x2e6f(%rip),%rcx
cmp    (%rcx),%eax
jne    1191 <main+0x41>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x8(%rbx),%rdi
lea    0xe68(%rip),%rsi
lea    0xe(%rsp),%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1060 <lsetxattr@plt>
test   %eax,%eax
js     11bb <main+0x6b>
lea    0xe74(%rip),%rdi
jmp    1184 <main+0x34>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe43(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1189 <main+0x39>

LLVM IR (-O0):
@.str = [70 x i8] c"Bad arguments, expected syntax: setretention <path> <retention days>\0A\00"
@.str.1 = [4 x i8] c"%hu\00"
@EOF = global i32 0
@.str.2 = [15 x i8] c"user.Retention\00"
@.str.3 = [26 x i8] c"Cannot set retention: %s\0A\00"
@errno = global i32 0
@.str.4 = [15 x i8] c"Retention set\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca i32
%8 = alloca i8*
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, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %38
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %6)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %38
23: ; preds = %13
%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** %8
%28 = call i32 @lsetxattr(i8* %27, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i16* %6, i32 2, i32 0)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %23
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %37
35: ; preds = %23
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
store i32 0, i32* %3
br label %38
38: ; preds = %37, %21, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%hu\00"
@EOF = global i32 0
@.str.2 = [15 x i8] c"user.Retention\00"
@.str.3 = [26 x i8] c"Cannot set retention: %s\0A\00"
@errno = global i32 0
@str = [14 x i8] c"Retention set\00"
@str.6 = [69 x i8] c"Bad arguments, expected syntax: setretention <path> <retention days>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.6, i64 0, i64 0))
br label %27
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i16* %3)
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.6, i64 0, i64 0))
br label %27
16: ; preds = %8
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @lsetxattr(i8* %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i16* %3, i32 2, i32 0)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %27
25: ; preds = %16
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %21, %25, %14, %6
ret i32 0
}