#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*/ print_interface_info(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ set_if_down(char *);
int /*<<< orphan*/ set_if_up(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  switch (argc) {
  case 1:
    print_interface_info("eth0");
    break;
  case 2:
    print_interface_info(argv[1]);
    break;
  case 3:
    if (strcmp("up", argv[2]) == 0) {
      set_if_up(argv[1]);
    } else if (strcmp("down", argv[2]) == 0) {
      set_if_down(argv[1]);
    } else {
      printf("unknown command %s.\n", argv[2]);
    }
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     119c <main+0x4c>
jmp    117a <main+0x2a>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11ad <main+0x5d>
jmp    118b <main+0x3b>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     11bf <main+0x6f>
jmp    123b <main+0xeb>
lea    0xe5d(%rip),%rdi
call   1070 <print_interface_info@plt>
jmp    123b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <print_interface_info@plt>
jmp    123b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe37(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ee <main+0x9e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <set_if_up@plt>
jmp    1236 <main+0xe6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe0b(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    121d <main+0xcd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <set_if_down@plt>
jmp    1231 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xde1(%rip),%rdi
call   1030 <printf@plt>
jmp    1236 <main+0xe6>
jmp    123b <main+0xeb>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1174 <main+0x24>
cmp    $0x2,%edi
je     11af <main+0x5f>
cmp    $0x1,%edi
jne    11ce <main+0x7e>
lea    0xe93(%rip),%rdi
call   1070 <print_interface_info@plt>
jmp    11ce <main+0x7e>
mov    0x10(%rbx),%r14
lea    0xe86(%rip),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ba <main+0x6a>
lea    0xe76(%rip),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11c5 <main+0x75>
lea    0xe68(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
jmp    11ce <main+0x7e>
mov    0x8(%rbx),%rdi
call   1070 <print_interface_info@plt>
jmp    11ce <main+0x7e>
mov    0x8(%rbx),%rdi
call   1050 <set_if_up@plt>
jmp    11ce <main+0x7e>
mov    0x8(%rbx),%rdi
call   1060 <set_if_down@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"eth0\00"
@.str.1 = [3 x i8] c"up\00"
@.str.2 = [5 x i8] c"down\00"
@.str.3 = [21 x i8] c"unknown command %s.\0A\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 = load i32, i32* %4
switch i32 %6, label %43 [
i32 1, label %7
i32 2, label %9
i32 3, label %14
]
7: ; preds = %2
%8 = call i32 @print_interface_info(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %43
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @print_interface_info(i8* %12)
br label %43
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @set_if_up(i8* %23)
br label %42
25: ; preds = %14
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @set_if_down(i8* %34)
br label %41
36: ; preds = %25
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %36, %31
br label %42
42: ; preds = %41, %20
br label %43
43: ; preds = %2, %42, %9, %7
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"eth0\00"
@.str.1 = [3 x i8] c"up\00"
@.str.2 = [5 x i8] c"down\00"
@.str.3 = [21 x i8] c"unknown command %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %27 [
i32 1, label %3
i32 2, label %5
i32 3, label %9
]
3: ; preds = %2
%4 = tail call i32 @print_interface_info(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %27
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @print_interface_info(i8* %7)
br label %27
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @set_if_up(i8* %16)
br label %27
18: ; preds = %9
%19 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %11)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32 @set_if_down(i8* %23)
br label %27
25: ; preds = %18
%26 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %27
27: ; preds = %14, %25, %21, %2, %5, %3
ret i32 0
}