#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 link(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int ret;
  ret = link("test1/test1.txt", "test1_hlnk");
  if (ret == 0) {
    printf("create test1_hlnk success!\n");
    return 0;
  } else {
    printf("create test1_hlnk failed!\n");
    perror("link");
    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   1050 <link@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1177 <main+0x47>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1196 <main+0x66>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
call   1040 <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   1050 <link@plt>
test   %eax,%eax
jne    1158 <main+0x28>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"test1/test1.txt\00"
@.str.1 = [11 x i8] c"test1_hlnk\00"
@.str.2 = [28 x i8] c"create test1_hlnk success!\0A\00"
@.str.3 = [27 x i8] c"create test1_hlnk failed!\0A\00"
@.str.4 = [5 x i8] c"link\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @link(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 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 ([28 x i8], [28 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 ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 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 = [11 x i8] c"test1_hlnk\00"
@.str.4 = [5 x i8] c"link\00"
@str = [26 x i8] c"create test1_hlnk failed!\00"
@str.5 = [27 x i8] c"create test1_hlnk success!\00"
define i32 @main() {
%1 = tail call i32 @link(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 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 ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
br label %8
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 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
}