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


x86 assembly (clang, -O0):
<rename_empty1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeef(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1040 <rename@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
mov    0x2e76(%rip),%rax
mov    (%rax),%ecx
lea    0xea8(%rip),%r8
call   1030 <report_test2@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1185 <rename_empty1+0x65>
lea    0xe87(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <rename@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rename_empty1>:
push   %rbx
lea    0xef6(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1040 <rename@plt>
mov    %eax,%ebx
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
mov    0x2ea2(%rip),%rax
mov    (%rax),%edx
mov    0x2e81(%rip),%rax
mov    (%rax),%ecx
lea    0xeb3(%rip),%r8
mov    %ebx,%edi
call   1030 <report_test2@plt>
test   %ebx,%ebx
je     1165 <rename_empty1+0x45>
pop    %rbx
ret
lea    0xe94(%rip),%rdi
lea    0xeac(%rip),%rsi
pop    %rbx
jmp    1040 <rename@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [11 x i8] c"badcalldir\00"
@errno = global i32 0
@EISDIR = global i32 0
@EINVAL = global i32 0
@.str.2 = [20 x i8] c"rename empty string\00"
@.str.3 = [15 x i8] c"badcalldir-foo\00"
define void @rename_empty1() {
%1 = alloca i32
%2 = call i32 @rename(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = load i32, i32* @errno
%5 = load i32, i32* @EISDIR
%6 = load i32, i32* @EINVAL
%7 = call i32 @report_test2(i32 %3, i32 %4, i32 %5, i32 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @rename(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [11 x i8] c"badcalldir\00"
@errno = global i32 0
@EISDIR = global i32 0
@EINVAL = global i32 0
@.str.2 = [20 x i8] c"rename empty string\00"
@.str.3 = [15 x i8] c"badcalldir-foo\00"
define void @rename_empty1() {
%1 = tail call i32 @rename(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%2 = load i32, i32* @errno
%3 = load i32, i32* @EISDIR
%4 = load i32, i32* @EINVAL
%5 = tail call i32 @report_test2(i32 %1, i32 %2, i32 %3, i32 %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @rename(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
ret void
}