#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 */
scalar_t__ SIOCDEVPRIVATE;
int do_add(scalar_t__, int, char **);
int do_del(int, char **);
int do_show(int, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ matches(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int do_iptunnel(int argc, char **argv) {
  if (argc > 0) {
    if (matches(*argv, "add") == 0)
      return do_add((SIOCDEVPRIVATE + 1), argc - 1, argv + 1);
    if (matches(*argv, "change") == 0)
      return do_add((SIOCDEVPRIVATE + 3), argc - 1, argv + 1);
    if (matches(*argv, "del") == 0)
      return do_del(argc - 1, argv + 1);
    if (matches(*argv, "show") == 0 || matches(*argv, "lst") == 0 ||
        matches(*argv, "list") == 0)
      return do_show(argc - 1, argv + 1);
    if (matches(*argv, "help") == 0)
      usage();
  } else
    return do_show(0, NULL);
  fprintf(stderr, "Command \"%s\" is unknown, try \"ip tunnel help\".\n",
          *argv);
  exit(-1);
}


x86 assembly (clang, -O0):
<do_iptunnel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    12e8 <do_iptunnel+0x178>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe69(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    11cf <do_iptunnel+0x5f>
mov    0x2e23(%rip),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   1060 <do_add@plt>
mov    %eax,-0x4(%rbp)
jmp    1321 <do_iptunnel+0x1b1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe27(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    1215 <do_iptunnel+0xa5>
mov    0x2ddd(%rip),%rax
mov    (%rax),%rdi
add    $0x3,%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   1060 <do_add@plt>
mov    %eax,-0x4(%rbp)
jmp    1321 <do_iptunnel+0x1b1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xde8(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    124d <do_iptunnel+0xdd>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1090 <do_del@plt>
mov    %eax,-0x4(%rbp)
jmp    1321 <do_iptunnel+0x1b1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb4(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
je     12a4 <do_iptunnel+0x134>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd9c(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
je     12a4 <do_iptunnel+0x134>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd83(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    12bf <do_iptunnel+0x14f>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1040 <do_show@plt>
mov    %eax,-0x4(%rbp)
jmp    1321 <do_iptunnel+0x1b1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd50(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    12e3 <do_iptunnel+0x173>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    12fb <do_iptunnel+0x18b>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <do_show@plt>
mov    %eax,-0x4(%rbp)
jmp    1321 <do_iptunnel+0x1b1>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd10(%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_iptunnel>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
jle    1212 <do_iptunnel+0xa2>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
lea    0xe76(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     1221 <do_iptunnel+0xb1>
mov    (%rbx),%rdi
lea    0xe62(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     1231 <do_iptunnel+0xc1>
mov    (%rbx),%rdi
lea    0xe51(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     1256 <do_iptunnel+0xe6>
mov    (%rbx),%rdi
lea    0xe3d(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     1204 <do_iptunnel+0x94>
mov    (%rbx),%rdi
lea    0xe2e(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
je     1204 <do_iptunnel+0x94>
mov    (%rbx),%rdi
lea    0xe1e(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
jne    126d <do_iptunnel+0xfd>
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
jmp    1216 <do_iptunnel+0xa6>
xor    %edi,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <do_show@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
jmp    123f <do_iptunnel+0xcf>
mov    0x2d98(%rip),%rax
mov    (%rax),%rdi
add    $0x3,%rdi
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %ebp,%esi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <do_add@plt>
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <do_del@plt>
mov    (%rbx),%rdi
lea    0xda6(%rip),%rsi
call   1030 <matches@plt>
test   %rax,%rax
jne    1288 <do_iptunnel+0x118>
xor    %eax,%eax
call   1070 <usage@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd87(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"add\00"
@SIOCDEVPRIVATE = global i64 0
@.str.1 = [7 x i8] c"change\00"
@.str.2 = [4 x i8] c"del\00"
@.str.3 = [5 x i8] c"show\00"
@.str.4 = [4 x i8] c"lst\00"
@.str.5 = [5 x i8] c"list\00"
@.str.6 = [5 x i8] c"help\00"
@stderr = global i32 0
@.str.7 = [48 x i8] c"Command \22%s\22 is unknown, try \22ip tunnel help\22.\0A\00"
define i32 @do_iptunnel(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 %74
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 %21
13: ; preds = %8
%14 = load i64, i64* @SIOCDEVPRIVATE
%15 = add nsw i64 %14, 1
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = call i32 @do_add(i64 %15, i32 %17, i8** %19)
store i32 %20, i32* %3
br label %82
21: ; preds = %8
%22 = load i8**, i8*** %5
%23 = load i8*, i8** %22
%24 = call i64 @matches(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %21
%27 = load i64, i64* @SIOCDEVPRIVATE
%28 = add nsw i64 %27, 3
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = call i32 @do_add(i64 %28, i32 %30, i8** %32)
store i32 %33, i32* %3
br label %82
34: ; preds = %21
%35 = load i8**, i8*** %5
%36 = load i8*, i8** %35
%37 = call i64 @matches(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 1
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = call i32 @do_del(i32 %41, i8** %43)
store i32 %44, i32* %3
br label %82
45: ; preds = %34
%46 = load i8**, i8*** %5
%47 = load i8*, i8** %46
%48 = call i64 @matches(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %60, label %50
50: ; preds = %45
%51 = load i8**, i8*** %5
%52 = load i8*, i8** %51
%53 = call i64 @matches(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %60, label %55
55: ; preds = %50
%56 = load i8**, i8*** %5
%57 = load i8*, i8** %56
%58 = call i64 @matches(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %55, %50, %45
%61 = load i32, i32* %4
%62 = sub nsw i32 %61, 1
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 1
%65 = call i32 @do_show(i32 %62, i8** %64)
store i32 %65, i32* %3
br label %82
66: ; preds = %55
%67 = load i8**, i8*** %5
%68 = load i8*, i8** %67
%69 = call i64 @matches(i8* %68, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = call i32 (...) @usage()
br label %73
73: ; preds = %71, %66
br label %76
74: ; preds = %2
%75 = call i32 @do_show(i32 0, i8** null)
store i32 %75, i32* %3
br label %82
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = load i8**, i8*** %5
%79 = load i8*, i8** %78
%80 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i8* %79)
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %74, %60, %39, %26, %13
%83 = load i32, i32* %3
ret i32 %83
}

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