#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*/ client_count_tcp(char *, char *, char *);
int /*<<< orphan*/ client_count_udp(char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getopt(int, char **, char *);
int getpid();
char *optarg;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ server_loop_tcp(char *);
int /*<<< orphan*/ server_loop_udp(char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  char *mode = "";
  char *server_port = "1234";
  char *server_ip = "127.0.0.1";
  char *number_input = "100";
  char protocol = 't';
  int o;
  while ((o = getopt(argc, argv, "p:h:m:n:s:")) != -1) {
    switch (o) {
    case 'p':
      server_port = optarg;
      break;
    case 'h':
      server_ip = optarg;
      break;
    case 'm':
      mode = optarg;
      break;
    case 'n':
      number_input = optarg;
      break;
    case 's':
      if (optarg[0] == 'T' || optarg[0] == 't') {
        protocol = 't';
      } else if (optarg[0] == 'U' || optarg[0] == 'u') {
        protocol = 'u';
      } else {
        fprintf(stderr, "Option %c accepts either TCP or UDP\n", optopt);
      }
      break;
    case '?':
      if (optopt == 'm' || optopt == 'p' || optopt == 'h') {
        fprintf(stderr, "Option %c requires an argument.\n", optopt);
      } else {
        fprintf(stderr, "Unknown argument: %c.\n", optopt);
      }
      break;
    }
  }
  if (strlen(mode) == 6) {
    if (strncmp(mode, "server", 6) == 0) {
      printf("LatencyCount[%d] works on server mode!\n", getpid());
      printf("        Local Server Port : %s\n", server_port);
      switch (protocol) {
      case 't':
        printf("        Server's Protocol : TCP\n");
        server_loop_tcp(server_port);
        break;
      case 'u':
        printf("        Server's Protocol : UDP\n");
        server_loop_udp(server_port);
        break;
      }
      return 0;
    } else if (strncmp(mode, "client", 6) == 0) {
      printf("LatencyCount[%d] works on client mode!\n", getpid());
      printf("        Remote Server IP  : %s\n", server_ip);
      printf("        Remote Server Port: %s\n", server_port);
      printf("        Connecting Times  : %s\n", number_input);
      switch (protocol) {
      case 't':
        printf("        Client's Protocol : TCP\n");
        client_count_tcp(server_ip, server_port, number_input);
        break;
      case 'u':
        printf("        Client's Protocol : UDP\n");
        client_count_udp(server_ip, server_port, number_input);
        break;
      }
      return 0;
    }
  }
  printf("LatencyCount[%d] doesn't work. Please choose a mode!\n", getpid());
  printf("Usage:\n        -m client or server\n        -h server's ip\n        "
         "-p port\n        -n times of loop\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x1129(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xf0c(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xf06(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xf05(%rip),%rax
mov    %rax,-0x30(%rbp)
movb   $0x74,-0x31(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xef3(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x38(%rbp)
cmp    $0xffffffff,%eax
je     1387 <main+0x1e7>
mov    -0x38(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x34,%eax
ja     1382 <main+0x1e2>
mov    -0x40(%rbp),%rax
lea    0xddb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2dc3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1382 <main+0x1e2>
mov    0x2db0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1382 <main+0x1e2>
mov    0x2d9d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1382 <main+0x1e2>
mov    0x2d8a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1382 <main+0x1e2>
mov    0x2d77(%rip),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x54,%eax
je     12a6 <main+0x106>
mov    0x2d61(%rip),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x74,%eax
jne    12af <main+0x10f>
movb   $0x74,-0x31(%rbp)
jmp    1307 <main+0x167>
mov    0x2d42(%rip),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x55,%eax
je     12db <main+0x13b>
mov    0x2d2c(%rip),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x75,%eax
jne    12e4 <main+0x144>
movb   $0x75,-0x31(%rbp)
jmp    1302 <main+0x162>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
mov    0x2cec(%rip),%rax
mov    (%rax),%edx
lea    0xdf5(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1307 <main+0x167>
jmp    1382 <main+0x1e2>
mov    0x2ccd(%rip),%rax
cmpl   $0x6d,(%rax)
je     133c <main+0x19c>
mov    0x2cbd(%rip),%rax
cmpl   $0x70,(%rax)
je     133c <main+0x19c>
mov    0x2cad(%rip),%rax
cmpl   $0x68,(%rax)
jne    135f <main+0x1bf>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
mov    0x2c94(%rip),%rax
mov    (%rax),%edx
lea    0xdc2(%rip),%rsi
call   1080 <fprintf@plt>
jmp    137d <main+0x1dd>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
mov    0x2c71(%rip),%rax
mov    (%rax),%edx
lea    0xdc0(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1382 <main+0x1e2>
jmp    11e6 <main+0x46>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x6,%eax
jne    153d <main+0x39d>
mov    -0x18(%rbp),%rdi
lea    0xdab(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    144b <main+0x2ab>
xor    %eax,%eax
mov    %al,-0x45(%rbp)
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x45(%rbp),%al
lea    0xd88(%rip),%rdi
call   1060 <printf@plt>
mov    -0x45(%rbp),%al
mov    -0x20(%rbp),%rsi
lea    0xd9d(%rip),%rdi
call   1060 <printf@plt>
movsbl -0x31(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x74,%eax
je     140c <main+0x26c>
jmp    13fb <main+0x25b>
mov    -0x44(%rbp),%eax
sub    $0x75,%eax
je     1428 <main+0x288>
jmp    143f <main+0x29f>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <server_loop_tcp@plt>
jmp    143f <main+0x29f>
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1090 <server_loop_udp@plt>
movl   $0x0,-0x4(%rbp)
jmp    1569 <main+0x3c9>
mov    -0x18(%rbp),%rdi
lea    0xd8a(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1533 <main+0x393>
xor    %eax,%eax
mov    %al,-0x4d(%rbp)
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x4d(%rbp),%al
lea    0xd67(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4d(%rbp),%al
mov    -0x28(%rbp),%rsi
lea    0xd7c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4d(%rbp),%al
mov    -0x20(%rbp),%rsi
lea    0xd89(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4d(%rbp),%al
mov    -0x30(%rbp),%rsi
lea    0xd96(%rip),%rdi
call   1060 <printf@plt>
movsbl -0x31(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x74,%eax
je     14e4 <main+0x344>
jmp    14d3 <main+0x333>
mov    -0x4c(%rbp),%eax
sub    $0x75,%eax
je     1508 <main+0x368>
jmp    1527 <main+0x387>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10a0 <client_count_tcp@plt>
jmp    1527 <main+0x387>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10c0 <client_count_udp@plt>
movl   $0x0,-0x4(%rbp)
jmp    1569 <main+0x3c9>
jmp    1538 <main+0x398>
jmp    153d <main+0x39d>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x74,%cl
lea    0xf9f(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xf89(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xf78(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x10fa(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xf73(%rip),%r14
lea    0xdfd(%rip),%r12
mov    0x2dee(%rip),%r13
jmp    1220 <main+0x70>
mov    0x0(%r13),%rax
mov    %rax,0x18(%rsp)
mov    %r15d,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,%r15d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10c0 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x34,%ecx
ja     12c8 <main+0x118>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
mov    %r15d,%ecx
jmp    *%rax
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
lea    -0x68(%rdx),%eax
cmp    $0x8,%eax
ja     12d6 <main+0x126>
mov    $0x121,%ecx
bt     %eax,%ecx
jae    12d6 <main+0x126>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
lea    0xf2c(%rip),%rsi
jmp    12e6 <main+0x136>
mov    0x0(%r13),%rax
mov    %rax,0x10(%rsp)
mov    %r15d,%ecx
jmp    1220 <main+0x70>
mov    0x0(%r13),%rax
mov    %rax,0x20(%rsp)
mov    %r15d,%ecx
jmp    1220 <main+0x70>
mov    0x0(%r13),%rax
mov    %rax,0x8(%rsp)
mov    %r15d,%ecx
jmp    1220 <main+0x70>
mov    0x0(%r13),%rax
movzbl (%rax),%eax
add    $0xac,%al
cmp    $0x21,%al
ja     12f3 <main+0x143>
movzbl %al,%eax
lea    0xe1e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    $0x74,%cl
jmp    *%rax
mov    $0x75,%cl
jmp    1220 <main+0x70>
mov    %r15d,%ecx
cmp    $0xffffffff,%eax
jne    1220 <main+0x70>
jmp    130e <main+0x15e>
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
lea    0xeda(%rip),%rsi
call   1090 <fprintf@plt>
mov    %r15d,%ecx
jmp    1220 <main+0x70>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
mov    0x2cdd(%rip),%rax
mov    (%rax),%edx
lea    0xe6e(%rip),%rsi
jmp    12e6 <main+0x136>
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    $0x6,%eax
jne    1356 <main+0x1a6>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     138a <main+0x1da>
lea    0xee6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13d7 <main+0x227>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xf51(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xf77(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xe46(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe5e(%rip),%rdi
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x75,%r15b
jne    1455 <main+0x2a5>
lea    0xfc6(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   10a0 <server_loop_udp@plt>
jmp    1379 <main+0x1c9>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xe48(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe60(%rip),%rdi
mov    0x10(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe6a(%rip),%rdi
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe74(%rip),%rdi
mov    0x18(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x75,%r15b
jne    146e <main+0x2be>
lea    0xf11(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   10d0 <client_count_udp@plt>
jmp    1379 <main+0x1c9>
lea    0xf52(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1080 <server_loop_tcp@plt>
jmp    1379 <main+0x1c9>
lea    0xef9(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   10b0 <client_count_tcp@plt>
jmp    1379 <main+0x1c9>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"1234\00"
@.str.2 = [10 x i8] c"127.0.0.1\00"
@.str.3 = [4 x i8] c"100\00"
@.str.4 = [11 x i8] c"p:h:m:n:s:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.5 = [37 x i8] c"Option %c accepts either TCP or UDP\0A\00"
@optopt = global i32 0
@.str.6 = [33 x i8] c"Option %c requires an argument.\0A\00"
@.str.7 = [23 x i8] c"Unknown argument: %c.\0A\00"
@.str.8 = [7 x i8] c"server\00"
@.str.9 = [40 x i8] c"LatencyCount[%d] works on server mode!\0A\00"
@.str.10 = [32 x i8] c" Local Server Port : %s\0A\00"
@.str.11 = [33 x i8] c" Server's Protocol : TCP\0A\00"
@.str.12 = [33 x i8] c" Server's Protocol : UDP\0A\00"
@.str.13 = [7 x i8] c"client\00"
@.str.14 = [40 x i8] c"LatencyCount[%d] works on client mode!\0A\00"
@.str.15 = [32 x i8] c" Remote Server IP : %s\0A\00"
@.str.16 = [32 x i8] c" Remote Server Port: %s\0A\00"
@.str.17 = [32 x i8] c" Connecting Times : %s\0A\00"
@.str.18 = [33 x i8] c" Client's Protocol : TCP\0A\00"
@.str.19 = [33 x i8] c" Client's Protocol : UDP\0A\00"
@.str.20 = [54 x i8] c"LatencyCount[%d] doesn't work. Please choose a mode!\0A\00"
@.str.21 = [100 x i8] c"Usage:\0A -m client or server\0A -h server's ip\0A -p port\0A -n times of loop\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %9
store i8 116, i8* %10
br label %12
12: ; preds = %77, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 %15, i32* %11
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %78
17: ; preds = %12
%18 = load i32, i32* %11
switch i32 %18, label %77 [
i32 112, label %19
i32 104, label %21
i32 109, label %23
i32 110, label %25
i32 115, label %27
i32 63, label %59
]
19: ; preds = %17
%20 = load i8*, i8** @optarg
store i8* %20, i8** %7
br label %77
21: ; preds = %17
%22 = load i8*, i8** @optarg
store i8* %22, i8** %8
br label %77
23: ; preds = %17
%24 = load i8*, i8** @optarg
store i8* %24, i8** %6
br label %77
25: ; preds = %17
%26 = load i8*, i8** @optarg
store i8* %26, i8** %9
br label %77
27: ; preds = %17
%28 = load i8*, i8** @optarg
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 84
br i1 %32, label %39, label %33
33: ; preds = %27
%34 = load i8*, i8** @optarg
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 116
br i1 %38, label %39, label %40
39: ; preds = %33, %27
store i8 116, i8* %10
br label %58
40: ; preds = %33
%41 = load i8*, i8** @optarg
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 85
br i1 %45, label %52, label %46
46: ; preds = %40
%47 = load i8*, i8** @optarg
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 117
br i1 %51, label %52, label %53
52: ; preds = %46, %40
store i8 117, i8* %10
br label %57
53: ; preds = %46
%54 = load i32, i32* @stderr
%55 = load i32, i32* @optopt
%56 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %53, %52
br label %58
58: ; preds = %57, %39
br label %77
59: ; preds = %17
%60 = load i32, i32* @optopt
%61 = icmp eq i32 %60, 109
br i1 %61, label %68, label %62
62: ; preds = %59
%63 = load i32, i32* @optopt
%64 = icmp eq i32 %63, 112
br i1 %64, label %68, label %65
65: ; preds = %62
%66 = load i32, i32* @optopt
%67 = icmp eq i32 %66, 104
br i1 %67, label %68, label %72
68: ; preds = %65, %62, %59
%69 = load i32, i32* @stderr
%70 = load i32, i32* @optopt
%71 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %70)
br label %76
72: ; preds = %65
%73 = load i32, i32* @stderr
%74 = load i32, i32* @optopt
%75 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %72, %68
br label %77
77: ; preds = %17, %76, %58, %25, %23, %21, %19
br label %12
78: ; preds = %12
%79 = load i8*, i8** %6
%80 = call i32 @strlen(i8* %79)
%81 = icmp eq i32 %80, 6
br i1 %81, label %82, label %132
82: ; preds = %78
%83 = load i8*, i8** %6
%84 = call i64 @strncmp(i8* %83, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 6)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %102
86: ; preds = %82
%87 = call i32 (...) @getpid()
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i32 %87)
%89 = load i8*, i8** %7
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %89)
%91 = load i8, i8* %10
%92 = sext i8 %91 to i32
switch i32 %92, label %101 [
i32 116, label %93
i32 117, label %97
]
93: ; preds = %86
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%95 = load i8*, i8** %7
%96 = call i32 @server_loop_tcp(i8* %95)
br label %101
97: ; preds = %86
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
%99 = load i8*, i8** %7
%100 = call i32 @server_loop_udp(i8* %99)
br label %101
101: ; preds = %86, %97, %93
store i32 0, i32* %3
br label %136
102: ; preds = %82
%103 = load i8*, i8** %6
%104 = call i64 @strncmp(i8* %103, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i32 6)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %130
106: ; preds = %102
%107 = call i32 (...) @getpid()
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.14, i64 0, i64 0), i32 %107)
%109 = load i8*, i8** %8
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), i8* %109)
%111 = load i8*, i8** %7
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0), i8* %111)
%113 = load i8*, i8** %9
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0), i8* %113)
%115 = load i8, i8* %10
%116 = sext i8 %115 to i32
switch i32 %116, label %129 [
i32 116, label %117
i32 117, label %123
]
117: ; preds = %106
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.18, i64 0, i64 0))
%119 = load i8*, i8** %8
%120 = load i8*, i8** %7
%121 = load i8*, i8** %9
%122 = call i32 @client_count_tcp(i8* %119, i8* %120, i8* %121)
br label %129
123: ; preds = %106
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.19, i64 0, i64 0))
%125 = load i8*, i8** %8
%126 = load i8*, i8** %7
%127 = load i8*, i8** %9
%128 = call i32 @client_count_udp(i8* %125, i8* %126, i8* %127)
br label %129
129: ; preds = %106, %123, %117
store i32 0, i32* %3
br label %136
130: ; preds = %102
br label %131
131: ; preds = %130
br label %132
132: ; preds = %131, %78
%133 = call i32 (...) @getpid()
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.20, i64 0, i64 0), i32 %133)
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.21, i64 0, i64 0))
store i32 0, i32* %3
br label %136
136: ; preds = %132, %129, %101
%137 = load i32, i32* %3
ret i32 %137
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"1234\00"
@.str.2 = [10 x i8] c"127.0.0.1\00"
@.str.3 = [4 x i8] c"100\00"
@.str.4 = [11 x i8] c"p:h:m:n:s:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.5 = [37 x i8] c"Option %c accepts either TCP or UDP\0A\00"
@optopt = global i32 0
@.str.6 = [33 x i8] c"Option %c requires an argument.\0A\00"
@.str.7 = [23 x i8] c"Unknown argument: %c.\0A\00"
@.str.8 = [7 x i8] c"server\00"
@.str.9 = [40 x i8] c"LatencyCount[%d] works on server mode!\0A\00"
@.str.10 = [32 x i8] c" Local Server Port : %s\0A\00"
@.str.13 = [7 x i8] c"client\00"
@.str.14 = [40 x i8] c"LatencyCount[%d] works on client mode!\0A\00"
@.str.15 = [32 x i8] c" Remote Server IP : %s\0A\00"
@.str.16 = [32 x i8] c" Remote Server Port: %s\0A\00"
@.str.17 = [32 x i8] c" Connecting Times : %s\0A\00"
@.str.20 = [54 x i8] c"LatencyCount[%d] doesn't work. Please choose a mode!\0A\00"
@str = [99 x i8] c"Usage:\0A -m client or server\0A -h server's ip\0A -p port\0A -n times of loop\00"
@str.22 = [32 x i8] c" Client's Protocol : UDP\00"
@str.23 = [32 x i8] c" Client's Protocol : TCP\00"
@str.24 = [32 x i8] c" Server's Protocol : UDP\00"
@str.25 = [32 x i8] c" Server's Protocol : TCP\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %21, %2
%4 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ], [ %22, %21 ]
%5 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %2 ], [ %23, %21 ]
%6 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %2 ], [ %24, %21 ]
%7 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %2 ], [ %25, %21 ]
%8 = phi i8 [ 116, %2 ], [ %26, %21 ]
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
switch i32 %9, label %21 [
i32 -1, label %40
i32 112, label %10
i32 104, label %12
i32 109, label %14
i32 110, label %16
i32 115, label %18
i32 63, label %32
]
10: ; preds = %3
%11 = load i8*, i8** @optarg
br label %21
12: ; preds = %3
%13 = load i8*, i8** @optarg
br label %21
14: ; preds = %3
%15 = load i8*, i8** @optarg
br label %21
16: ; preds = %3
%17 = load i8*, i8** @optarg
br label %21
18: ; preds = %3
%19 = load i8*, i8** @optarg
%20 = load i8, i8* %19
switch i8 %20, label %28 [
i8 84, label %21
i8 116, label %21
i8 85, label %27
i8 117, label %27
]
21: ; preds = %18, %18, %3, %34, %37, %28, %27, %16, %14, %12, %10
%22 = phi i8* [ %4, %34 ], [ %4, %37 ], [ %4, %27 ], [ %4, %28 ], [ %4, %16 ], [ %15, %14 ], [ %4, %12 ], [ %4, %10 ], [ %4, %3 ], [ %4, %18 ], [ %4, %18 ]
%23 = phi i8* [ %5, %34 ], [ %5, %37 ], [ %5, %27 ], [ %5, %28 ], [ %5, %16 ], [ %5, %14 ], [ %5, %12 ], [ %11, %10 ], [ %5, %3 ], [ %5, %18 ], [ %5, %18 ]
%24 = phi i8* [ %6, %34 ], [ %6, %37 ], [ %6, %27 ], [ %6, %28 ], [ %6, %16 ], [ %6, %14 ], [ %13, %12 ], [ %6, %10 ], [ %6, %3 ], [ %6, %18 ], [ %6, %18 ]
%25 = phi i8* [ %7, %34 ], [ %7, %37 ], [ %7, %27 ], [ %7, %28 ], [ %17, %16 ], [ %7, %14 ], [ %7, %12 ], [ %7, %10 ], [ %7, %3 ], [ %7, %18 ], [ %7, %18 ]
%26 = phi i8 [ %8, %34 ], [ %8, %37 ], [ 117, %27 ], [ %8, %28 ], [ %8, %16 ], [ %8, %14 ], [ %8, %12 ], [ %8, %10 ], [ %8, %3 ], [ 116, %18 ], [ 116, %18 ]
br label %3
27: ; preds = %18, %18
br label %21
28: ; preds = %18
%29 = load i32, i32* @stderr
%30 = load i32, i32* @optopt
%31 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %21
32: ; preds = %3
%33 = load i32, i32* @optopt
switch i32 %33, label %37 [
i32 112, label %34
i32 109, label %34
i32 104, label %34
]
34: ; preds = %32, %32, %32
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %33)
br label %21
37: ; preds = %32
%38 = load i32, i32* @stderr
%39 = tail call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %33)
br label %21
40: ; preds = %3
%41 = tail call i32 @strlen(i8* %4)
%42 = icmp eq i32 %41, 6
br i1 %42, label %43, label %73
43: ; preds = %40
%44 = tail call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 6)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %57
46: ; preds = %43
%47 = tail call i32 (...) @getpid()
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i32 %47)
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %5)
%50 = icmp eq i8 %8, 117
br i1 %50, label %54, label %51
51: ; preds = %46
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.25, i64 0, i64 0))
%53 = tail call i32 @server_loop_tcp(i8* %5)
br label %77
54: ; preds = %46
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.24, i64 0, i64 0))
%56 = tail call i32 @server_loop_udp(i8* %5)
br label %77
57: ; preds = %43
%58 = tail call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i32 6)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %73
60: ; preds = %57
%61 = tail call i32 (...) @getpid()
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.14, i64 0, i64 0), i32 %61)
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), i8* %6)
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0), i8* %5)
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0), i8* %7)
%66 = icmp eq i8 %8, 117
br i1 %66, label %70, label %67
67: ; preds = %60
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.23, i64 0, i64 0))
%69 = tail call i32 @client_count_tcp(i8* %6, i8* %5, i8* %7)
br label %77
70: ; preds = %60
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.22, i64 0, i64 0))
%72 = tail call i32 @client_count_udp(i8* %6, i8* %5, i8* %7)
br label %77
73: ; preds = %57, %40
%74 = tail call i32 (...) @getpid()
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.20, i64 0, i64 0), i32 %74)
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str, i64 0, i64 0))
br label %77
77: ; preds = %67, %70, %51, %54, %73
ret i32 0
}