#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 /*<<< orphan*/ client(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ server(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr,
            "Usage is:\ntransfer -c 'HOST IP'\ntransfer -s 'path/to/file'\n");
    exit(1);
  }
  char *option = (argv[1] + 1);
  char *str_arg = argv[2];
  if (*option == 'c') {
    printf("Client mode.\n");
    client(str_arg);
  } else if (*option == 's') {
    printf("Server mode.\n");
    server(str_arg);
  } else {
    printf("Usage is:\ntransfer -c 'HOST IP'\ntransfer -s 'path/to/file'\n");
    exit(2);
  }
  return 0;
}


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     118f <main+0x3f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    11d5 <main+0x85>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <client@plt>
jmp    121a <main+0xca>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    11ff <main+0xaf>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <server@plt>
jmp    1215 <main+0xc5>
lea    0xdfa(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
jmp    121a <main+0xca>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jne    1197 <main+0x47>
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%rbx
mov    0x1(%rax),%al
cmp    $0x73,%al
je     117f <main+0x2f>
cmp    $0x63,%al
jne    11b6 <main+0x66>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <client@plt>
jmp    1193 <main+0x43>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <server@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [60 x i8] c"Usage is:\0Atransfer -c 'HOST IP'\0Atransfer -s 'path/to/file'\0A\00"
@.str.1 = [14 x i8] c"Client mode.\0A\00"
@.str.2 = [14 x i8] c"Server mode.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
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* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8* %18, i8** %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
store i8* %21, i8** %7
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 99
br i1 %25, label %26, label %30
26: ; preds = %14
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%28 = load i8*, i8** %7
%29 = call i32 @client(i8* %28)
br label %43
30: ; preds = %14
%31 = load i8*, i8** %6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 115
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%37 = load i8*, i8** %7
%38 = call i32 @server(i8* %37)
br label %42
39: ; preds = %30
%40 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%41 = call i32 @exit(i32 2)
unreachable
42: ; preds = %35
br label %43
43: ; preds = %42, %26
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [60 x i8] c"Usage is:\0Atransfer -c 'HOST IP'\0Atransfer -s 'path/to/file'\0A\00"
@str = [59 x i8] c"Usage is:\0Atransfer -c 'HOST IP'\0Atransfer -s 'path/to/file'\00"
@str.3 = [13 x i8] c"Server mode.\00"
@str.4 = [13 x i8] c"Client mode.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = load i8, i8* %11
switch i8 %14, label %21 [
i8 99, label %15
i8 115, label %18
]
15: ; preds = %8
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%17 = tail call i32 @client(i8* %13)
br label %24
18: ; preds = %8
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.3, i64 0, i64 0))
%20 = tail call i32 @server(i8* %13)
br label %24
21: ; preds = %8
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 2)
unreachable
24: ; preds = %18, %15
ret i32 0
}