#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*/ printf(char *, char *);
int symlink(char *, char *);
int main(void) {
  char actualpath[] = "symlink.c";
  char sympath[] = "/tmp/mysymlink";
  if (symlink(actualpath, sympath) == -1)
    printf("symlink error for %s\n", sympath);
  else
    printf("symlink succeed for %s\n", sympath);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xec7(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xeb6(%rip),%ax
mov    %ax,-0x11(%rbp)
mov    0xeae(%rip),%al
mov    %al,-0xf(%rbp)
lea    -0xe(%rbp),%rdi
lea    -0x1d(%rbp),%rsi
call   1040 <symlink@plt>
cmp    $0xffffffff,%eax
jne    1198 <main+0x78>
lea    -0x1d(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    11a8 <main+0x88>
lea    -0x1d(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movabs $0x2e6b6e696c6d7973,%rax
6e 6b 2e
mov    %rax,(%rsp)
movw   $0x63,0x8(%rsp)
movabs $0x6b6e696c6d7973,%rax
mov    %rax,0x17(%rsp)
movabs $0x73796d2f706d742f,%rax
6d 79 73
mov    %rax,0x10(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <symlink@plt>
cmp    $0xffffffff,%eax
lea    0xea7(%rip),%rax
lea    0xeb6(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.actualpath = [10 x i8] c"symlink.c\00"
@__const.main.sympath = [15 x i8] c"/tmp/mysymlink\00"
@.str = [22 x i8] c"symlink error for %s\0A\00"
@.str.1 = [24 x i8] c"symlink succeed for %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [15 x i8]
store i32 0, i32* %1
%4 = bitcast [10 x i8]* %2 to i8*
%5 = bitcast [15 x i8]* %3 to i8*
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%8 = call i32 @symlink(i8* %6, i8* %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %16
13: ; preds = %0
%14 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %10
ret i32 0
}

LLVM IR (-O2):
@__const.main.actualpath = [10 x i8] c"symlink.c\00"
@__const.main.sympath = [15 x i8] c"/tmp/mysymlink\00"
@.str = [22 x i8] c"symlink error for %s\0A\00"
@.str.1 = [24 x i8] c"symlink succeed for %s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%5 = call i32 @symlink(i8* %3, i8* %4)
%6 = icmp eq i32 %5, -1
%7 = select i1 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0)
%8 = call i32 @printf(i8* %7, i8* %4)
ret i32 0
}