#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*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int symlink(char *, char *);
int /*<<< orphan*/ unlink(char *);
int create_real_link(char *realhome, char *home) {
  int ret;
  char errormsg[2048];
  unlink(home);
  ret = symlink(realhome, home);
  if (ret) {
    snprintf(
        errormsg, 2048,
        "Failed to make link from %s to %s, please report to help@vpac.org",
        home, realhome);
    perror(errormsg);
    exit(-1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<create_real_link>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <symlink@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11bc <create_real_link+0x6c>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    $0x800,%esi
lea    0xe5f(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x820(%rbp),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_real_link>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <unlink@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <symlink@plt>
test   %eax,%eax
jne    1188 <create_real_link+0x38>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe71(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x800,%esi
mov    %rbx,%rcx
mov    %r14,%r8
call   1050 <snprintf@plt>
mov    %r15,%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [66 x i8] c"Failed to make link from %s to %s, please report to help@vpac.org\00"
define i32 @create_real_link(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [2048 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @unlink(i8* %7)
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i32 @symlink(i8* %9, i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = load i8*, i8** %3
%18 = call i32 @snprintf(i8* %15, i32 2048, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17)
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%20 = call i32 @perror(i8* %19)
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
ret i32 0
}

LLVM IR (-O2):
@.str = [66 x i8] c"Failed to make link from %s to %s, please report to help@vpac.org\00"
define i32 @create_real_link(i8* %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @unlink(i8* %1)
%6 = tail call i32 @symlink(i8* %0, i8* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = call i32 @snprintf(i8* %4, i32 2048, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%10 = call i32 @perror(i8* %4)
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
ret i32 0
}