#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*/ fprintf(int /*<<< orphan*/, char *);
int link(char *, char *);
int /*<<< orphan*/ memmove(char *, char *, unsigned long);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ pinfo();
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
unsigned long strlen(char *);
int unlink(char *);
int main(int argc, char *argv[]) {
  if (argc != 3 && argc != 4) {
    fprintf(stderr, "error: see info below\n");
    pinfo();
    return 1;
  }
  if (strcmp(argv[1], "make") == 0) {
    if (argv[3][strlen(argv[3]) - 1] == '/') {
      unsigned long idxToDel = strlen(argv[3]) - 1;
      memmove(&argv[3][idxToDel], &argv[3][idxToDel + 1],
              strlen(argv[3]) - idxToDel);
    }
    int res = link(argv[2], argv[3]);
    if (res != 0)
      perror("link");
  } else if (strcmp(argv[1], "remove") == 0) {
    int res = unlink(argv[2]);
    if (res != 0)
      perror("unlink");
  } else {
    pinfo();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11d2 <main+0x52>
cmpl   $0x4,-0x8(%rbp)
je     11d2 <main+0x52>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1040 <pinfo@plt>
movl   $0x1,-0x4(%rbp)
jmp    130d <main+0x18d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe36(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12b1 <main+0x131>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    127e <main+0xfe>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <strlen@plt>
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
sub    -0x18(%rbp),%rdx
call   1080 <memmove@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   10a0 <link@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12ac <main+0x12c>
lea    0xd7e(%rip),%rdi
call   1090 <perror@plt>
jmp    1306 <main+0x186>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd5c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12fa <main+0x17a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     12f5 <main+0x175>
lea    0xd33(%rip),%rdi
call   1090 <perror@plt>
jmp    1301 <main+0x181>
mov    $0x0,%al
call   1040 <pinfo@plt>
jmp    1306 <main+0x186>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
add    $0xfffffffb,%edi
cmp    $0xfffffffd,%edi
ja     11b2 <main+0x32>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1040 <pinfo@plt>
mov    $0x1,%ebx
jmp    1249 <main+0xc9>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11ea <main+0x6a>
mov    0x8(%rbx),%rdi
lea    0xe47(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     123a <main+0xba>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <pinfo@plt>
jmp    1249 <main+0xc9>
mov    0x18(%rbx),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
cmpb   $0x2f,-0x1(%rax,%r14,1)
jne    121a <main+0x9a>
lea    (%rax,%r14,1),%rdi
add    $0xffffffffffffffff,%rdi
add    %rax,%r14
mov    $0x1,%edx
mov    %r14,%rsi
call   1080 <memmove@plt>
mov    0x18(%rbx),%r14
mov    0x10(%rbx),%rdi
mov    %r14,%rsi
call   10a0 <link@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1249 <main+0xc9>
lea    0xdf2(%rip),%rdi
call   1090 <perror@plt>
jmp    1249 <main+0xc9>
mov    0x10(%rbx),%rdi
call   1030 <unlink@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1253 <main+0xd3>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdc9(%rip),%rdi
call   1090 <perror@plt>
jmp    1249 <main+0xc9>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"error: see info below\0A\00"
@.str.1 = [5 x i8] c"make\00"
@.str.2 = [5 x i8] c"link\00"
@.str.3 = [7 x i8] c"remove\00"
@.str.4 = [7 x i8] c"unlink\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 4
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (...) @pinfo()
store i32 1, i32* %3
br label %94
18: ; preds = %11, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %74
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call i64 @strlen(i8* %30)
%32 = sub i64 %31, 1
%33 = getelementptr inbounds i8, i8* %27, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 47
br i1 %36, label %37, label %61
37: ; preds = %24
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 3
%40 = load i8*, i8** %39
%41 = call i64 @strlen(i8* %40)
%42 = sub i64 %41, 1
store i64 %42, i64* %6
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = load i64, i64* %6
%47 = getelementptr inbounds i8, i8* %45, i64 %46
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = load i64, i64* %6
%52 = add i64 %51, 1
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call i64 @strlen(i8* %56)
%58 = load i64, i64* %6
%59 = sub i64 %57, %58
%60 = call i32 @memmove(i8* %47, i8* %53, i64 %59)
br label %61
61: ; preds = %37, %24
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 2
%64 = load i8*, i8** %63
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 3
%67 = load i8*, i8** %66
%68 = call i32 @link(i8* %64, i8* %67)
store i32 %68, i32* %7
%69 = load i32, i32* %7
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %61
%72 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %73
73: ; preds = %71, %61
br label %93
74: ; preds = %18
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %90
80: ; preds = %74
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 2
%83 = load i8*, i8** %82
%84 = call i32 @unlink(i8* %83)
store i32 %84, i32* %8
%85 = load i32, i32* %8
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %80
%88 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %89
89: ; preds = %87, %80
br label %92
90: ; preds = %74
%91 = call i32 (...) @pinfo()
br label %92
92: ; preds = %90, %89
br label %93
93: ; preds = %92, %73
store i32 0, i32* %3
br label %94
94: ; preds = %93, %14
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"error: see info below\0A\00"
@.str.1 = [5 x i8] c"make\00"
@.str.2 = [5 x i8] c"link\00"
@.str.3 = [7 x i8] c"remove\00"
@.str.4 = [7 x i8] c"unlink\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -5
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (...) @pinfo()
br label %47
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i64 @strlen(i8* dereferenceable(1) %16)
%18 = add i64 %17, -1
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 47
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = getelementptr inbounds i8, i8* %16, i64 %17
%24 = tail call i32 @memmove(i8* %19, i8* %23, i64 1)
%25 = load i8*, i8** %15
br label %26
26: ; preds = %22, %14
%27 = phi i8* [ %25, %22 ], [ %16, %14 ]
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32 @link(i8* %29, i8* %27)
%31 = icmp eq i32 %30, 0
br i1 %31, label %47, label %32
32: ; preds = %26
%33 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %47
34: ; preds = %9
%35 = load i8*, i8** %10
%36 = tail call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %34
%39 = getelementptr inbounds i8*, i8** %1, i64 2
%40 = load i8*, i8** %39
%41 = tail call i32 @unlink(i8* %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %38
%44 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %47
45: ; preds = %34
%46 = tail call i32 (...) @pinfo()
br label %47
47: ; preds = %45, %32, %26, %43, %38, %5
%48 = phi i32 [ 1, %5 ], [ 0, %38 ], [ 0, %43 ], [ 0, %26 ], [ 0, %32 ], [ 0, %45 ]
ret i32 %48
}