#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 do_set(int, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int ipaddr_list_link(int, char **);
scalar_t__ matches(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int do_iplink(int argc, char **argv) {
  if (argc > 0) {
    if (matches(*argv, "set") == 0)
      return do_set(argc - 1, argv + 1);
    if (matches(*argv, "show") == 0 || matches(*argv, "lst") == 0 ||
        matches(*argv, "list") == 0)
      return ipaddr_list_link(argc - 1, argv + 1);
    if (matches(*argv, "help") == 0)
      usage();
  } else
    return ipaddr_list_link(0, NULL);
  fprintf(stderr, "Command \"%s\" is unknown, try \"ip link help\".\n", *argv);
  exit(-1);
}


x86 assembly (clang, -O0):
<do_iplink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    124c <do_iplink+0xec>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe79(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    11b1 <do_iplink+0x51>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1070 <do_set@plt>
mov    %eax,-0x4(%rbp)
jmp    1285 <do_iplink+0x125>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe45(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
je     1208 <do_iplink+0xa8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe2d(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
je     1208 <do_iplink+0xa8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe14(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    1223 <do_iplink+0xc3>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1040 <ipaddr_list_link@plt>
mov    %eax,-0x4(%rbp)
jmp    1285 <do_iplink+0x125>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xde1(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    1247 <do_iplink+0xe7>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    125f <do_iplink+0xff>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <ipaddr_list_link@plt>
mov    %eax,-0x4(%rbp)
jmp    1285 <do_iplink+0x125>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda1(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_iplink>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
jle    11ca <do_iplink+0x6a>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     11d9 <do_iplink+0x79>
mov    (%rbx),%rdi
lea    0xe7a(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     11bc <do_iplink+0x5c>
mov    (%rbx),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     11bc <do_iplink+0x5c>
mov    (%rbx),%rdi
lea    0xe5b(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
jne    11f0 <do_iplink+0x90>
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
jmp    11ce <do_iplink+0x6e>
xor    %edi,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ipaddr_list_link@plt>
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <do_set@plt>
mov    (%rbx),%rdi
lea    0xe18(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
jne    120b <do_iplink+0xab>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdf9(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"set\00"
@.str.1 = [5 x i8] c"show\00"
@.str.2 = [4 x i8] c"lst\00"
@.str.3 = [5 x i8] c"list\00"
@.str.4 = [5 x i8] c"help\00"
@stderr = global i32 0
@.str.5 = [46 x i8] c"Command \22%s\22 is unknown, try \22ip link help\22.\0A\00"
define i32 @do_iplink(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %48
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = load i8*, i8** %9
%11 = call i64 @matches(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = call i32 @do_set(i32 %15, i8** %17)
store i32 %18, i32* %3
br label %56
19: ; preds = %8
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = call i64 @matches(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 %34, label %24
24: ; preds = %19
%25 = load i8**, i8*** %5
%26 = load i8*, i8** %25
%27 = call i64 @matches(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i8**, i8*** %5
%31 = load i8*, i8** %30
%32 = call i64 @matches(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %29, %24, %19
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = call i32 @ipaddr_list_link(i32 %36, i8** %38)
store i32 %39, i32* %3
br label %56
40: ; preds = %29
%41 = load i8**, i8*** %5
%42 = load i8*, i8** %41
%43 = call i64 @matches(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 (...) @usage()
br label %47
47: ; preds = %45, %40
br label %50
48: ; preds = %2
%49 = call i32 @ipaddr_list_link(i32 0, i8** null)
store i32 %49, i32* %3
br label %56
50: ; preds = %47
%51 = load i32, i32* @stderr
%52 = load i8**, i8*** %5
%53 = load i8*, i8** %52
%54 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* %53)
%55 = call i32 @exit(i32 -1)
unreachable
56: ; preds = %48, %34, %13
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [4 x i8] c"set\00"
@.str.1 = [5 x i8] c"show\00"
@.str.2 = [4 x i8] c"lst\00"
@.str.3 = [5 x i8] c"list\00"
@.str.4 = [5 x i8] c"help\00"
@stderr = global i32 0
@.str.5 = [46 x i8] c"Command \22%s\22 is unknown, try \22ip link help\22.\0A\00"
define i32 @do_iplink(i32 %0, i8** %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %34
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i64 @matches(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = add nsw i32 %0, -1
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = tail call i32 @do_set(i32 %9, i8** %10)
br label %41
12: ; preds = %4
%13 = load i8*, i8** %1
%14 = tail call i64 @matches(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %12
%17 = load i8*, i8** %1
%18 = tail call i64 @matches(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i8*, i8** %1
%22 = tail call i64 @matches(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20, %16, %12
%25 = add nsw i32 %0, -1
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = tail call i32 @ipaddr_list_link(i32 %25, i8** %26)
br label %41
28: ; preds = %20
%29 = load i8*, i8** %1
%30 = tail call i64 @matches(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = tail call i32 (...) @usage()
br label %36
34: ; preds = %2
%35 = tail call i32 @ipaddr_list_link(i32 0, i8** null)
br label %41
36: ; preds = %28, %32
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %1
%39 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = tail call i32 @exit(i32 -1)
unreachable
41: ; preds = %34, %24, %8
%42 = phi i32 [ %11, %8 ], [ %27, %24 ], [ %35, %34 ]
ret i32 %42
}