#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*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int rename(char *, char *);
int main() {
  int result;
  char old_file_name[] = "oldfile.txt";
  char new_file_name[] = "newfile.txt";
  result = rename(old_file_name, new_file_name);
  if (result == 0)
    puts("File successfully renamed");
  else
    perror("Error renamingfile");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <rename@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1192 <main+0x62>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
jmp    119e <main+0x6e>
lea    0xe99(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movabs $0x2e656c6966646c6f,%rax
6c 65 2e
mov    %rax,0x18(%rsp)
movl   $0x747874,0x20(%rsp)
movabs $0x2e656c696677656e,%rax
6c 65 2e
mov    %rax,0x8(%rsp)
movl   $0x747874,0x10(%rsp)
lea    0x18(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <rename@plt>
test   %eax,%eax
jne    1188 <main+0x58>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xea3(%rip),%rdi
call   1040 <perror@plt>
jmp    1181 <main+0x51>

LLVM IR (-O0):
@__const.main.old_file_name = [12 x i8] c"oldfile.txt\00"
@__const.main.new_file_name = [12 x i8] c"newfile.txt\00"
@.str = [26 x i8] c"File successfully renamed\00"
@.str.1 = [19 x i8] c"Error renamingfile\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [12 x i8]
%4 = alloca [12 x i8]
store i32 0, i32* %1
%5 = bitcast [12 x i8]* %3 to i8*
%6 = bitcast [12 x i8]* %4 to i8*
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%9 = call i32 @rename(i8* %7, i8* %8)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %16
14: ; preds = %0
%15 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.old_file_name = [12 x i8] c"oldfile.txt\00"
@__const.main.new_file_name = [12 x i8] c"newfile.txt\00"
@.str = [26 x i8] c"File successfully renamed\00"
@.str.1 = [19 x i8] c"Error renamingfile\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = call i32 @rename(i8* %3, i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
ret i32 0
}