#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*/ exit(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ tcpconnect_client(int, char **);
int /*<<< orphan*/ tcpconnect_server(int, char **);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc < 2)
    usage();
  if (strcmp(argv[1], "server") == 0)
    tcpconnect_server(argc - 2, argv + 2);
  else if (strcmp(argv[1], "client") == 0)
    tcpconnect_client(argc - 2, argv + 2);
  else
    usage();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1177 <main+0x27>
mov    $0x0,%al
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ad <main+0x5d>
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   1040 <tcpconnect_server@plt>
jmp    11ef <main+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e3 <main+0x93>
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   1050 <tcpconnect_client@plt>
jmp    11ea <main+0x9a>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    11ef <main+0x9f>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jg     1164 <main+0x14>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1191 <main+0x41>
add    $0xfffffffe,%ebp
add    $0x10,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <tcpconnect_server@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x8(%rbx),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11be <main+0x6e>
add    $0xfffffffe,%ebp
add    $0x10,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <tcpconnect_client@plt>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
call   1060 <usage@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"server\00"
@.str.1 = [7 x i8] c"client\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
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @usage()
br label %10
10: ; preds = %8, %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %10
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = call i32 @tcpconnect_server(i32 %18, i8** %20)
br label %37
22: ; preds = %10
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %22
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = call i32 @tcpconnect_client(i32 %30, i8** %32)
br label %36
34: ; preds = %22
%35 = call i32 (...) @usage()
br label %36
36: ; preds = %34, %28
br label %37
37: ; preds = %36, %16
%38 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"server\00"
@.str.1 = [7 x i8] c"client\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = add nsw i32 %0, -2
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = tail call i32 @tcpconnect_server(i32 %12, i8** %13)
br label %25
15: ; preds = %6
%16 = load i8*, i8** %7
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = add nsw i32 %0, -2
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = tail call i32 @tcpconnect_client(i32 %20, i8** %21)
br label %25
23: ; preds = %15
%24 = tail call i32 (...) @usage()
br label %25
25: ; preds = %19, %23, %11
%26 = tail call i32 @exit(i32 0)
unreachable
}