#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*/ EINVAL;
scalar_t__ create_testdir();
int /*<<< orphan*/ errno;
int link(char *, char *);
int /*<<< orphan*/ report_test(int, int /*<<< orphan*/, int /*<<< orphan*/,
                               char *);
int /*<<< orphan*/ rmdir(char *);
void link_empty2(void) {
  int rv;
  if (create_testdir() < 0) {
    return;
  }
  rv = link("badcalldir", "");
  report_test(rv, errno, EINVAL, "hard link to empty string");
  rmdir("badcalldir");
}


x86 assembly (clang, -O0):
<link_empty2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <create_testdir@plt>
cmp    $0x0,%rax
jge    115e <link_empty2+0x1e>
jmp    11a1 <link_empty2+0x61>
lea    0xe9b(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <link@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
lea    0xe7b(%rip),%rcx
call   1030 <report_test@plt>
lea    0xe64(%rip),%rdi
call   1040 <rmdir@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<link_empty2>:
push   %rbx
xor    %eax,%eax
call   1050 <create_testdir@plt>
test   %rax,%rax
js     118c <link_empty2+0x4c>
lea    0xeac(%rip),%rbx
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1060 <link@plt>
mov    0x2e76(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e65(%rip),%rcx
mov    (%rcx),%edx
lea    0xe8f(%rip),%rcx
mov    %eax,%edi
call   1030 <report_test@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <rmdir@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"badcalldir\00"
@.str.1 = [1 x i8] zeroinitializer
@errno = global i32 0
@EINVAL = global i32 0
@.str.2 = [26 x i8] c"hard link to empty string\00"
define void @link_empty2() {
%1 = alloca i32
%2 = call i64 (...) @create_testdir()
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
br label %12
5: ; preds = %0
%6 = call i32 @link(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = load i32, i32* @errno
%9 = load i32, i32* @EINVAL
%10 = call i32 @report_test(i32 %7, i32 %8, i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @rmdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %5, %4
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"badcalldir\00"
@.str.1 = [1 x i8] zeroinitializer
@errno = global i32 0
@EINVAL = global i32 0
@.str.2 = [26 x i8] c"hard link to empty string\00"
define void @link_empty2() {
%1 = tail call i64 (...) @create_testdir()
%2 = icmp slt i64 %1, 0
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i32 @link(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @errno
%6 = load i32, i32* @EINVAL
%7 = tail call i32 @report_test(i32 %4, i32 %5, i32 %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @rmdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %0, %3
ret void
}