#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, char **);
int server_main();
int /*<<< orphan*/ strcmp(char *, char *);
int wetalk_usage(char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    return wetalk_usage(argv[0]);
  }
  if (!strcmp(argv[1], "-d")) {
    return server_main();
  } else if (!strcmp(argv[1], "-r") || !strcmp(argv[1], "-c")) {
    return client_main(argc - 1, argv + 1);
  }
  return wetalk_usage(argv[0]);
}


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    1174 <main+0x34>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <wetalk_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1209 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11a0 <main+0x60>
mov    $0x0,%al
call   1060 <server_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1209 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11da <main+0x9a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11f5 <main+0xb5>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1040 <client_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1209 <main+0xc9>
jmp    11fa <main+0xba>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <wetalk_usage@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jne    1158 <main+0x18>
mov    (%rbx),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <wetalk_usage@plt>
mov    %edi,%ebp
mov    0x8(%rbx),%r14
lea    0xe9b(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11ac <main+0x6c>
lea    0xe8b(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1197 <main+0x57>
lea    0xe7b(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    114c <main+0xc>
add    $0x8,%rbx
add    $0xffffffff,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <client_main@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <server_main@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"-c\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 %13
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @wetalk_usage(i8* %11)
store i32 %12, i32* %3
br label %45
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = call i32 (...) @server_main()
store i32 %20, i32* %3
br label %45
21: ; preds = %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %21
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %27, %21
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = call i32 @client_main(i32 %35, i8** %37)
store i32 %38, i32* %3
br label %45
39: ; preds = %27
br label %40
40: ; preds = %39
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @wetalk_usage(i8* %43)
store i32 %44, i32* %3
br label %45
45: ; preds = %40, %33, %19, %8
%46 = load i32, i32* %3
ret i32 %46
}

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