#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*/ rename(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char const *);
int strlen(char const *);
void MapFileRename(const char *rootpath, const char *newfilename,
                   const char *oldfilename) {
  char oldfullname[260];
  char newfullname[260];
  if (strlen(rootpath) + strlen(oldfilename) >= 260)
    return;
  if (strlen(rootpath) + strlen(newfilename) >= 260)
    return;
  sprintf(oldfullname, "%s%s", rootpath, oldfilename);
  sprintf(newfullname, "%s%s", rootpath, newfilename);
  rename(oldfullname, newfullname);
}


x86 assembly (clang, -O0):
<MapFileRename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x234(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x234(%rbp),%eax
add    %ecx,%eax
cmp    $0x104,%eax
jl     1179 <MapFileRename+0x49>
jmp    11f4 <MapFileRename+0xc4>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x238(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x238(%rbp),%eax
add    %ecx,%eax
cmp    $0x104,%eax
jl     11ab <MapFileRename+0x7b>
jmp    11f4 <MapFileRename+0xc4>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe3f(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x230(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe24(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1040 <rename@plt>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MapFileRename>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cmp    $0x103,%eax
jg     11bc <MapFileRename+0x8c>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cmp    $0x103,%eax
jg     11bc <MapFileRename+0x8c>
lea    0xe7c(%rip),%r13
lea    0x110(%rsp),%r12
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1050 <sprintf@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1040 <rename@plt>
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
define void @MapFileRename(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [260 x i8]
%8 = alloca [260 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = load i8*, i8** %6
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %10, %12
%14 = icmp sge i32 %13, 260
br i1 %14, label %15, label %16
15: ; preds = %3
br label %36
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = call i32 @strlen(i8* %17)
%19 = load i8*, i8** %5
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 %18, %20
%22 = icmp sge i32 %21, 260
br i1 %22, label %23, label %24
23: ; preds = %16
br label %36
24: ; preds = %16
%25 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
%26 = load i8*, i8** %4
%27 = load i8*, i8** %6
%28 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
%29 = getelementptr inbounds [260 x i8], [260 x i8]* %8, i64 0, i64 0
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31)
%33 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds [260 x i8], [260 x i8]* %8, i64 0, i64 0
%35 = call i32 @rename(i8* %33, i8* %34)
br label %36
36: ; preds = %24, %23, %15
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
define void @MapFileRename(i8* %0, i8* %1, i8* %2) {
%4 = alloca [260 x i8]
%5 = alloca [260 x i8]
%6 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [260 x i8], [260 x i8]* %5, i64 0, i64 0
%8 = tail call i32 @strlen(i8* %0)
%9 = tail call i32 @strlen(i8* %2)
%10 = add nsw i32 %9, %8
%11 = icmp sgt i32 %10, 259
br i1 %11, label %21, label %12
12: ; preds = %3
%13 = tail call i32 @strlen(i8* %0)
%14 = tail call i32 @strlen(i8* %1)
%15 = add nsw i32 %14, %13
%16 = icmp sgt i32 %15, 259
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %2)
%19 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%20 = call i32 @rename(i8* %6, i8* %7)
br label %21
21: ; preds = %12, %3, %17
ret void
}