#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 */
scalar_t__ EEXIST;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, scalar_t__);
int /*<<< orphan*/ stderr;
scalar_t__ symlink(char const *, char const *);
int create_symlink(const char *source, const char *target) {
  if (symlink(source, target) != 0 && errno != EEXIST) {
    fprintf(stderr, "Cannot create symlink %s --> %s (error code %d)\n", source,
            target, errno);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<create_symlink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <symlink@plt>
cmp    $0x0,%rax
je     1194 <create_symlink+0x74>
mov    0x2e82(%rip),%rax
mov    (%rax),%rax
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%rax
je     1194 <create_symlink+0x74>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    0x2e57(%rip),%rax
mov    (%rax),%r8
lea    0xe7d(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <create_symlink+0x7b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_symlink>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <symlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     116f <create_symlink+0x4f>
mov    0x2e90(%rip),%rcx
mov    (%rcx),%r8
mov    0x2e96(%rip),%rcx
cmp    (%rcx),%r8
je     116f <create_symlink+0x4f>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@errno = global i64 0
@EEXIST = global i64 0
@stderr = global i32 0
@.str = [49 x i8] c"Cannot create symlink %s --> %s (error code %d)\0A\00"
define i32 @create_symlink(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = load i8*, i8** %5
%8 = call i64 @symlink(i8* %6, i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = load i64, i64* @errno
%12 = load i64, i64* @EEXIST
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = load i64, i64* @errno
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i64 %18)
store i32 -1, i32* %3
br label %21
20: ; preds = %10, %2
store i32 0, i32* %3
br label %21
21: ; preds = %20, %14
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@errno = global i64 0
@EEXIST = global i64 0
@stderr = global i32 0
@.str = [49 x i8] c"Cannot create symlink %s --> %s (error code %d)\0A\00"
define i32 @create_symlink(i8* %0, i8* %1) {
%3 = tail call i64 @symlink(i8* %0, i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = load i64, i64* @errno
%7 = load i64, i64* @EEXIST
%8 = icmp eq i64 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i64 %6)
br label %12
12: ; preds = %2, %5, %9
%13 = phi i32 [ -1, %9 ], [ 0, %5 ], [ 0, %2 ]
ret i32 %13
}