#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ client(char *, char *);
int getopt_long(int, char **, char const *const, struct option const *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ help_exit();
int /*<<< orphan*/ no_argument;
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ required_argument;
int /*<<< orphan*/ server(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  char nick[64] = {};
  char sv_nameaddr[64] = {};
  const char *const short_options = "hc:n:";
  const struct option long_options[] = {{"help", no_argument, NULL, 'h'},
                                        {"conn", required_argument, NULL, 'c'},
                                        {"nick", required_argument, NULL, 'n'},
                                        {NULL, 0, NULL, 0}};
  int next_option;
  while ((next_option = getopt_long(argc, argv, short_options, long_options,
                                    NULL)) != -1) {
    switch (next_option) {
    case 'h':
      help_exit();
      break;
    case 'c':
      strncpy(sv_nameaddr, optarg, 64);
      printf("Connecting to %s\n", sv_nameaddr);
      break;
    case 'n':
      strncpy(nick, optarg, 64);
      printf("Nickname: %s\n", optarg);
      break;
    default:
      help_exit();
    }
  }
  if (!*nick) {
    printf("Please specify a nickname.\n");
    help_exit();
  }
  if (sv_nameaddr[0] == 0) {
    printf("Running as server\n");
    server(nick);
  } else {
    client(sv_nameaddr, nick);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    0xe4d(%rip),%rax
mov    %rax,-0x98(%rbp)
lea    -0x120(%rbp),%rdi
lea    0xe3e(%rip),%rax
mov    %rax,-0x120(%rbp)
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x118(%rbp)
movq   $0x0,-0x110(%rbp)
movl   $0x68,-0x108(%rbp)
add    $0x20,%rdi
lea    0xe0d(%rip),%rax
mov    %rax,-0x100(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%eax
mov    %al,-0xf8(%rbp)
movq   $0x0,-0xf0(%rbp)
movl   $0x63,-0xe8(%rbp)
add    $0x20,%rdi
lea    0xddc(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %al,-0xd8(%rbp)
movq   $0x0,-0xd0(%rbp)
movl   $0x6e,-0xc8(%rbp)
add    $0x20,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x120(%rbp),%rcx
lea    0xd7c(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <getopt_long@plt>
mov    %eax,-0x124(%rbp)
cmp    $0xffffffff,%eax
je     1361 <main+0x1f1>
mov    -0x124(%rbp),%eax
mov    %eax,-0x128(%rbp)
sub    $0x63,%eax
je     12eb <main+0x17b>
jmp    12b7 <main+0x147>
mov    -0x128(%rbp),%eax
sub    $0x68,%eax
je     12df <main+0x16f>
jmp    12cb <main+0x15b>
mov    -0x128(%rbp),%eax
sub    $0x6e,%eax
je     1320 <main+0x1b0>
jmp    1355 <main+0x1e5>
mov    $0x0,%al
call   1040 <help_exit@plt>
jmp    135c <main+0x1ec>
lea    -0x90(%rbp),%rdi
mov    0x2cff(%rip),%rax
mov    (%rax),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    -0x90(%rbp),%rsi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    135c <main+0x1ec>
lea    -0x50(%rbp),%rdi
mov    0x2ccd(%rip),%rax
mov    (%rax),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%rsi
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    135c <main+0x1ec>
mov    $0x0,%al
call   1040 <help_exit@plt>
jmp    126f <main+0xff>
cmpb   $0x0,-0x50(%rbp)
jne    1380 <main+0x210>
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <help_exit@plt>
movsbl -0x90(%rbp),%eax
cmp    $0x0,%eax
jne    13ac <main+0x23c>
lea    0xcba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1080 <server@plt>
jmp    13bc <main+0x24c>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1090 <client@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
lea    0xe43(%rip),%rax
mov    %rax,0x40(%rsp)
mov    0x2e01(%rip),%rax
mov    (%rax),%al
mov    %al,0x48(%rsp)
movq   $0x0,0x50(%rsp)
movl   $0x68,0x58(%rsp)
lea    0xe1e(%rip),%rax
mov    %rax,0x60(%rsp)
mov    0x2de7(%rip),%rax
mov    (%rax),%al
mov    %al,0x68(%rsp)
movq   $0x0,0x70(%rsp)
movl   $0x63,0x78(%rsp)
lea    0xdf9(%rip),%rcx
mov    %rcx,0x80(%rsp)
mov    %al,0x88(%rsp)
movq   $0x0,0x90(%rsp)
movl   $0x6e,0x98(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
lea    0xdac(%rip),%r14
lea    0x40(%rsp),%r15
mov    0x2d98(%rip),%r13
lea    0xc0(%rsp),%r12
jmp    1293 <main+0x123>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%rsi
mov    %rsp,%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    0x0(%r13),%rsi
lea    0xd9b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1060 <getopt_long@plt>
cmp    $0x67,%eax
jle    12c0 <main+0x150>
cmp    $0x6e,%eax
je     1270 <main+0x100>
cmp    $0x68,%eax
jmp    12e7 <main+0x177>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x63,%eax
jne    12e2 <main+0x172>
mov    0x0(%r13),%rsi
mov    %r12,%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0xd38(%rip),%rdi
mov    %r12,%rsi
jmp    128c <main+0x11c>
cmp    $0xffffffff,%eax
je     12f0 <main+0x180>
xor    %eax,%eax
call   1050 <help_exit@plt>
jmp    1293 <main+0x123>
cmpb   $0x0,(%rsp)
je     1312 <main+0x1a2>
cmpb   $0x0,0xc0(%rsp)
je     132f <main+0x1bf>
lea    0xc0(%rsp),%rdi
mov    %rsp,%rsi
call   1090 <client@plt>
jmp    1343 <main+0x1d3>
lea    0xd1c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <help_exit@plt>
cmpb   $0x0,0xc0(%rsp)
jne    1300 <main+0x190>
lea    0xd1a(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
call   1080 <server@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [6 x i8] c"hc:n:\00"
@.str.1 = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.2 = [5 x i8] c"conn\00"
@required_argument = global i32 0
@.str.3 = [5 x i8] c"nick\00"
@optarg = global i8* null
@.str.4 = [18 x i8] c"Connecting to %s\0A\00"
@.str.5 = [14 x i8] c"Nickname: %s\0A\00"
@.str.6 = [28 x i8] c"Please specify a nickname.\0A\00"
@.str.7 = [19 x i8] c"Running as server\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i8]
%7 = alloca [64 x i8]
%8 = alloca i8*
%9 = alloca [4 x %struct.option]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [64 x i8]* %6 to i8*
%12 = bitcast [64 x i8]* %7 to i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %8
%13 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %9, i64 0, i64 0
%14 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 1
%16 = load i32, i32* @no_argument
%17 = trunc i32 %16 to i8
store i8 %17, i8* %15
%18 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 2
store i32* null, i32** %18
%19 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 3
store i32 104, i32* %19
%20 = getelementptr inbounds %struct.option, %struct.option* %13, i64 1
%21 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 1
%23 = load i32, i32* @required_argument
%24 = trunc i32 %23 to i8
store i8 %24, i8* %22
%25 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 2
store i32* null, i32** %25
%26 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 3
store i32 99, i32* %26
%27 = getelementptr inbounds %struct.option, %struct.option* %20, i64 1
%28 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %28
%29 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 1
%30 = load i32, i32* @required_argument
%31 = trunc i32 %30 to i8
store i8 %31, i8* %29
%32 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 2
store i32* null, i32** %32
%33 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 3
store i32 110, i32* %33
%34 = getelementptr inbounds %struct.option, %struct.option* %27, i64 1
%35 = bitcast %struct.option* %34 to i8*
br label %36
36: ; preds = %60, %2
%37 = load i32, i32* %4
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %9, i64 0, i64 0
%40 = call i32 @getopt_long(i32 %37, i8** %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), %struct.option* %39, i32* null)
store i32 %40, i32* %10
%41 = icmp ne i32 %40, -1
br i1 %41, label %42, label %61
42: ; preds = %36
%43 = load i32, i32* %10
switch i32 %43, label %58 [
i32 104, label %44
i32 99, label %46
i32 110, label %52
]
44: ; preds = %42
%45 = call i32 (...) @help_exit()
br label %60
46: ; preds = %42
%47 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%48 = load i8*, i8** @optarg
%49 = call i32 @strncpy(i8* %47, i8* %48, i32 64)
%50 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %60
52: ; preds = %42
%53 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%54 = load i8*, i8** @optarg
%55 = call i32 @strncpy(i8* %53, i8* %54, i32 64)
%56 = load i8*, i8** @optarg
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %56)
br label %60
58: ; preds = %42
%59 = call i32 (...) @help_exit()
br label %60
60: ; preds = %58, %52, %46, %44
br label %36
61: ; preds = %36
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%63 = load i8, i8* %62
%64 = icmp ne i8 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%67 = call i32 (...) @help_exit()
br label %68
68: ; preds = %65, %61
%69 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %68
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%75 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%76 = call i32 @server(i8* %75)
br label %81
77: ; preds = %68
%78 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%79 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%80 = call i32 @client(i8* %78, i8* %79)
br label %81
81: ; preds = %77, %73
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [6 x i8] c"hc:n:\00"
@.str.1 = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.2 = [5 x i8] c"conn\00"
@required_argument = global i32 0
@.str.3 = [5 x i8] c"nick\00"
@optarg = global i8* null
@.str.4 = [18 x i8] c"Connecting to %s\0A\00"
@.str.5 = [14 x i8] c"Nickname: %s\0A\00"
@str = [27 x i8] c"Please specify a nickname.\00"
@str.8 = [18 x i8] c"Running as server\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = alloca [4 x %struct.option]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%8 = bitcast [4 x %struct.option]* %5 to i8*
%9 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0
%10 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 1
%12 = load i32, i32* @no_argument
%13 = trunc i32 %12 to i8
store i8 %13, i8* %11
%14 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 2
store i32* null, i32** %14
%15 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 3
store i32 104, i32* %15
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 1
%18 = load i32, i32* @required_argument
%19 = trunc i32 %18 to i8
store i8 %19, i8* %17
%20 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 2
store i32* null, i32** %20
%21 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 3
store i32 99, i32* %21
%22 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 1
store i8 %19, i8* %23
%24 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 2
store i32* null, i32** %24
%25 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 3
store i32 110, i32* %25
%26 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 3
%27 = bitcast %struct.option* %26 to i8*
br label %28
28: ; preds = %43, %2
%29 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.option* %9, i32* null)
switch i32 %29, label %41 [
i32 -1, label %44
i32 104, label %30
i32 99, label %32
i32 110, label %36
]
30: ; preds = %28
%31 = call i32 (...) @help_exit()
br label %43
32: ; preds = %28
%33 = load i8*, i8** @optarg
%34 = call i32 @strncpy(i8* %7, i8* %33, i32 64)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %7)
br label %43
36: ; preds = %28
%37 = load i8*, i8** @optarg
%38 = call i32 @strncpy(i8* %6, i8* %37, i32 64)
%39 = load i8*, i8** @optarg
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %39)
br label %43
41: ; preds = %28
%42 = call i32 (...) @help_exit()
br label %43
43: ; preds = %41, %36, %32, %30
br label %28
44: ; preds = %28
%45 = load i8, i8* %6
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%49 = call i32 (...) @help_exit()
br label %50
50: ; preds = %47, %44
%51 = load i8, i8* %7
%52 = icmp eq i8 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%55 = call i32 @server(i8* %6)
br label %58
56: ; preds = %50
%57 = call i32 @client(i8* %7, i8* %6)
br label %58
58: ; preds = %56, %53
ret i32 0
}