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

/* Variables and functions */
int getxattr(char const *, char const *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void print_xattrib_val(const char *path, const char *name) {
  char buffer[100];
  int n;
  n = getxattr(path, name, buffer, sizeof(buffer));
  if (n >= 0) {
    uint8_t *b = (uint8_t *)buffer;
    printf("%d bytes:", n);
    while (n > 0) {
      printf("[%02X]", *b);
      b++;
      n--;
    }
    printf("\n");
  } else
    printf(" Novalue result %d\n", n);
}


x86 assembly (clang, -O0):
<print_xattrib_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x80(%rbp),%rdx
mov    $0x64,%ecx
call   1040 <getxattr@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jl     11d8 <print_xattrib_val+0xb8>
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x84(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x84(%rbp)
jle    11c5 <print_xattrib_val+0xa5>
mov    -0x90(%rbp),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x90(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x90(%rbp)
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x84(%rbp)
jmp    117b <print_xattrib_val+0x5b>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_xattrib_val+0xcc>
mov    -0x84(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_xattrib_val>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdx
mov    $0x64,%ecx
call   1050 <getxattr@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1194 <print_xattrib_val+0x64>
lea    0xeab(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
je     1188 <print_xattrib_val+0x58>
add    $0x1,%ebp
lea    0xe9e(%rip),%r14
nopl   0x0(%rax)
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x4,%rbx
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1170 <print_xattrib_val+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a4 <print_xattrib_val+0x74>
lea    0xe76(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%d bytes:\00"
@.str.1 = [7 x i8] c"[%02X]\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [20 x i8] c" Novalue result %d\0A\00"
define void @print_xattrib_val(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%11 = call i32 @getxattr(i8* %8, i8* %9, i8* %10, i32 100)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %32
14: ; preds = %2
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%16 = bitcast i8* %15 to i32*
store i32* %16, i32** %7
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %22, %14
%20 = load i32, i32* %6
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %7
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %7
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
br label %19
30: ; preds = %19
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
32: ; preds = %2
%33 = load i32, i32* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %30
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d bytes:\00"
@.str.1 = [7 x i8] c"[%02X]\00"
@.str.3 = [20 x i8] c" Novalue result %d\0A\00"
define void @print_xattrib_val(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @getxattr(i8* %0, i8* %1, i8* %4, i32 100)
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %22
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5)
%9 = icmp eq i32 %5, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = bitcast [100 x i8]* %3 to i32*
br label %12
12: ; preds = %10, %12
%13 = phi i32* [ %17, %12 ], [ %11, %10 ]
%14 = phi i32 [ %18, %12 ], [ %5, %10 ]
%15 = load i32, i32* %13
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %13, i64 1
%18 = add nsw i32 %14, -1
%19 = icmp ugt i32 %14, 1
br i1 %19, label %12, label %20
20: ; preds = %12, %7
%21 = call i32 @putchar(i32 10)
br label %24
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %24
24: ; preds = %22, %20
ret void
}