#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*/ err(char *, int);
int link(char const *, char const *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char const *, char *);
int symlink(char const *, char const *);
int main(int argc, char const *argv[]) {
  if (argc < 4)
    err("arg err", -1);
  if (strcmp(argv[1], "-n") == 0)
    if (link(argv[2], argv[3]) == -1)
      err("link err", -2);
    else
      printf("\nlink successful\n");
  else if (strcmp(argv[1], "-s") == 0)
    if (symlink(argv[2], argv[3]) == -1)
      err("syslink err", -3);
    else
      printf("\nsyslink successful\n");
  else
    printf("\ninvalid argument\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)
jge    1181 <main+0x31>
lea    0xe89(%rip),%rdi
mov    $0xffffffff,%esi
call   1060 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe78(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <link@plt>
cmp    $0xffffffff,%eax
jne    11d3 <main+0x83>
lea    0xe5f(%rip),%rdi
mov    $0xfffffffe,%esi
call   1060 <err@plt>
jmp    11df <main+0x8f>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x108>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1247 <main+0xf7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <symlink@plt>
cmp    $0xffffffff,%eax
jne    1236 <main+0xe6>
lea    0xdf9(%rip),%rdi
mov    $0xfffffffd,%esi
call   1060 <err@plt>
jmp    1242 <main+0xf2>
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
jmp    1253 <main+0x103>
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x108>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     116a <main+0x1a>
lea    0xea0(%rip),%rdi
mov    $0xffffffff,%esi
call   1060 <err@plt>
mov    0x8(%rbx),%rdi
lea    0xe93(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     119d <main+0x4d>
mov    0x8(%rbx),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11b8 <main+0x68>
lea    0xe7f(%rip),%rdi
jmp    11d1 <main+0x81>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1070 <link@plt>
cmp    $0xffffffff,%eax
je     11da <main+0x8a>
lea    0xe8a(%rip),%rdi
jmp    11d1 <main+0x81>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <symlink@plt>
cmp    $0xffffffff,%eax
je     11ed <main+0x9d>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe30(%rip),%rdi
mov    $0xfffffffe,%esi
call   1060 <err@plt>
jmp    11d6 <main+0x86>
lea    0xe1a(%rip),%rdi
mov    $0xfffffffd,%esi
call   1060 <err@plt>
jmp    11d6 <main+0x86>

LLVM IR (-O0):
@.str = [8 x i8] c"arg err\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [9 x i8] c"link err\00"
@.str.3 = [18 x i8] c"\0Alink successful\0A\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [12 x i8] c"syslink err\00"
@.str.6 = [21 x i8] c"\0Asyslink successful\0A\00"
@.str.7 = [19 x i8] c"\0Ainvalid argument\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 slt i32 %6, 4
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @err(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 -1)
br label %10
10: ; preds = %8, %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %30
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @link(i8* %19, i8* %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = call i32 @err(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 -2)
br label %29
27: ; preds = %16
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
br label %53
30: ; preds = %10
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %30
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32 @symlink(i8* %39, i8* %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %36
%46 = call i32 @err(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 -3)
br label %49
47: ; preds = %36
%48 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
br label %52
50: ; preds = %30
%51 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %52
52: ; preds = %50, %49
br label %53
53: ; preds = %52, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"arg err\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [9 x i8] c"link err\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [12 x i8] c"syslink err\00"
@str = [18 x i8] c"\0Ainvalid argument\00"
@str.8 = [20 x i8] c"\0Asyslink successful\00"
@str.9 = [17 x i8] c"\0Alink successful\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @err(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 -1)
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32 @link(i8* %13, i8* %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = tail call i32 @err(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 -2)
br label %39
20: ; preds = %11
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
br label %39
22: ; preds = %6
%23 = load i8*, i8** %7
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8*, i8** %1, i64 3
%30 = load i8*, i8** %29
%31 = tail call i32 @symlink(i8* %28, i8* %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = tail call i32 @err(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 -3)
br label %39
35: ; preds = %26
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
br label %39
37: ; preds = %22
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %39
39: ; preds = %37, %35, %33, %18, %20
ret i32 0
}