#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 symlinkat(const char *from, int fd, const char *to) {
  if (from == NULL || to == NULL) {
    __set_errno(EINVAL);
    return -1;
  }
  if (fd != AT_FDCWD && fd < 0 && *to != '/') {
    __set_errno(EBADF);
    return -1;
  }
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<symlinkat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1139 <symlinkat+0x29>
cmpq   $0x0,-0x20(%rbp)
jne    1153 <symlinkat+0x43>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <symlinkat+0x9e>
mov    -0x14(%rbp),%eax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%eax
je     1199 <symlinkat+0x89>
cmpl   $0x0,-0x14(%rbp)
jge    1199 <symlinkat+0x89>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1199 <symlinkat+0x89>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <symlinkat+0x9e>
mov    0x2e48(%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):
<symlinkat>:
push   %rax
mov    0x2ec0(%rip),%rax
test   %rdi,%rdi
je     1146 <symlinkat+0x36>
test   %rdx,%rdx
je     1146 <symlinkat+0x36>
test   %esi,%esi
jns    1136 <symlinkat+0x26>
mov    0x2e93(%rip),%rax
cmp    %esi,(%rax)
je     1136 <symlinkat+0x26>
cmpb   $0x2f,(%rdx)
jne    113f <symlinkat+0x2f>
mov    0x2eab(%rip),%rax
jmp    1146 <symlinkat+0x36>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

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

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