#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*/ check_for_root_maybe_die();
int /*<<< orphan*/ do_ethernet(int, char **);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ version();
int main(int argc, char **argv) {
  check_for_root_maybe_die();
  if (argc <= 1)
    usage();
  argc--;
  argv++;
  if (!strncmp("help", argv[0], strlen("help")))
    usage();
  else if (!strncmp("version", argv[0], strlen("version")))
    version();
  else if (!strncmp("ethernet", argv[0], strlen("ethernet")))
    do_ethernet(--argc, ++argv);
  else
    usage();
  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)
mov    $0x0,%al
call   1080 <check_for_root_maybe_die@plt>
cmpl   $0x1,-0x8(%rbp)
jg     118e <main+0x2e>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe4b(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe39(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11e1 <main+0x81>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    1281 <main+0x121>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xe12(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe00(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    121f <main+0xbf>
mov    $0x0,%al
call   1060 <version@plt>
jmp    127c <main+0x11c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    0xddc(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xdca(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1270 <main+0x110>
mov    -0x8(%rbp),%edi
add    $0xffffffff,%edi
mov    %edi,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    %rsi,-0x10(%rbp)
call   1040 <do_ethernet@plt>
jmp    1277 <main+0x117>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    127c <main+0x11c>
jmp    1281 <main+0x121>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
xor    %eax,%eax
call   1080 <check_for_root_maybe_die@plt>
cmp    $0x1,%r14d
jg     1181 <main+0x21>
xor    %eax,%eax
call   1070 <usage@plt>
mov    0x8(%r15),%rbp
lea    0xe74(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ed <main+0x8d>
mov    0x8(%r15),%rbx
lea    0xe55(%rip),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11f6 <main+0x96>
mov    0x8(%r15),%rbx
lea    0xe39(%rip),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ff <main+0x9f>
xor    %eax,%eax
call   1070 <usage@plt>
jmp    1212 <main+0xb2>
xor    %eax,%eax
call   1060 <version@plt>
jmp    1212 <main+0xb2>
add    $0xfffffffe,%r14d
add    $0x10,%r15
mov    %r14d,%edi
mov    %r15,%rsi
call   1040 <do_ethernet@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [9 x i8] c"ethernet\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 = call i32 (...) @check_for_root_maybe_die()
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @usage()
br label %11
11: ; preds = %9, %2
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %5
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %11
%23 = call i32 (...) @usage()
br label %50
24: ; preds = %11
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %27, i32 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %24
%32 = call i32 (...) @version()
br label %49
33: ; preds = %24
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @strncmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %36, i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %33
%41 = load i32, i32* %4
%42 = add nsw i32 %41, -1
store i32 %42, i32* %4
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i32 1
store i8** %44, i8*** %5
%45 = call i32 @do_ethernet(i32 %42, i8** %44)
br label %48
46: ; preds = %33
%47 = call i32 (...) @usage()
br label %48
48: ; preds = %46, %40
br label %49
49: ; preds = %48, %31
br label %50
50: ; preds = %49, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [9 x i8] c"ethernet\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 (...) @check_for_root_maybe_die()
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (...) @usage()
br label %7
7: ; preds = %5, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 (...) @usage()
br label %33
15: ; preds = %7
%16 = load i8*, i8** %8
%17 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 (...) @version()
br label %33
22: ; preds = %15
%23 = load i8*, i8** %8
%24 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @strncmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = add nsw i32 %0, -2
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = tail call i32 @do_ethernet(i32 %28, i8** %29)
br label %33
31: ; preds = %22
%32 = tail call i32 (...) @usage()
br label %33
33: ; preds = %20, %31, %27, %13
ret i32 0
}