#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ link(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: ln old new\n");
    exit(0);
  }
  if (link(argv[1], argv[2]) < 0)
    fprintf(stderr, "link %s %s: failed\n", argv[1], argv[2]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     116e <main+0x3e>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <link@plt>
cmp    $0x0,%rax
jge    11b4 <main+0x84>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jne    116e <main+0x3e>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
call   1040 <link@plt>
test   %rax,%rax
jns    116a <main+0x3a>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
mov    0x10(%rbx),%rcx
lea    0xeb0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: ln old new\0A\00"
@.str.1 = [20 x i8] c"link %s %s: failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 3
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i64 @link(i8* %15, i8* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %12
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %28)
br label %30
30: ; preds = %21, %12
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: ln old new\0A\00"
@.str.1 = [20 x i8] c"link %s %s: failed\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i64 @link(i8* %10, i8* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %9
%18 = load i8*, i8** %11
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
br label %20
20: ; preds = %15, %8
ret i32 0
}