#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 /*<<< orphan*/ get_dev_and_path(char *, short *, short *, char *);
int mx_symlink(short, char *, char *);
int /*<<< orphan*/ relpath_to_abspath(char const *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int u_symlink(const char *path, const char *path2) {
  char localpath2[256], abspath2[256];
  short device2, fs2;
  if (*path2 != '/')
    relpath_to_abspath(path2, abspath2);
  else
    strncpy(abspath2, path2, 256);
  get_dev_and_path(abspath2, &device2, &fs2, (char *)&localpath2);
  if (fs2 != 1)
    return -1;
  return mx_symlink(device2, (char *)path, localpath2);
}


x86 assembly (clang, -O0):
<u_symlink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1178 <u_symlink+0x38>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1050 <relpath_to_abspath@plt>
jmp    118d <u_symlink+0x4d>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rcx
lea    -0x222(%rbp),%rsi
lea    -0x224(%rbp),%rdx
call   1060 <get_dev_and_path@plt>
movswl -0x224(%rbp),%eax
cmp    $0x1,%eax
je     11ca <u_symlink+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <u_symlink+0xa7>
mov    -0x222(%rbp),%ax
mov    -0x10(%rbp),%rsi
lea    -0x120(%rbp),%rdx
movswl %ax,%edi
call   1040 <mx_symlink@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<u_symlink>:
push   %rbx
sub    $0x210,%rsp
mov    %rdi,%rbx
cmpb   $0x2f,(%rsi)
jne    1161 <u_symlink+0x21>
lea    0x10(%rsp),%rdi
mov    $0x100,%edx
call   1030 <strncpy@plt>
jmp    1171 <u_symlink+0x31>
lea    0x10(%rsp),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1050 <relpath_to_abspath@plt>
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x110(%rsp),%rcx
call   1060 <get_dev_and_path@plt>
mov    $0xffffffff,%eax
cmpw   $0x1,0xc(%rsp)
jne    11af <u_symlink+0x6f>
movswl 0xe(%rsp),%edi
lea    0x110(%rsp),%rdx
mov    %rbx,%rsi
call   1040 <mx_symlink@plt>
add    $0x210,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @u_symlink(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca i16
%9 = alloca i16
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 47
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%17 = call i32 @relpath_to_abspath(i8* %15, i8* %16)
br label %22
18: ; preds = %2
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%20 = load i8*, i8** %5
%21 = call i32 @strncpy(i8* %19, i8* %20, i32 256)
br label %22
22: ; preds = %18, %14
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%24 = bitcast [256 x i8]* %6 to i8*
%25 = call i32 @get_dev_and_path(i8* %23, i16* %8, i16* %9, i8* %24)
%26 = load i16, i16* %9
%27 = sext i16 %26 to i32
%28 = icmp ne i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %22
store i32 -1, i32* %3
br label %35
30: ; preds = %22
%31 = load i16, i16* %8
%32 = load i8*, i8** %4
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%34 = call i32 @mx_symlink(i16 signext %31, i8* %32, i8* %33)
store i32 %34, i32* %3
br label %35
35: ; preds = %30, %29
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @u_symlink(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca i16
%6 = alloca i16
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = bitcast i16* %5 to i8*
%10 = bitcast i16* %6 to i8*
%11 = load i8, i8* %1
%12 = icmp eq i8 %11, 47
br i1 %12, label %15, label %13
13: ; preds = %2
%14 = call i32 @relpath_to_abspath(i8* %1, i8* %8)
br label %17
15: ; preds = %2
%16 = call i32 @strncpy(i8* %8, i8* %1, i32 256)
br label %17
17: ; preds = %15, %13
%18 = call i32 @get_dev_and_path(i8* %8, i16* %5, i16* %6, i8* %7)
%19 = load i16, i16* %6
%20 = icmp eq i16 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i16, i16* %5
%23 = call i32 @mx_symlink(i16 signext %22, i8* %0, i8* %7)
br label %24
24: ; preds = %17, %21
%25 = phi i32 [ %23, %21 ], [ -1, %17 ]
ret i32 %25
}