#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*/ Usage(char *);
int /*<<< orphan*/ add_link();
int /*<<< orphan*/ del_link();
int getopt(int, char **, char *);
int main(int argc, char *argv[]) {
  int opt, op = 0, context = 0;
  while ((opt = getopt(argc, argv, "adgLAR")) != -1) {
    switch (opt) {
    case 'a':
      op = 1;
      break;
    case 'd':
      op = 2;
      break;
    case 'g':
      op = 3;
      break;
    case 'L':
      context = 1;
      break;
    case 'A':
      context = 2;
      break;
    case 'R':
      context = 3;
      break;
    }
  }
  if (!op || !context) {
    Usage(argv[0]);
    return -1;
  }
  if (context == 1) {
    switch (op) {
    case 1:
      add_link();
      break;
    case 2:
      del_link();
      break;
    }
  }
  return 0;
}


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)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf2a(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11f4 <main+0xb4>
mov    -0x14(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x26,%eax
ja     11ef <main+0xaf>
mov    -0x28(%rbp),%rax
lea    0xe5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x18(%rbp)
jmp    11ef <main+0xaf>
movl   $0x2,-0x18(%rbp)
jmp    11ef <main+0xaf>
movl   $0x3,-0x18(%rbp)
jmp    11ef <main+0xaf>
movl   $0x1,-0x1c(%rbp)
jmp    11ef <main+0xaf>
movl   $0x2,-0x1c(%rbp)
jmp    11ef <main+0xaf>
movl   $0x3,-0x1c(%rbp)
jmp    1164 <main+0x24>
cmpl   $0x0,-0x18(%rbp)
je     1208 <main+0xc8>
cmpl   $0x0,-0x1c(%rbp)
jne    1220 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <Usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    126e <main+0x12e>
cmpl   $0x1,-0x1c(%rbp)
jne    1267 <main+0x127>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x1,%eax
je     124f <main+0x10f>
jmp    123e <main+0xfe>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     125b <main+0x11b>
jmp    1262 <main+0x122>
mov    $0x0,%al
call   1050 <add_link@plt>
jmp    1262 <main+0x122>
mov    $0x0,%al
call   1040 <del_link@plt>
jmp    1267 <main+0x127>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r15d,%r15d
lea    0xf42(%rip),%r14
lea    0xe9f(%rip),%r13
xor    %r12d,%r12d
jmp    1175 <main+0x35>
cs nopw 0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     11c4 <main+0x84>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
lea    -0x41(%rax),%ecx
cmp    $0x26,%ecx
ja     1170 <main+0x30>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    $0x2,%r12d
jmp    1175 <main+0x35>
mov    $0x1,%r12d
jmp    1175 <main+0x35>
mov    $0x3,%r12d
jmp    1175 <main+0x35>
mov    $0x1,%r15d
jmp    1175 <main+0x35>
mov    $0x2,%r15d
jmp    1175 <main+0x35>
mov    $0x3,%r15d
jmp    1175 <main+0x35>
test   %r15d,%r15d
je     11ed <main+0xad>
test   %r12d,%r12d
je     11ed <main+0xad>
xor    %ebx,%ebx
cmp    $0x1,%r12d
jne    11fa <main+0xba>
cmp    $0x2,%r15d
je     120b <main+0xcb>
cmp    $0x1,%r15d
jne    11fa <main+0xba>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <add_link@plt>
jmp    11fa <main+0xba>
mov    (%rbx),%rdi
call   1030 <Usage@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <del_link@plt>
jmp    11fa <main+0xba>

LLVM IR (-O0):
@.str = [7 x i8] c"adgLAR\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %22, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %23
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %22 [
i32 97, label %16
i32 100, label %17
i32 103, label %18
i32 76, label %19
i32 65, label %20
i32 82, label %21
]
16: ; preds = %14
store i32 1, i32* %7
br label %22
17: ; preds = %14
store i32 2, i32* %7
br label %22
18: ; preds = %14
store i32 3, i32* %7
br label %22
19: ; preds = %14
store i32 1, i32* %8
br label %22
20: ; preds = %14
store i32 2, i32* %8
br label %22
21: ; preds = %14
store i32 3, i32* %8
br label %22
22: ; preds = %14, %21, %20, %19, %18, %17, %16
br label %9
23: ; preds = %9
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %26, %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @Usage(i8* %32)
store i32 -1, i32* %3
br label %45
34: ; preds = %26
%35 = load i32, i32* %8
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %7
switch i32 %38, label %43 [
i32 1, label %39
i32 2, label %41
]
39: ; preds = %37
%40 = call i32 (...) @add_link()
br label %43
41: ; preds = %37
%42 = call i32 (...) @del_link()
br label %43
43: ; preds = %37, %41, %39
br label %44
44: ; preds = %43, %34
store i32 0, i32* %3
br label %45
45: ; preds = %44, %29
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [7 x i8] c"adgLAR\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i32 [ 0, %2 ], [ %13, %12 ]
%5 = phi i32 [ 0, %2 ], [ %7, %12 ]
br label %6
6: ; preds = %16, %3
%7 = phi i32 [ %5, %3 ], [ %17, %16 ]
br label %8
8: ; preds = %6, %8
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %8 [
i32 -1, label %18
i32 97, label %12
i32 100, label %10
i32 103, label %11
i32 76, label %16
i32 65, label %14
i32 82, label %15
]
10: ; preds = %8
br label %12
11: ; preds = %8
br label %12
12: ; preds = %8, %11, %10
%13 = phi i32 [ 2, %10 ], [ 3, %11 ], [ 1, %8 ]
br label %3
14: ; preds = %8
br label %16
15: ; preds = %8
br label %16
16: ; preds = %8, %15, %14
%17 = phi i32 [ 2, %14 ], [ 3, %15 ], [ 1, %8 ]
br label %6
18: ; preds = %8
%19 = icmp ne i32 %4, 0
%20 = icmp ne i32 %7, 0
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i8*, i8** %1
%24 = tail call i32 @Usage(i8* %23)
br label %32
25: ; preds = %18
%26 = icmp eq i32 %7, 1
br i1 %26, label %27, label %32
27: ; preds = %25
switch i32 %4, label %32 [
i32 1, label %28
i32 2, label %30
]
28: ; preds = %27
%29 = tail call i32 (...) @add_link()
br label %32
30: ; preds = %27
%31 = tail call i32 (...) @del_link()
br label %32
32: ; preds = %25, %27, %30, %28, %22
%33 = phi i32 [ -1, %22 ], [ 0, %28 ], [ 0, %30 ], [ 0, %27 ], [ 0, %25 ]
ret i32 %33
}