#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 */
struct yaffs_obj {
  int dummy;
};

/* Variables and functions */
int yaffs_remove_xattrib(struct yaffs_obj *, char const *);
scalar_t__ yaffsfs_CheckMemRegion(char const *, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
struct yaffs_obj *yaffsfs_HandleToObject(int);
int /*<<< orphan*/ yaffsfs_Lock();
int /*<<< orphan*/ yaffsfs_SetError(int);
int /*<<< orphan*/ yaffsfs_Unlock();
int yaffs_fremovexattr(int fd, const char *name) {
  struct yaffs_obj *obj;
  int retVal = -1;
  if (yaffsfs_CheckMemRegion(name, 0, 0) < 0) {
    yaffsfs_SetError(-14);
    return -1;
  }
  yaffsfs_Lock();
  obj = yaffsfs_HandleToObject(fd);
  if (obj) {
    retVal = yaffs_remove_xattrib(obj, name);
    if (retVal < 0) {
      yaffsfs_SetError(retVal);
      retVal = -1;
    }
  } else
    yaffsfs_SetError(-9);
  yaffsfs_Unlock();
  return retVal;
}


x86 assembly (clang, -O0):
<yaffs_fremovexattr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <yaffsfs_CheckMemRegion@plt>
cmp    $0x0,%rax
jge    11a3 <yaffs_fremovexattr+0x43>
mov    $0xfffffff2,%edi
call   1050 <yaffsfs_SetError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1206 <yaffs_fremovexattr+0xa6>
mov    $0x0,%al
call   1070 <yaffsfs_Lock@plt>
mov    -0x8(%rbp),%edi
call   1060 <yaffsfs_HandleToObject@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ef <yaffs_fremovexattr+0x8f>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <yaffs_remove_xattrib@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11ea <yaffs_fremovexattr+0x8a>
mov    -0x1c(%rbp),%edi
call   1050 <yaffsfs_SetError@plt>
movl   $0xffffffff,-0x1c(%rbp)
jmp    11f9 <yaffs_fremovexattr+0x99>
mov    $0xfffffff7,%edi
call   1050 <yaffsfs_SetError@plt>
mov    $0x0,%al
call   1030 <yaffsfs_Unlock@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yaffs_fremovexattr>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <yaffsfs_CheckMemRegion@plt>
test   %rax,%rax
js     119f <yaffs_fremovexattr+0x3f>
xor    %eax,%eax
call   1070 <yaffsfs_Lock@plt>
mov    %ebp,%edi
call   1060 <yaffsfs_HandleToObject@plt>
test   %rax,%rax
je     11b0 <yaffs_fremovexattr+0x50>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1080 <yaffs_remove_xattrib@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11c1 <yaffs_fremovexattr+0x61>
jmp    11b5 <yaffs_fremovexattr+0x55>
mov    $0xfffffff2,%edi
call   1050 <yaffsfs_SetError@plt>
mov    $0xffffffff,%ebx
jmp    11c8 <yaffs_fremovexattr+0x68>
mov    $0xfffffff7,%ebx
mov    %ebx,%edi
call   1050 <yaffsfs_SetError@plt>
mov    $0xffffffff,%ebx
xor    %eax,%eax
call   1030 <yaffsfs_Unlock@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.yaffs_obj = type { i32 }
define i32 @yaffs_fremovexattr(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.yaffs_obj*
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 -1, i32* %7
%8 = load i8*, i8** %5
%9 = call i64 @yaffsfs_CheckMemRegion(i8* %8, i32 0, i32 0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @yaffsfs_SetError(i32 -14)
store i32 -1, i32* %3
br label %34
13: ; preds = %2
%14 = call i32 (...) @yaffsfs_Lock()
%15 = load i32, i32* %4
%16 = call %struct.yaffs_obj* @yaffsfs_HandleToObject(i32 %15)
store %struct.yaffs_obj* %16, %struct.yaffs_obj** %6
%17 = load %struct.yaffs_obj*, %struct.yaffs_obj** %6
%18 = icmp ne %struct.yaffs_obj* %17, null
br i1 %18, label %19, label %29
19: ; preds = %13
%20 = load %struct.yaffs_obj*, %struct.yaffs_obj** %6
%21 = load i8*, i8** %5
%22 = call i32 @yaffs_remove_xattrib(%struct.yaffs_obj* %20, i8* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* %7
%27 = call i32 @yaffsfs_SetError(i32 %26)
store i32 -1, i32* %7
br label %28
28: ; preds = %25, %19
br label %31
29: ; preds = %13
%30 = call i32 @yaffsfs_SetError(i32 -9)
br label %31
31: ; preds = %29, %28
%32 = call i32 (...) @yaffsfs_Unlock()
%33 = load i32, i32* %7
store i32 %33, i32* %3
br label %34
34: ; preds = %31, %11
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
%struct.yaffs_obj = type { i32 }
define i32 @yaffs_fremovexattr(i32 %0, i8* %1) {
%3 = tail call i64 @yaffsfs_CheckMemRegion(i8* %1, i32 0, i32 0)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @yaffsfs_SetError(i32 -14)
br label %20
7: ; preds = %2
%8 = tail call i32 (...) @yaffsfs_Lock()
%9 = tail call %struct.yaffs_obj* @yaffsfs_HandleToObject(i32 %0)
%10 = icmp eq %struct.yaffs_obj* %9, null
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call i32 @yaffs_remove_xattrib(%struct.yaffs_obj* %9, i8* %1)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %7, %11
%15 = phi i32 [ %12, %11 ], [ -9, %7 ]
%16 = tail call i32 @yaffsfs_SetError(i32 %15)
br label %17
17: ; preds = %14, %11
%18 = phi i32 [ %12, %11 ], [ -1, %14 ]
%19 = tail call i32 (...) @yaffsfs_Unlock()
br label %20
20: ; preds = %17, %5
%21 = phi i32 [ -1, %5 ], [ %18, %17 ]
ret i32 %21
}