#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_main();
int server_main(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    return client_main();
  } else if (!strncmp(argv[1], "-d", 2)) {
    if (argc == 2)
      return server_main(NULL);
    else if (argc == 3)
      return server_main(argv[2]);
  }
  usage(argv[0]);
  return 1;
}


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   $0x1,-0x8(%rbp)
jne    116f <main+0x2f>
mov    $0x0,%al
call   1040 <client_main@plt>
mov    %eax,-0x4(%rbp)
jmp    11ed <main+0xad>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11d5 <main+0x95>
cmpl   $0x2,-0x8(%rbp)
jne    11ac <main+0x6c>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <server_main@plt>
mov    %eax,-0x4(%rbp)
jmp    11ed <main+0xad>
cmpl   $0x3,-0x8(%rbp)
jne    11cb <main+0x8b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <server_main@plt>
mov    %eax,-0x4(%rbp)
jmp    11ed <main+0xad>
jmp    11d0 <main+0x90>
jmp    11d5 <main+0x95>
jmp    11da <main+0x9a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1155 <main+0x15>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <client_main@plt>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1187 <main+0x47>
mov    (%rbx),%rdi
call   1060 <usage@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
cmp    $0x3,%ebp
je     1195 <main+0x55>
cmp    $0x2,%ebp
jne    1173 <main+0x33>
xor    %edi,%edi
jmp    1199 <main+0x59>
mov    0x10(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <server_main@plt>

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**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @client_main()
store i32 %9, i32* %3
br label %37
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%15 = icmp ne i32 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %10
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @server_main(i8* null)
store i32 %20, i32* %3
br label %37
21: ; preds = %16
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @server_main(i8* %27)
store i32 %28, i32* %3
br label %37
29: ; preds = %21
br label %30
30: ; preds = %29
br label %31
31: ; preds = %30, %10
br label %32
32: ; preds = %31
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 @usage(i8* %35)
store i32 1, i32* %3
br label %37
37: ; preds = %32, %24, %19, %8
%38 = load i32, i32* %3
ret i32 %38
}

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