#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ Unify_copy(char *, struct stat *, char *);
int lstat(char *, struct stat *);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  struct stat st;
  if (argc < 2)
    return EXIT_FAILURE;
  if (lstat(argv[1], &st) == -1)
    return EXIT_FAILURE;
  unlink(argv[2]);
  return Unify_copy(argv[1], &st, argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1161 <main+0x31>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11df <main+0xaf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <lstat@plt>
cmp    $0xffffffff,%eax
jne    118c <main+0x5c>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11df <main+0xaf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <unlink@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    -0x18(%rbp),%rsi
call   1040 <Unify_copy@plt>
cmp    $0x0,%rax
je     11cd <main+0x9d>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11d9 <main+0xa9>
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    1170 <main+0x40>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1050 <lstat@plt>
cmp    $0xffffffff,%eax
je     1170 <main+0x40>
mov    0x10(%rbx),%rdi
call   1030 <unlink@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rdx
lea    0x8(%rsp),%rsi
call   1040 <Unify_copy@plt>
test   %rax,%rax
jne    117f <main+0x4f>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e52(%rip),%rax
jmp    1177 <main+0x47>

LLVM IR (-O0):
%struct.stat = type { i32 }
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %3
br label %38
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @lstat(i8* %14, %struct.stat* %6)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %38
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @unlink(i8* %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i64 @Unify_copy(i8* %26, %struct.stat* %6, i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %19
%33 = load i32, i32* @EXIT_SUCCESS
br label %36
34: ; preds = %19
%35 = load i32, i32* @EXIT_FAILURE
br label %36
36: ; preds = %34, %32
%37 = phi i32 [ %33, %32 ], [ %35, %34 ]
store i32 %37, i32* %3
br label %38
38: ; preds = %36, %17, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32, i32* @EXIT_FAILURE
br label %26
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @lstat(i8* %10, %struct.stat* %3)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i32, i32* @EXIT_FAILURE
br label %26
15: ; preds = %8
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @unlink(i8* %17)
%19 = load i8*, i8** %9
%20 = load i8*, i8** %16
%21 = call i64 @Unify_copy(i8* %19, %struct.stat* %3, i8* %20)
%22 = icmp eq i64 %21, 0
%23 = load i32, i32* @EXIT_SUCCESS
%24 = load i32, i32* @EXIT_FAILURE
%25 = select i1 %22, i32 %24, i32 %23
br label %26
26: ; preds = %15, %13, %6
%27 = phi i32 [ %7, %6 ], [ %14, %13 ], [ %25, %15 ]
ret i32 %27
}