#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*/ bu_extra_argument(char *);
scalar_t__ bu_handle_version(int, char **);
int /*<<< orphan*/ bu_missing_argument(char *);
scalar_t__ has_arg(int, char **, char *);
int link(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  if (has_arg(argc, argv, "-h") || has_arg(argc, argv, "--help")) {
    puts("Usage: link FILE1 FILE2");
    puts("Creates a link to existing path FILE1, named FILE2");
    return 1;
  }
  if (bu_handle_version(argc, argv)) {
    return 0;
  }
  if (argc < 3) {
    bu_missing_argument(argv[0]);
    return 1;
  }
  if (argc > 3) {
    bu_extra_argument(argv[0]);
    return 1;
  }
  if (link(argv[1], argv[2]) == -1) {
    perror(argv[0]);
    return 1;
  }
  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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdx
call   1040 <has_arg@plt>
cmp    $0x0,%rax
jne    11c0 <main+0x50>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe52(%rip),%rdx
call   1040 <has_arg@plt>
cmp    $0x0,%rax
je     11e4 <main+0x74>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1287 <main+0x117>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <bu_handle_version@plt>
cmp    $0x0,%rax
je     1206 <main+0x96>
movl   $0x0,-0x4(%rbp)
jmp    1287 <main+0x117>
cmpl   $0x3,-0x8(%rbp)
jge    1228 <main+0xb8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <bu_missing_argument@plt>
movl   $0x1,-0x4(%rbp)
jmp    1287 <main+0x117>
cmpl   $0x3,-0x8(%rbp)
jle    124a <main+0xda>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <bu_extra_argument@plt>
movl   $0x1,-0x4(%rbp)
jmp    1287 <main+0x117>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1070 <link@plt>
cmp    $0xffffffff,%eax
jne    1280 <main+0x110>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1287 <main+0x117>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xe80(%rip),%rdx
call   1040 <has_arg@plt>
test   %rax,%rax
jne    11a0 <main+0x30>
lea    0xe72(%rip),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <has_arg@plt>
test   %rax,%rax
je     11c4 <main+0x54>
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %ebx,%edi
mov    %r14,%rsi
call   1080 <bu_handle_version@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11bd <main+0x4d>
cmp    $0x2,%ebx
jg     11e4 <main+0x74>
mov    (%r14),%rdi
call   1090 <bu_missing_argument@plt>
jmp    11b8 <main+0x48>
cmp    $0x3,%ebx
jne    1205 <main+0x95>
mov    0x8(%r14),%rdi
mov    0x10(%r14),%rsi
call   1070 <link@plt>
cmp    $0xffffffff,%eax
jne    11bd <main+0x4d>
mov    (%r14),%rdi
call   1060 <perror@plt>
jmp    11b8 <main+0x48>
mov    (%r14),%rdi
call   1050 <bu_extra_argument@plt>
jmp    11b8 <main+0x48>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [24 x i8] c"Usage: link FILE1 FILE2\00"
@.str.3 = [51 x i8] c"Creates a link to existing path FILE1, named FILE2\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 = load i8**, i8*** %5
%8 = call i64 @has_arg(i32 %6, i8** %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i64 @has_arg(i32 %11, i8** %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10, %2
%16 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %55
18: ; preds = %10
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i64 @bu_handle_version(i32 %19, i8** %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 0, i32* %3
br label %55
24: ; preds = %18
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 3
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @bu_missing_argument(i8* %30)
store i32 1, i32* %3
br label %55
32: ; preds = %24
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 3
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 @bu_extra_argument(i8* %38)
store i32 1, i32* %3
br label %55
40: ; preds = %32
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 @link(i8* %43, i8* %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %54
49: ; preds = %40
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 0
%52 = load i8*, i8** %51
%53 = call i32 @perror(i8* %52)
store i32 1, i32* %3
br label %55
54: ; preds = %40
store i32 0, i32* %3
br label %55
55: ; preds = %54, %49, %35, %27, %23, %15
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [24 x i8] c"Usage: link FILE1 FILE2\00"
@.str.3 = [51 x i8] c"Creates a link to existing path FILE1, named FILE2\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5, %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %34
11: ; preds = %5
%12 = tail call i64 @bu_handle_version(i32 %0, i8** %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %11
%15 = icmp slt i32 %0, 3
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = load i8*, i8** %1
%18 = tail call i32 @bu_missing_argument(i8* %17)
br label %34
19: ; preds = %14
%20 = icmp eq i32 %0, 3
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = load i8*, i8** %1
%23 = tail call i32 @bu_extra_argument(i8* %22)
br label %34
24: ; preds = %19
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32 @link(i8* %26, i8* %28)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i8*, i8** %1
%33 = tail call i32 @perror(i8* %32)
br label %34
34: ; preds = %24, %11, %31, %21, %16, %8
%35 = phi i32 [ 1, %8 ], [ 1, %16 ], [ 1, %21 ], [ 1, %31 ], [ 0, %11 ], [ 0, %24 ]
ret i32 %35
}