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

/* Variables and functions */
int AT_FDCWD;
int /*<<< orphan*/ EBADF;
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ENOSYS;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int renameat(int oldfd, const char *old, int newfd, const char *new) {
  if ((oldfd < 0 && oldfd != AT_FDCWD) || (newfd < 0 && newfd != AT_FDCWD)) {
    __set_errno(EBADF);
    return -1;
  }
  if (old == NULL || new == NULL) {
    __set_errno(EINVAL);
    return -1;
  }
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<renameat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1142 <renameat+0x32>
mov    -0x8(%rbp),%eax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%eax
jne    115e <renameat+0x4e>
cmpl   $0x0,-0x14(%rbp)
jge    1178 <renameat+0x68>
mov    -0x14(%rbp),%eax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%eax
je     1178 <renameat+0x68>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <renameat+0xad>
cmpq   $0x0,-0x10(%rbp)
je     118e <renameat+0x7e>
cmpq   $0x0,-0x20(%rbp)
jne    11a8 <renameat+0x98>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <renameat+0xad>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<renameat>:
push   %rax
mov    0x2ea8(%rip),%rax
mov    (%rax),%eax
mov    0x2eaf(%rip),%r8
test   %edi,%edi
jns    1129 <renameat+0x19>
cmp    %edi,%eax
jne    114e <renameat+0x3e>
test   %edx,%edx
jns    1131 <renameat+0x21>
cmp    %edx,%eax
jne    114e <renameat+0x3e>
mov    0x2ea0(%rip),%rax
mov    %rax,%r8
test   %rcx,%rcx
je     1147 <renameat+0x37>
mov    0x2ea1(%rip),%r8
test   %rsi,%rsi
cmove  %rax,%r8
mov    (%r8),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

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

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