#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int server_main(int, char **);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char *op_mode;
  if (argc < 2) {
    fprintf(stderr, "usage: gm [client|server]\n");
    return 1;
  }
  op_mode = argv[1];
  argc--;
  argv++;
  if (strcmp(op_mode, "client") == 0)
    return client_main();
  if (strcmp(op_mode, "server") == 0)
    return server_main(argc, argv);
  fprintf(stderr, "unrecognized operating mode %s\n", op_mode);
  return 1;
}


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)
jge    1183 <main+0x43>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <main+0x8d>
mov    $0x0,%al
call   1030 <client_main@plt>
mov    %eax,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    -0x18(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fb <main+0xbb>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <server_main@plt>
mov    %eax,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     1162 <main+0x22>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11ad <main+0x6d>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%r14
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b7 <main+0x77>
lea    0xe9c(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c2 <main+0x82>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <client_main@plt>
add    $0x8,%rbx
add    $0xffffffff,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <server_main@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage: gm [client|server]\0A\00"
@.str.1 = [7 x i8] c"client\00"
@.str.2 = [7 x i8] c"server\00"
@.str.3 = [32 x i8] c"unrecognized operating mode %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %37
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
%16 = load i32, i32* %4
%17 = add nsw i32 %16, -1
store i32 %17, i32* %4
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %5
%20 = load i8*, i8** %6
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %12
%24 = call i32 (...) @client_main()
store i32 %24, i32* %3
br label %37
25: ; preds = %12
%26 = load i8*, i8** %6
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32, i32* %4
%31 = load i8**, i8*** %5
%32 = call i32 @server_main(i32 %30, i8** %31)
store i32 %32, i32* %3
br label %37
33: ; preds = %25
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %6
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %35)
store i32 1, i32* %3
br label %37
37: ; preds = %33, %29, %23, %9
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage: gm [client|server]\0A\00"
@.str.1 = [7 x i8] c"client\00"
@.str.2 = [7 x i8] c"server\00"
@.str.3 = [32 x i8] c"unrecognized operating mode %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %23
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = add nsw i32 %0, -1
%11 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 (...) @client_main()
br label %23
15: ; preds = %7
%16 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @server_main(i32 %10, i8** %8)
br label %23
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %23
23: ; preds = %20, %18, %13, %4
%24 = phi i32 [ 1, %4 ], [ %14, %13 ], [ %19, %18 ], [ 1, %20 ]
ret i32 %24
}