#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*/ async_read(int /*<<< orphan*/, int);
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ client_init(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ server_init(int /*<<< orphan*/);
int tun_alloc(char *);
int main(int argc, char *argv[]) {
  int fd;
  if (argv[1][0] == 'c') {
    if ((fd = tun_alloc(argv[2])) < 0)
      exit(1);
    async_read(client_init(argv[3], atoi(argv[4])), fd);
  } else if (argv[1][0] == 's') {
    if ((fd = tun_alloc(argv[2])) < 0)
      exit(1);
    async_read(server_init(atoi(argv[3])), fd);
  }
  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    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    11e0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <tun_alloc@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11ad <main+0x4d>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1070 <atoi@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1060 <client_init@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
call   1050 <async_read@plt>
jmp    123a <main+0xda>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    1235 <main+0xd5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <tun_alloc@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1217 <main+0xb7>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1040 <server_init@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
call   1050 <async_read@plt>
jmp    123a <main+0xda>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
mov    (%rax),%al
cmp    $0x73,%al
je     119d <main+0x3d>
cmp    $0x63,%al
jne    11c5 <main+0x65>
mov    0x10(%rbx),%rdi
call   1030 <tun_alloc@plt>
test   %eax,%eax
js     11cc <main+0x6c>
mov    %eax,%ebp
mov    0x18(%rbx),%r14
mov    0x20(%rbx),%rdi
call   1070 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <client_init@plt>
jmp    11bc <main+0x5c>
mov    0x10(%rbx),%rdi
call   1030 <tun_alloc@plt>
test   %eax,%eax
js     11cc <main+0x6c>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1040 <server_init@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1050 <async_read@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 99
br i1 %13, label %14, label %33
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @tun_alloc(i8* %17)
store i32 %18, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
%30 = call i32 @client_init(i8* %25, i32 %29)
%31 = load i32, i32* %6
%32 = call i32 @async_read(i32 %30, i32 %31)
br label %58
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 115
br i1 %40, label %41, label %57
41: ; preds = %33
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @tun_alloc(i8* %44)
store i32 %45, i32* %6
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %41
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %41
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i32 @atoi(i8* %52)
%54 = call i32 @server_init(i32 %53)
%55 = load i32, i32* %6
%56 = call i32 @async_read(i32 %54, i32 %55)
br label %57
57: ; preds = %49, %33
br label %58
58: ; preds = %57, %22
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
switch i8 %5, label %34 [
i8 99, label %6
i8 115, label %21
]
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @tun_alloc(i8* %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %6
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = tail call i32 @client_init(i8* %15, i32 %18)
%20 = tail call i32 @async_read(i32 %19, i32 %9)
br label %34
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @tun_alloc(i8* %23)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %21
%29 = getelementptr inbounds i8*, i8** %1, i64 3
%30 = load i8*, i8** %29
%31 = tail call i32 @atoi(i8* %30)
%32 = tail call i32 @server_init(i32 %31)
%33 = tail call i32 @async_read(i32 %32, i32 %24)
br label %34
34: ; preds = %2, %28, %13
ret i32 0
}