#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*/ printf(char *, char *);
int rename(char *, char *);
int main(int argc, char *argv[]) {
  int res;
  if (3 == argc) {
    res = rename(argv[1], argv[2]);
    if (-1 == res) {
      perror("rename");
      return 1;
    }
  } else {
    printf("usage: %s <source> <dest>\n", argv[0]);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
jne    1197 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1050 <rename@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    1192 <main+0x62>
lea    0xe7f(%rip),%rdi
call   1040 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bd <main+0x8d>
jmp    11b6 <main+0x86>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bd <main+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x3,%edi
jne    114e <main+0x1e>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
call   1050 <rename@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     1164 <main+0x34>
pop    %rcx
ret
mov    (%rsi),%rsi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe95(%rip),%rdi
call   1040 <perror@plt>
jmp    115d <main+0x2d>

LLVM IR (-O0):
@.str = [7 x i8] c"rename\00"
@.str.1 = [27 x i8] c"usage: %s <source> <dest>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 3, %7
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @rename(i8* %12, i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp eq i32 -1, %17
br i1 %18, label %19, label %21
19: ; preds = %9
%20 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %28
21: ; preds = %9
br label %27
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 1, i32* %3
br label %28
27: ; preds = %21
store i32 0, i32* %3
br label %28
28: ; preds = %27, %22, %19
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [7 x i8] c"rename\00"
@.str.1 = [27 x i8] c"usage: %s <source> <dest>\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @rename(i8* %6, i8* %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %16
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %4, %13, %11
%17 = phi i32 [ 1, %11 ], [ 1, %13 ], [ 0, %4 ]
ret i32 %17
}