#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(int, int);
scalar_t__ fork();
int server(int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int usage(int, char **);
int main(int argc, char **argv) {
  if (argc != 3) {
    return usage(argc, argv);
  }
  int pings = 0;
  int size = 0;
  sscanf(argv[1], "%d", &pings);
  sscanf(argv[2], "%d", &size);
  if (fork() == 0) {
    return client(pings, size);
  } else {
    return server(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   $0x3,-0x8(%rbp)
je     1184 <main+0x34>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11f4 <main+0xa4>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5f(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe47(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    11e6 <main+0x96>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <client@plt>
mov    %eax,-0x4(%rbp)
jmp    11f4 <main+0xa4>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <server@plt>
mov    %eax,-0x4(%rbp)
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    $0x3,%edi
jne    11ac <main+0x5c>
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
mov    0x8(%rbx),%rdi
lea    0xe8a(%rip),%r14
lea    0x4(%rsp),%rdx
mov    %r14,%rsi
call   1040 <sscanf@plt>
mov    0x10(%rbx),%rdi
mov    %rsp,%rdx
mov    %r14,%rsi
call   1040 <sscanf@plt>
xor    %eax,%eax
call   1070 <fork@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
test   %rax,%rax
je     11bb <main+0x6b>
call   1030 <server@plt>
jmp    11c0 <main+0x70>
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <usage@plt>
call   1060 <client@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\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, 3
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 %33
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 1
%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 2
%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 = call i64 (...) @fork()
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %14
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = call i32 @client(i32 %26, i32 %27)
store i32 %28, i32* %3
br label %33
29: ; preds = %14
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = call i32 @server(i32 %30, i32 %31)
store i32 %32, i32* %3
br label %33
33: ; preds = %29, %25, %10
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i32 %0, 3
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @usage(i32 %0, i8** %1)
br label %27
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 1
%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 2
%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 = call i64 (...) @fork()
%18 = icmp eq i64 %17, 0
%19 = load i32, i32* %3
%20 = load i32, i32* %4
br i1 %18, label %21, label %23
21: ; preds = %8
%22 = call i32 @client(i32 %19, i32 %20)
br label %25
23: ; preds = %8
%24 = call i32 @server(i32 %19, i32 %20)
br label %25
25: ; preds = %23, %21
%26 = phi i32 [ %22, %21 ], [ %24, %23 ]
br label %27
27: ; preds = %25, %6
%28 = phi i32 [ %7, %6 ], [ %26, %25 ]
ret i32 %28
}