#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*/ dohardlink(char *, char *);
int /*<<< orphan*/ dosymlink(char *, char *);
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ warnx(char *);
int main(int argc, char *argv[]) {
  if (argc == 4 && !strcmp(argv[1], "-s")) {
    dosymlink(argv[2], argv[3]);
  } else if (argc == 3) {
    dohardlink(argv[1], argv[2]);
  } else {
    warnx("Usage: ln oldfile newfile");
    errx(1, "       ln -s symlinkcontents symlinkfile\n");
  }
  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   $0x4,-0x8(%rbp)
jne    11a7 <main+0x57>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11a7 <main+0x57>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <dosymlink@plt>
jmp    11ed <main+0x9d>
cmpl   $0x3,-0x8(%rbp)
jne    11cb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <dohardlink@plt>
jmp    11e8 <main+0x98>
lea    0xe31(%rip),%rdi
call   1050 <warnx@plt>
mov    $0x1,%edi
lea    0xe3a(%rip),%rsi
call   1040 <errx@plt>
jmp    11ed <main+0x9d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1191 <main+0x41>
cmp    $0x4,%edi
jne    1172 <main+0x22>
mov    0x8(%rbx),%rdi
lea    0xe97(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11a0 <main+0x50>
lea    0xe8a(%rip),%rdi
call   1050 <warnx@plt>
lea    0xe98(%rip),%rsi
mov    $0x1,%edi
call   1040 <errx@plt>
jmp    11ad <main+0x5d>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
call   1030 <dohardlink@plt>
jmp    11ad <main+0x5d>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1070 <dosymlink@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-s\00"
@.str.1 = [26 x i8] c"Usage: ln oldfile newfile\00"
@.str.2 = [42 x i8] c" ln -s symlinkcontents symlinkfile\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 eq i32 %6, 4
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
%21 = call i32 @dosymlink(i8* %17, i8* %20)
br label %37
22: ; preds = %8, %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @dohardlink(i8* %28, i8* %31)
br label %36
33: ; preds = %22
%34 = call i32 @warnx(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @errx(i32 1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %33, %25
br label %37
37: ; preds = %36, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-s\00"
@.str.1 = [26 x i8] c"Usage: ln oldfile newfile\00"
@.str.2 = [42 x i8] c" ln -s symlinkcontents symlinkfile\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %20 [
i32 4, label %3
i32 3, label %14
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %3
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32 @dosymlink(i8* %10, i8* %12)
br label %23
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @dohardlink(i8* %16, i8* %18)
br label %23
20: ; preds = %3, %2
%21 = tail call i32 @warnx(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %14, %20, %8
ret i32 0
}