#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*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ link(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ symlink(char *, char *);
int main(int argc, char *argv[]) {
  if (argc == 3) {
    if (link(argv[1], argv[2]) != 0) {
      perror("ln");
      return 1;
    }
  } else if (argc == 4 &&
             ((argv[1][0] == '-' && argv[1][1] == 's' && argv[1][2] == '\0'))) {
    if (symlink(argv[2], argv[3]) != 0) {
      perror("ln");
      return 1;
    }
  } else {
    fputs("Usage: ln [-s] <target> <link_name>\n", stderr);
    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)
cmpl   $0x3,-0x8(%rbp)
jne    119c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <link@plt>
cmp    $0x0,%rax
je     1197 <main+0x57>
lea    0xe7a(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    124d <main+0x10d>
jmp    1246 <main+0x106>
cmpl   $0x4,-0x8(%rbp)
jne    1220 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1220 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x73,%eax
jne    1220 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    1220 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <symlink@plt>
cmp    $0x0,%rax
je     121b <main+0xdb>
lea    0xdf6(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    124d <main+0x10d>
jmp    1241 <main+0x101>
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
lea    0xdd3(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    124d <main+0x10d>
jmp    1246 <main+0x106>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x4,%edi
je     1164 <main+0x24>
cmp    $0x3,%edi
jne    1179 <main+0x39>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
call   1060 <link@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11a4 <main+0x64>
pop    %rcx
ret
mov    0x8(%rsi),%rax
cmpb   $0x2d,(%rax)
jne    1179 <main+0x39>
cmpb   $0x73,0x1(%rax)
jne    1179 <main+0x39>
cmpb   $0x0,0x2(%rax)
je     1195 <main+0x55>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    0xe7a(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%eax
pop    %rcx
ret
mov    0x10(%rsi),%rdi
mov    0x18(%rsi),%rsi
call   1030 <symlink@plt>
jmp    1158 <main+0x18>
lea    0xe55(%rip),%rdi
call   1050 <perror@plt>
jmp    118e <main+0x4e>

LLVM IR (-O0):
@.str = [3 x i8] c"ln\00"
@.str.1 = [37 x i8] c"Usage: ln [-s] <target> <link_name>\0A\00"
@stderr = global i32 0
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 eq i32 %6, 3
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i64 @link(i8* %11, i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %64
19: ; preds = %8
br label %63
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 4
br i1 %22, label %23, label %59
23: ; preds = %20
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 45
br i1 %30, label %31, label %59
31: ; preds = %23
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 115
br i1 %38, label %39, label %59
39: ; preds = %31
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i64 2
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %59
47: ; preds = %39
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = call i64 @symlink(i8* %50, i8* %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %47
%57 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %64
58: ; preds = %47
br label %62
59: ; preds = %39, %31, %23, %20
%60 = load i32, i32* @stderr
%61 = call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %60)
store i32 1, i32* %3
br label %64
62: ; preds = %58
br label %63
63: ; preds = %62, %19
store i32 0, i32* %3
br label %64
64: ; preds = %63, %59, %56, %17
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [3 x i8] c"ln\00"
@.str.1 = [37 x i8] c"Usage: ln [-s] <target> <link_name>\0A\00"
@stderr = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %34 [
i32 3, label %3
i32 4, label %12
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call i64 @link(i8* %5, i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %37, label %10
10: ; preds = %3
%11 = tail call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %37
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 45
br i1 %16, label %17, label %34
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %14, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 115
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = getelementptr inbounds i8, i8* %14, i64 2
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i64 @symlink(i8* %27, i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %25
%33 = tail call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %37
34: ; preds = %2, %21, %17, %12
%35 = load i32, i32* @stderr
%36 = tail call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %3, %25, %34, %32, %10
%38 = phi i32 [ 1, %10 ], [ 1, %32 ], [ 1, %34 ], [ 0, %25 ], [ 0, %3 ]
ret i32 %38
}