#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*/ doNormalMode(int);
int /*<<< orphan*/ doShellMode(int);
int init(int, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int socket;
  char address[] = "localhost";
  int portno = 10000;
  if (argc == 2 && !strcmp(argv[1], "shell")) {
    socket = init(portno, address, 1);
    0;
    doShellMode(socket);
  } else {
    socket = init(portno, address, 0);
    doNormalMode(socket);
  }
  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    0xea3(%rip),%rax
mov    %rax,-0x1e(%rbp)
mov    0xea0(%rip),%ax
mov    %ax,-0x16(%rbp)
movl   $0x2710,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11bb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11bb <main+0x7b>
mov    -0x24(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
call   1060 <init@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <doShellMode@plt>
jmp    11d4 <main+0x94>
mov    -0x24(%rbp),%edi
lea    -0x1e(%rbp),%rsi
xor    %edx,%edx
call   1060 <init@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <doNormalMode@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movabs $0x736f686c61636f6c,%rax
68 6f 73
mov    %rax,0x8(%rsp)
movw   $0x74,0x10(%rsp)
cmp    $0x2,%edi
jne    1173 <main+0x33>
mov    0x8(%rsi),%rdi
lea    0xea0(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     118d <main+0x4d>
lea    0x8(%rsp),%rsi
mov    $0x2710,%edi
xor    %edx,%edx
call   1060 <init@plt>
mov    %eax,%edi
call   1040 <doNormalMode@plt>
jmp    11a8 <main+0x68>
lea    0x8(%rsp),%rsi
mov    $0x2710,%edi
mov    $0x1,%edx
call   1060 <init@plt>
mov    %eax,%edi
call   1030 <doShellMode@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.address = [10 x i8] c"localhost\00"
@.str = [6 x i8] c"shell\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [10 x i8]* %7 to i8*
store i32 10000, i32* %8
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %24
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %12
%19 = load i32, i32* %8
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%21 = call i32 @init(i32 %19, i8* %20, i32 1)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = call i32 @doShellMode(i32 %22)
br label %30
24: ; preds = %12, %2
%25 = load i32, i32* %8
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%27 = call i32 @init(i32 %25, i8* %26, i32 0)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = call i32 @doNormalMode(i32 %28)
br label %30
30: ; preds = %24, %18
ret i32 0
}

LLVM IR (-O2):
@__const.main.address = [10 x i8] c"localhost\00"
@.str = [6 x i8] c"shell\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = call i32 @init(i32 10000, i8* %4, i32 1)
%13 = call i32 @doShellMode(i32 %12)
br label %17
14: ; preds = %6, %2
%15 = call i32 @init(i32 10000, i8* %4, i32 0)
%16 = call i32 @doNormalMode(i32 %15)
br label %17
17: ; preds = %14, %11
ret i32 0
}