#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*/ errno;
int rename(char *, char *);
int /*<<< orphan*/ report_test(int, int /*<<< orphan*/, int /*<<< orphan*/,
                               char *);
void rename_dot(void) {
  int rv;
  rv = rename(".", "badcalldir");
  report_test(rv, errno, EINVAL, "rename .");
  if (rv == 0) {
    rename("badcalldir", ".");
  }
}


x86 assembly (clang, -O0):
<rename_dot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee3(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1040 <rename@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
lea    0xeb1(%rip),%rcx
call   1030 <report_test@plt>
cmpl   $0x0,-0x4(%rbp)
jne    117c <rename_dot+0x5c>
lea    0xe90(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <rename@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rename_dot>:
push   %rbx
lea    0xeea(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1040 <rename@plt>
mov    %eax,%ebx
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
lea    0xebc(%rip),%rcx
mov    %ebx,%edi
call   1030 <report_test@plt>
test   %ebx,%ebx
je     115c <rename_dot+0x3c>
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
lea    0xea8(%rip),%rsi
pop    %rbx
jmp    1040 <rename@plt>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [11 x i8] c"badcalldir\00"
@errno = global i32 0
@EINVAL = global i32 0
@.str.2 = [9 x i8] c"rename .\00"
define void @rename_dot() {
%1 = alloca i32
%2 = call i32 @rename(i8* getelementptr inbounds ([2 x i8], [2 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* @EINVAL
%6 = call i32 @report_test(i32 %3, i32 %4, i32 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @rename(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [11 x i8] c"badcalldir\00"
@errno = global i32 0
@EINVAL = global i32 0
@.str.2 = [9 x i8] c"rename .\00"
define void @rename_dot() {
%1 = tail call i32 @rename(i8* getelementptr inbounds ([2 x i8], [2 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* @EINVAL
%4 = tail call i32 @report_test(i32 %1, i32 %2, i32 %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32 %1, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @rename(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
ret void
}