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


x86 assembly (clang, -O0):
<rename_empty2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <create_testdir@plt>
cmp    $0x0,%rax
jge    115e <rename_empty2+0x1e>
jmp    11aa <rename_empty2+0x6a>
lea    0xe9b(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <rename@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
mov    0x2e40(%rip),%rax
mov    (%rax),%ecx
lea    0xe72(%rip),%r8
call   1030 <report_test2@plt>
lea    0xe5b(%rip),%rdi
call   1040 <rmdir@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rename_empty2>:
push   %rbx
xor    %eax,%eax
call   1060 <create_testdir@plt>
test   %rax,%rax
js     1195 <rename_empty2+0x55>
lea    0xeac(%rip),%rbx
lea    0xec6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <rename@plt>
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e75(%rip),%rcx
mov    (%rcx),%edx
mov    0x2e54(%rip),%rcx
mov    (%rcx),%ecx
lea    0xe86(%rip),%r8
mov    %eax,%edi
call   1030 <report_test2@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
@EISDIR = global i32 0
@EINVAL = global i32 0
@.str.2 = [23 x i8] c"rename to empty string\00"
define void @rename_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 %13
5: ; preds = %0
%6 = call i32 @rename(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* @EISDIR
%10 = load i32, i32* @EINVAL
%11 = call i32 @report_test2(i32 %7, i32 %8, i32 %9, i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @rmdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; 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
@EISDIR = global i32 0
@EINVAL = global i32 0
@.str.2 = [23 x i8] c"rename to empty string\00"
define void @rename_empty2() {
%1 = tail call i64 (...) @create_testdir()
%2 = icmp slt i64 %1, 0
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i32 @rename(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* @EISDIR
%7 = load i32, i32* @EINVAL
%8 = tail call i32 @report_test2(i32 %4, i32 %5, i32 %6, i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @rmdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %0, %3
ret void
}