#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 stat64 {
  int dummy;
};

/* Variables and functions */
int AT_FDCWD;
int AT_SYMLINK_NOFOLLOW;
int /*<<< orphan*/ EBADF;
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ENOSYS;
int _STAT_VER;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int __fxstatat64(int vers, int fd, const char *filename, struct stat64 *buf,
                 int flag) {
  if (vers != _STAT_VER) {
    __set_errno(EINVAL);
    return -1;
  }
  if (fd < 0 && fd != AT_FDCWD) {
    __set_errno(EBADF);
    return -1;
  }
  if (buf == NULL || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) {
    __set_errno(EINVAL);
    return -1;
  }
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<__fxstatat64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ea4(%rip),%rcx
cmp    (%rcx),%eax
je     1156 <__fxstatat64+0x46>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e0 <__fxstatat64+0xd0>
cmpl   $0x0,-0xc(%rbp)
jge    118c <__fxstatat64+0x7c>
mov    -0xc(%rbp),%eax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%eax
je     118c <__fxstatat64+0x7c>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e0 <__fxstatat64+0xd0>
cmpq   $0x0,-0x20(%rbp)
je     11b1 <__fxstatat64+0xa1>
mov    -0x24(%rbp),%eax
mov    0x2e1f(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11cb <__fxstatat64+0xbb>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e0 <__fxstatat64+0xd0>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__fxstatat64>:
push   %rax
mov    0x2ec0(%rip),%rdx
mov    0x2eb1(%rip),%rax
cmp    %edi,(%rdx)
jne    1160 <__fxstatat64+0x50>
test   %esi,%esi
jns    113b <__fxstatat64+0x2b>
mov    0x2e82(%rip),%rdx
cmp    %esi,(%rdx)
je     113b <__fxstatat64+0x2b>
mov    0x2e8f(%rip),%rax
jmp    1160 <__fxstatat64+0x50>
test   %rcx,%rcx
je     1160 <__fxstatat64+0x50>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
not    %eax
test   %r8d,%eax
jne    1159 <__fxstatat64+0x49>
mov    0x2e91(%rip),%rax
jmp    1160 <__fxstatat64+0x50>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat64 = type { i32 }
@_STAT_VER = global i32 0
@EINVAL = global i32 0
@AT_FDCWD = global i32 0
@EBADF = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@ENOSYS = global i32 0
define i32 @__fxstatat64(i32 %0, i32 %1, i8* %2, %struct.stat64* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca %struct.stat64*
%11 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store %struct.stat64* %3, %struct.stat64** %10
store i32 %4, i32* %11
%12 = load i32, i32* %7
%13 = load i32, i32* @_STAT_VER
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = load i32, i32* @EINVAL
%17 = call i32 @__set_errno(i32 %16)
store i32 -1, i32* %6
br label %43
18: ; preds = %5
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %8
%23 = load i32, i32* @AT_FDCWD
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* @EBADF
%27 = call i32 @__set_errno(i32 %26)
store i32 -1, i32* %6
br label %43
28: ; preds = %21, %18
%29 = load %struct.stat64*, %struct.stat64** %10
%30 = icmp eq %struct.stat64* %29, null
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = load i32, i32* %11
%33 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%34 = xor i32 %33, -1
%35 = and i32 %32, %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %31, %28
%38 = load i32, i32* @EINVAL
%39 = call i32 @__set_errno(i32 %38)
store i32 -1, i32* %6
br label %43
40: ; preds = %31
%41 = load i32, i32* @ENOSYS
%42 = call i32 @__set_errno(i32 %41)
store i32 -1, i32* %6
br label %43
43: ; preds = %40, %37, %25, %15
%44 = load i32, i32* %6
ret i32 %44
}

LLVM IR (-O2):
%struct.stat64 = type { i32 }
@_STAT_VER = global i32 0
@EINVAL = global i32 0
@AT_FDCWD = global i32 0
@EBADF = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@ENOSYS = global i32 0
define i32 @__fxstatat64(i32 %0, i32 %1, i8* nocapture readnone %2, %struct.stat64* readnone %3, i32 %4) {
%6 = load i32, i32* @_STAT_VER
%7 = icmp eq i32 %6, %0
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = icmp sgt i32 %1, -1
%10 = load i32, i32* @AT_FDCWD
%11 = icmp eq i32 %10, %1
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = icmp eq %struct.stat64* %3, null
br i1 %14, label %21, label %15
15: ; preds = %13
%16 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%17 = xor i32 %16, -1
%18 = and i32 %17, %4
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i32* @ENOSYS, i32* @EINVAL
br label %21
21: ; preds = %15, %13, %8, %5
%22 = phi i32* [ @EINVAL, %5 ], [ @EBADF, %8 ], [ @EINVAL, %13 ], [ %20, %15 ]
%23 = load i32, i32* %22
%24 = tail call i32 @__set_errno(i32 %23)
ret i32 -1
}