#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*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int symlink(char *, char *);
int main(void) {
  int result;
  result = symlink("test1/test1.txt", "test1_symlink");
  if (result == 0) {
    printf("create test1_symlink success!\n");
    return 0;
  } else {
    printf("create test1_symlink failed!\n");
    perror("symlink");
    return -1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1040 <symlink@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1177 <main+0x47>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1196 <main+0x66>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1040 <symlink@plt>
test   %eax,%eax
jne    1158 <main+0x28>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"test1/test1.txt\00"
@.str.1 = [14 x i8] c"test1_symlink\00"
@.str.2 = [31 x i8] c"create test1_symlink success!\0A\00"
@.str.3 = [30 x i8] c"create test1_symlink failed!\0A\00"
@.str.4 = [8 x i8] c"symlink\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @symlink(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %11
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %11
11: ; preds = %8, %6
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@.str = [16 x i8] c"test1/test1.txt\00"
@.str.1 = [14 x i8] c"test1_symlink\00"
@.str.4 = [8 x i8] c"symlink\00"
@str = [29 x i8] c"create test1_symlink failed!\00"
@str.5 = [30 x i8] c"create test1_symlink success!\00"
define i32 @main() {
%1 = tail call i32 @symlink(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
br label %8
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %8
8: ; preds = %5, %3
%9 = phi i32 [ 0, %3 ], [ -1, %5 ]
ret i32 %9
}