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


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   $0x2,-0x8(%rbp)
je     1184 <main+0x34>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11ce <main+0x7e>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    11c4 <main+0x74>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe55(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x14(%rbp),%edi
call   1060 <client@plt>
mov    %eax,-0x4(%rbp)
jmp    11ce <main+0x7e>
mov    $0x0,%al
call   1030 <server@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1175 <main+0x25>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     1182 <main+0x32>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1030 <server@plt>
mov    %rbx,%rsi
add    $0x10,%rsp
pop    %rbx
jmp    1050 <usage@plt>
movl   $0x0,0xc(%rsp)
mov    0x8(%rbx),%rdi
lea    0xe6b(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%edi
call   1060 <client@plt>
add    $0x10,%rsp
pop    %rbx
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @usage(i32 %10, i8** %11)
store i32 %12, i32* %3
br label %25
13: ; preds = %2
%14 = call i64 (...) @fork()
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
store i32 0, i32* %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%21 = load i32, i32* %6
%22 = call i32 @client(i32 %21)
store i32 %22, i32* %3
br label %25
23: ; preds = %13
%24 = call i32 (...) @server()
store i32 %24, i32* %3
br label %25
25: ; preds = %23, %16, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @usage(i32 %0, i8** %1)
br label %19
7: ; preds = %2
%8 = tail call i64 (...) @fork()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = call i32 @client(i32 %15)
br label %19
17: ; preds = %7
%18 = tail call i32 (...) @server()
br label %19
19: ; preds = %17, %10, %5
%20 = phi i32 [ %6, %5 ], [ %16, %10 ], [ %18, %17 ]
ret i32 %20
}