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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ deleteAttr(char *, char *);
int /*<<< orphan*/ errExit(char *);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ listAttrs(char *, void *, int);
void *malloc(int);
int /*<<< orphan*/ setattr_testattr();
scalar_t__ strcmp(char *, char *);
ssize_t setattr_name() {
  void *data = malloc(128);
  if (data == NULL) {
    errExit("test: malloc listAttrs buffer");
  }
  for (size_t i = 0; i < 128; i++) {
    ((char *)data)[i] = '\0';
  }
  setattr_testattr();
  listAttrs("testFile", data, 128);
  ssize_t ret = EXIT_FAILURE;
  if (strcmp("ctest_testing", (char *)data) == 0)
    ret = EXIT_SUCCESS;
  free(data);
  data = NULL;
  deleteAttr("testFile", "ctest_testing");
  return ret;
}


x86 assembly (clang, -O0):
<setattr_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x80,%edi
call   1090 <malloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    119d <setattr_name+0x2d>
lea    0xe68(%rip),%rdi
call   1050 <errExit@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x80,-0x10(%rbp)
jae    11d0 <setattr_name+0x60>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a5 <setattr_name+0x35>
mov    $0x0,%al
call   1070 <setattr_testattr@plt>
mov    -0x8(%rbp),%rsi
lea    0xe3c(%rip),%rdi
mov    $0x80,%edx
call   1080 <listAttrs@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe24(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <setattr_name+0xae>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
lea    0xde8(%rip),%rdi
lea    0xdea(%rip),%rsi
call   1040 <deleteAttr@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setattr_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x80,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1195 <setattr_name+0x25>
lea    0xe70(%rip),%rdi
call   1050 <errExit@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x70(%rbx)
movups %xmm0,0x60(%rbx)
movups %xmm0,0x50(%rbx)
movups %xmm0,0x40(%rbx)
movups %xmm0,0x30(%rbx)
movups %xmm0,0x20(%rbx)
movups %xmm0,0x10(%rbx)
movups %xmm0,(%rbx)
xor    %eax,%eax
call   1070 <setattr_testattr@plt>
lea    0xe59(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1080 <listAttrs@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%ebp
lea    0xe42(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11fe <setattr_name+0x8e>
mov    0x2ddc(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <deleteAttr@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"test: malloc listAttrs buffer\00"
@.str.1 = [9 x i8] c"testFile\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [14 x i8] c"ctest_testing\00"
@EXIT_SUCCESS = global i32 0
define i32 @setattr_name() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i32
%4 = call i8* @malloc(i32 128)
store i8* %4, i8** %1
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @errExit(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
store i64 0, i64* %2
br label %10
10: ; preds = %17, %9
%11 = load i64, i64* %2
%12 = icmp ult i64 %11, 128
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i8*, i8** %1
%15 = load i64, i64* %2
%16 = getelementptr inbounds i8, i8* %14, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %13
%18 = load i64, i64* %2
%19 = add i64 %18, 1
store i64 %19, i64* %2
br label %10
20: ; preds = %10
%21 = call i32 (...) @setattr_testattr()
%22 = load i8*, i8** %1
%23 = call i32 @listAttrs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %22, i32 128)
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
%25 = load i8*, i8** %1
%26 = call i64 @strcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = load i32, i32* @EXIT_SUCCESS
store i32 %29, i32* %3
br label %30
30: ; preds = %28, %20
%31 = load i8*, i8** %1
%32 = call i32 @free(i8* %31)
store i8* null, i8** %1
%33 = call i32 @deleteAttr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [30 x i8] c"test: malloc listAttrs buffer\00"
@.str.1 = [9 x i8] c"testFile\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [14 x i8] c"ctest_testing\00"
@EXIT_SUCCESS = global i32 0
define i32 @setattr_name() {
%1 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @errExit(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 (...) @setattr_testattr()
%7 = tail call i32 @listAttrs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 128)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i64 @strcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%10 = icmp eq i64 %9, 0
%11 = load i32, i32* @EXIT_SUCCESS
%12 = select i1 %10, i32 %11, i32 %8
%13 = tail call i32 @free(i8* %1)
%14 = tail call i32 @deleteAttr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
ret i32 %12
}