#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ link(char const *, char const *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ symlink(char const *, char const *);
int main(int argc, char **argv) {
  if ((argc == 4) && (!strcmp(*++argv, "-s"))) {
    const char *oldpath = *++argv;
    const char *newpath = *++argv;
    if (symlink(oldpath, newpath) < 0) {
      perror("ln");
      return EXIT_FAILURE;
    }
  } else if (argc == 3) {
    const char *oldpath = *++argv;
    const char *newpath = *++argv;
    if (link(oldpath, newpath) < 0) {
      perror("ln");
      return EXIT_FAILURE;
    }
  } else {
    printf("Wrong arguments\n");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    11ff <main+0xaf>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe76(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ff <main+0xaf>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <symlink@plt>
cmp    $0x0,%rax
jge    11fa <main+0xaa>
lea    0xe1f(%rip),%rdi
call   1060 <perror@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    129e <main+0x14e>
jmp    1292 <main+0x142>
cmpl   $0x3,-0x8(%rbp)
jne    1270 <main+0x120>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <link@plt>
cmp    $0x0,%rax
jge    126b <main+0x11b>
lea    0xdae(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    129e <main+0x14e>
jmp    128d <main+0x13d>
lea    0xd8f(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    129e <main+0x14e>
jmp    1292 <main+0x142>
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1187 <main+0x37>
cmp    $0x4,%edi
jne    1172 <main+0x22>
mov    0x8(%rbx),%rdi
lea    0xe97(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11a4 <main+0x54>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e5b(%rip),%rax
jmp    11a0 <main+0x50>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
call   1070 <link@plt>
test   %rax,%rax
js     11b6 <main+0x66>
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <symlink@plt>
test   %rax,%rax
jns    1199 <main+0x49>
lea    0xe46(%rip),%rdi
call   1060 <perror@plt>
jmp    117e <main+0x2e>

LLVM IR (-O0):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"ln\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [17 x i8] c"Wrong arguments\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %33
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %5
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %33, label %18
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %5
%21 = load i8*, i8** %20
store i8* %21, i8** %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i32 1
store i8** %23, i8*** %5
%24 = load i8*, i8** %23
store i8* %24, i8** %7
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = call i64 @symlink(i8* %25, i8* %26)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %18
%30 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %57
32: ; preds = %18
br label %55
33: ; preds = %12, %2
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 3
br i1 %35, label %36, label %51
36: ; preds = %33
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i32 1
store i8** %38, i8*** %5
%39 = load i8*, i8** %38
store i8* %39, i8** %8
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i32 1
store i8** %41, i8*** %5
%42 = load i8*, i8** %41
store i8* %42, i8** %9
%43 = load i8*, i8** %8
%44 = load i8*, i8** %9
%45 = call i64 @link(i8* %43, i8* %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %36
%48 = call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %3
br label %57
50: ; preds = %36
br label %54
51: ; preds = %33
%52 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
store i32 %53, i32* %3
br label %57
54: ; preds = %50
br label %55
55: ; preds = %54, %32
%56 = load i32, i32* @EXIT_SUCCESS
store i32 %56, i32* %3
br label %57
57: ; preds = %55, %51, %47, %29
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"ln\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [16 x i8] c"Wrong arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %26 [
i32 4, label %3
i32 3, label %17
]
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 %26
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 i64 @symlink(i8* %10, i8* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %8
%16 = tail call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %28
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i64 @link(i8* %19, i8* %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = tail call i32 @perror(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %28
26: ; preds = %2, %3
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %8, %17, %24, %15, %26
%29 = phi i32* [ @EXIT_FAILURE, %24 ], [ @EXIT_FAILURE, %26 ], [ @EXIT_FAILURE, %15 ], [ @EXIT_SUCCESS, %17 ], [ @EXIT_SUCCESS, %8 ]
%30 = load i32, i32* %29
ret i32 %30
}