#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 client(char *, char *, int, int);
int server(char *, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int usage(int, char **);
int main(int argc, char **argv) {
  if (argc != 6) {
    return usage(argc, argv);
  }
  int pings = 0;
  int size = 0;
  sscanf(argv[4], "%d", &pings);
  sscanf(argv[5], "%d", &size);
  if (strcmp(argv[1], "CLIENT") == 0) {
    return client(argv[2], argv[3], pings, size);
  } else if (strcmp(argv[1], "SERVER") == 0) {
    return server(argv[3], pings, size);
  }
}


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)
cmpl   $0x6,-0x8(%rbp)
je     1184 <main+0x34>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1241 <main+0xf1>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe5f(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xe47(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe32(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1070 <client@plt>
mov    %eax,-0x4(%rbp)
jmp    1241 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <server@plt>
mov    %eax,-0x4(%rbp)
jmp    1241 <main+0xf1>
jmp    1241 <main+0xf1>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x6,%edi
jne    11d3 <main+0x83>
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
mov    0x20(%rbx),%rdi
lea    0xe8a(%rip),%r14
lea    0x4(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    0x28(%rbx),%rdi
mov    %rsp,%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    0x8(%rbx),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e2 <main+0x92>
mov    0x8(%rbx),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11f6 <main+0xa6>
mov    0x18(%rbx),%rdi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
call   1040 <server@plt>
jmp    11f6 <main+0xa6>
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <usage@plt>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
call   1070 <client@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"CLIENT\00"
@.str.2 = [7 x i8] c"SERVER\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 6
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @usage(i32 %11, i8** %12)
store i32 %13, i32* %3
br label %52
14: ; preds = %2
store i32 0, i32* %6
store i32 0, i32* %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 4
%17 = load i8*, i8** %16
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 5
%21 = load i8*, i8** %20
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%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 %38
28: ; preds = %14
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = call i32 @client(i8* %31, i8* %34, i32 %35, i32 %36)
store i32 %37, i32* %3
br label %52
38: ; preds = %14
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %38
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 3
%47 = load i8*, i8** %46
%48 = load i32, i32* %6
%49 = load i32, i32* %7
%50 = call i32 @server(i8* %47, i32 %48, i32 %49)
store i32 %50, i32* %3
br label %52
51: ; preds = %38
br label %52
52: ; preds = %10, %28, %44, %51
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"CLIENT\00"
@.str.2 = [7 x i8] c"SERVER\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i32 %0, 6
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @usage(i32 %0, i8** %1)
br label %41
8: ; preds = %2
%9 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%11 = getelementptr inbounds i8*, i8** %1, i64 4
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%14 = getelementptr inbounds i8*, i8** %1, i64 5
%15 = load i8*, i8** %14
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %8
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 @client(i8* %23, i8* %25, i32 %26, i32 %27)
br label %39
29: ; preds = %8
%30 = load i8*, i8** %17
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = getelementptr inbounds i8*, i8** %1, i64 3
%35 = load i8*, i8** %34
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 @server(i8* %35, i32 %36, i32 %37)
br label %39
39: ; preds = %29, %33, %21
%40 = phi i32 [ %28, %21 ], [ %38, %33 ], [ 0, %29 ]
br label %41
41: ; preds = %39, %6
%42 = phi i32 [ %7, %6 ], [ %40, %39 ]
ret i32 %42
}