#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*/ atoi(char *);
int /*<<< orphan*/ change_addr(char *, char *, char *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ tuntap_up(int /*<<< orphan*/, int, char **);
void tuntap_v2(int argc, char **argv) {
  char *op = argv[0];
  if (!strcmp(op, "up"))
    tuntap_up(atoi(argv[2]), argc - 3, argv + 3);
  else if (!strcmp(op, "add") || !strcmp(op, "del"))
    change_addr(argv[1], argv[2], argv[3], NULL, NULL);
  else {
    fprintf(stderr, "Bad tuntap op : '%s'\n", op);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<tuntap_v2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11ba <tuntap_v2+0x5a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
sub    $0x3,%esi
mov    -0x10(%rbp),%rdx
add    $0x18,%rdx
call   1060 <tuntap_up@plt>
jmp    123e <tuntap_v2+0xde>
mov    -0x18(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11ec <tuntap_v2+0x8c>
mov    -0x18(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1216 <tuntap_v2+0xb6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1080 <change_addr@plt>
jmp    1239 <tuntap_v2+0xd9>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xde1(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    123e <tuntap_v2+0xde>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tuntap_v2>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%r14
lea    0xe8d(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11bf <tuntap_v2+0x5f>
lea    0xe7d(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a5 <tuntap_v2+0x45>
lea    0xe6e(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    11df <tuntap_v2+0x7f>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    0x18(%rbx),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <change_addr@plt>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
add    $0xfffffffd,%ebp
add    $0x18,%rbx
mov    %eax,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <tuntap_up@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"up\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [4 x i8] c"del\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"Bad tuntap op : '%s'\0A\00"
define void @tuntap_v2(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i8**, i8*** %4
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 3
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = call i32 @tuntap_up(i32 %16, i32 %18, i8** %20)
br label %47
22: ; preds = %2
%23 = load i8*, i8** %5
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %41, label %30
30: ; preds = %26, %22
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %4
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = call i32 @change_addr(i8* %33, i8* %36, i8* %39, i32* null, i32* null)
br label %46
41: ; preds = %26
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %5
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %30
br label %47
47: ; preds = %46, %12
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"up\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [4 x i8] c"del\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"Bad tuntap op : '%s'\0A\00"
define void @tuntap_v2(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = add nsw i32 %0, -3
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = tail call i32 @tuntap_up(i32 %9, i32 %10, i8** %11)
br label %31
13: ; preds = %2
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %16, %13
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = tail call i32 @change_addr(i8* %21, i8* %23, i8* %25, i32* null, i32* null)
br label %31
27: ; preds = %16
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %19, %6
ret void
}