#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 */
typedef int /*<<< orphan*/ cmdArg;
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int createSocket(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ receiveFile(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sendFile(char *, int);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void client(int argc, char **argv) {
  if (argc < 3) {
    printf("Client mode requires an additional parameter! Usage:\n");
    printf("%s -C [servername or address]\n", argv[0]);
    exit(1);
  }
  int s_tcp;
  int doLoop = 1;
  char *buffer;
  int bufferSize = 65535;
  buffer = malloc(bufferSize * sizeof(char));
  char cmd[256], cmdArg[256];
  char *serverAddress = argv[2];
  s_tcp = createSocket(serverAddress, "CLIENT");
  printf(" OK!\nPlease choose one of the following commands:\n");
  printf("get [filename]   read file from server\n", argv[3]);
  printf("put [filename]   write local file to server\n", argv[3]);
  printf("quit             close client application\n\n", argv[3]);
  while (doLoop) {
    memset(buffer, 0, bufferSize);
    memset(cmd, 0, sizeof(cmd));
    memset(cmdArg, 0, sizeof(cmdArg));
    fgets(buffer, bufferSize, stdin);
    sscanf(buffer, "%s %s", cmd, cmdArg);
    if (strcmp(cmd, "quit") == 0) {
      doLoop = 0;
    } else if (strcmp(cmd, "get") == 0) {
      memset(buffer, 0, bufferSize);
      strcpy(buffer, "@SEND ");
      strcat(buffer, cmdArg);
      send(s_tcp, buffer, strlen(buffer), 0);
      memset(buffer, 0, bufferSize);
      recv(s_tcp, buffer, bufferSize, 0);
      printf("%s", buffer);
      send(s_tcp, "OK", 4, 0);
      receiveFile(cmdArg, s_tcp, 0);
    } else if (strcmp(cmd, "put") == 0) {
      memset(buffer, 0, bufferSize);
      strcpy(buffer, "@RECEIVE ");
      strcat(buffer, cmdArg);
      send(s_tcp, buffer, strlen(buffer), 0);
      memset(buffer, 0, bufferSize);
      recv(s_tcp, buffer, bufferSize, 0);
      sendFile(cmdArg, s_tcp);
      memset(buffer, 0, bufferSize);
      recv(s_tcp, buffer, bufferSize, 0);
      printf("Completion Answer from Server: %s\n", buffer);
    } else {
      printf("Command %s unknown\n", cmd);
    }
    printf("\n");
  }
  printf("Closing connection.\n");
  close(s_tcp);
}


x86 assembly (clang, -O0):
<client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    1249 <client+0x49>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
movl   $0x1,-0x18(%rbp)
movl   $0xffff,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1040 <createSocket@plt>
mov    %eax,-0x14(%rbp)
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     1568 <client+0x368>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
lea    -0x230(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2cbd(%rip),%rax
mov    (%rax),%edx
call   10b0 <fgets@plt>
mov    -0x20(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    -0x230(%rbp),%rcx
lea    0xdc5(%rip),%rsi
call   10f0 <sscanf@plt>
lea    -0x130(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1379 <client+0x179>
movl   $0x0,-0x18(%rbp)
jmp    1555 <client+0x355>
lea    -0x130(%rbp),%rdi
lea    0xd94(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1454 <client+0x254>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x20(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1110 <strcat@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x244(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x240(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x244(%rbp),%edi
mov    -0x240(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x20(%rbp),%rsi
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%edi
lea    0xcf4(%rip),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
lea    -0x230(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   10d0 <receiveFile@plt>
jmp    1550 <client+0x350>
lea    -0x130(%rbp),%rdi
lea    0xcc7(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1536 <client+0x336>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x20(%rbp),%rdi
lea    0xca3(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1110 <strcat@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x254(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x250(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x254(%rbp),%edi
mov    -0x250(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    -0x230(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1100 <sendFile@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x20(%rbp),%rsi
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    154b <client+0x34b>
lea    -0x130(%rbp),%rsi
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1550 <client+0x350>
jmp    1555 <client+0x355>
lea    0xbb2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    12df <client+0xdf>
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jle    14d3 <client+0x2b3>
mov    $0xffff,%edi
call   1100 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   1050 <createSocket@plt>
mov    %eax,%r14d
lea    0xe20(%rip),%rdi
call   1070 <puts@plt>
lea    0xe46(%rip),%rdi
call   1070 <puts@plt>
lea    0xe61(%rip),%rdi
call   1070 <puts@plt>
lea    0xe81(%rip),%rdi
call   1070 <puts@plt>
lea    0x100(%rsp),%rbp
mov    %rsp,%r15
lea    0xd87(%rip),%r12
lea    0xd86(%rip),%r13
jmp    134f <client+0x12f>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffff,%edx
call   10b0 <memset@plt>
mov    %rbx,%rdi
lea    0xd6c(%rip),%rsi
call   1060 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1130 <strcat@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffff,%edx
call   10b0 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xffff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xd11(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %r14d,%edi
lea    0xd10(%rip),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    %r15,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   10f0 <receiveFile@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffff,%edx
call   10b0 <memset@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10b0 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10b0 <memset@plt>
mov    0x2c65(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffff,%esi
call   10d0 <fgets@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1110 <sscanf@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   10e0 <strcmp@plt>
test   %rax,%rax
je     14a3 <client+0x283>
mov    %rbp,%rdi
lea    0xc70(%rip),%rsi
call   10e0 <strcmp@plt>
test   %rax,%rax
je     12b0 <client+0x90>
mov    %rbp,%rdi
lea    0xc66(%rip),%rsi
call   10e0 <strcmp@plt>
test   %rax,%rax
je     1400 <client+0x1e0>
lea    0xc86(%rip),%rdi
mov    %rbp,%rsi
jmp    1497 <client+0x277>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffff,%edx
call   10b0 <memset@plt>
mov    %rbx,%rdi
lea    0xc2a(%rip),%rsi
call   1060 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1130 <strcat@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffff,%edx
call   10b0 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xffff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1120 <sendFile@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffff,%edx
call   10b0 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xffff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xbb9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    1345 <client+0x125>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xc80(%rip),%rdi
call   1070 <puts@plt>
mov    %r14d,%edi
call   10c0 <close@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc6e(%rip),%rdi
call   1070 <puts@plt>
mov    0x0(%rbp),%rsi
lea    0xb16(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"Client mode requires an additional parameter! Usage:\0A\00"
@.str.1 = [31 x i8] c"%s -C [servername or address]\0A\00"
@.str.2 = [7 x i8] c"CLIENT\00"
@.str.3 = [51 x i8] c" OK!\0APlease choose one of the following commands:\0A\00"
@.str.4 = [40 x i8] c"get [filename] read file from server\0A\00"
@.str.5 = [45 x i8] c"put [filename] write local file to server\0A\00"
@.str.6 = [44 x i8] c"quit close client application\0A\0A\00"
@stdin = global i32 0
@.str.7 = [6 x i8] c"%s %s\00"
@.str.8 = [5 x i8] c"quit\00"
@.str.9 = [4 x i8] c"get\00"
@.str.10 = [7 x i8] c"@SEND \00"
@.str.11 = [3 x i8] c"%s\00"
@.str.12 = [3 x i8] c"OK\00"
@.str.13 = [4 x i8] c"put\00"
@.str.14 = [10 x i8] c"@RECEIVE \00"
@.str.15 = [35 x i8] c"Completion Answer from Server: %s\0A\00"
@.str.16 = [20 x i8] c"Command %s unknown\0A\00"
@.str.17 = [2 x i8] c"\0A\00"
@.str.18 = [21 x i8] c"Closing connection.\0A\00"
define void @client(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
store i32 1, i32* %6
store i32 65535, i32* %8
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 1
%25 = trunc i64 %24 to i32
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %7
%27 = load i8**, i8*** %4
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
store i8* %29, i8** %11
%30 = load i8*, i8** %11
%31 = call i32 @createSocket(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 %31, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8**, i8*** %4
%34 = getelementptr inbounds i8*, i8** %33, i64 3
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %35)
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %39)
%41 = load i8**, i8*** %4
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %142, %21
%46 = load i32, i32* %6
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %144
48: ; preds = %45
%49 = load i8*, i8** %7
%50 = load i32, i32* %8
%51 = call i32 @memset(i8* %49, i32 0, i32 %50)
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%53 = call i32 @memset(i8* %52, i32 0, i32 256)
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%55 = call i32 @memset(i8* %54, i32 0, i32 256)
%56 = load i8*, i8** %7
%57 = load i32, i32* %8
%58 = load i32, i32* @stdin
%59 = call i32 @fgets(i8* %56, i32 %57, i32 %58)
%60 = load i8*, i8** %7
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%63 = call i32 @sscanf(i8* %60, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %61, i8* %62)
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %48
store i32 0, i32* %6
br label %142
68: ; preds = %48
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %100
72: ; preds = %68
%73 = load i8*, i8** %7
%74 = load i32, i32* %8
%75 = call i32 @memset(i8* %73, i32 0, i32 %74)
%76 = load i8*, i8** %7
%77 = call i32 @strcpy(i8* %76, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%78 = load i8*, i8** %7
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%80 = call i32 @strcat(i8* %78, i8* %79)
%81 = load i32, i32* %5
%82 = load i8*, i8** %7
%83 = load i8*, i8** %7
%84 = call i32 @strlen(i8* %83)
%85 = call i32 @send(i32 %81, i8* %82, i32 %84, i32 0)
%86 = load i8*, i8** %7
%87 = load i32, i32* %8
%88 = call i32 @memset(i8* %86, i32 0, i32 %87)
%89 = load i32, i32* %5
%90 = load i8*, i8** %7
%91 = load i32, i32* %8
%92 = call i32 @recv(i32 %89, i8* %90, i32 %91, i32 0)
%93 = load i8*, i8** %7
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %93)
%95 = load i32, i32* %5
%96 = call i32 @send(i32 %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32 4, i32 0)
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%98 = load i32, i32* %5
%99 = call i32 @receiveFile(i8* %97, i32 %98, i32 0)
br label %141
100: ; preds = %68
%101 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%102 = call i64 @strcmp(i8* %101, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %137
104: ; preds = %100
%105 = load i8*, i8** %7
%106 = load i32, i32* %8
%107 = call i32 @memset(i8* %105, i32 0, i32 %106)
%108 = load i8*, i8** %7
%109 = call i32 @strcpy(i8* %108, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
%110 = load i8*, i8** %7
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%112 = call i32 @strcat(i8* %110, i8* %111)
%113 = load i32, i32* %5
%114 = load i8*, i8** %7
%115 = load i8*, i8** %7
%116 = call i32 @strlen(i8* %115)
%117 = call i32 @send(i32 %113, i8* %114, i32 %116, i32 0)
%118 = load i8*, i8** %7
%119 = load i32, i32* %8
%120 = call i32 @memset(i8* %118, i32 0, i32 %119)
%121 = load i32, i32* %5
%122 = load i8*, i8** %7
%123 = load i32, i32* %8
%124 = call i32 @recv(i32 %121, i8* %122, i32 %123, i32 0)
%125 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%126 = load i32, i32* %5
%127 = call i32 @sendFile(i8* %125, i32 %126)
%128 = load i8*, i8** %7
%129 = load i32, i32* %8
%130 = call i32 @memset(i8* %128, i32 0, i32 %129)
%131 = load i32, i32* %5
%132 = load i8*, i8** %7
%133 = load i32, i32* %8
%134 = call i32 @recv(i32 %131, i8* %132, i32 %133, i32 0)
%135 = load i8*, i8** %7
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0), i8* %135)
br label %140
137: ; preds = %100
%138 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0), i8* %138)
br label %140
140: ; preds = %137, %104
br label %141
141: ; preds = %140, %72
br label %142
142: ; preds = %141, %67
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
br label %45
144: ; preds = %45
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.18, i64 0, i64 0))
%146 = load i32, i32* %5
%147 = call i32 @close(i32 %146)
ret void
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"%s -C [servername or address]\0A\00"
@.str.2 = [7 x i8] c"CLIENT\00"
@stdin = global i32 0
@.str.7 = [6 x i8] c"%s %s\00"
@.str.8 = [5 x i8] c"quit\00"
@.str.9 = [4 x i8] c"get\00"
@.str.10 = [7 x i8] c"@SEND \00"
@.str.11 = [3 x i8] c"%s\00"
@.str.12 = [3 x i8] c"OK\00"
@.str.13 = [4 x i8] c"put\00"
@.str.14 = [10 x i8] c"@RECEIVE \00"
@.str.15 = [35 x i8] c"Completion Answer from Server: %s\0A\00"
@.str.16 = [20 x i8] c"Command %s unknown\0A\00"
@str = [50 x i8] c" OK!\0APlease choose one of the following commands:\00"
@str.19 = [39 x i8] c"get [filename] read file from server\00"
@str.20 = [44 x i8] c"put [filename] write local file to server\00"
@str.21 = [43 x i8] c"quit close client application\0A\00"
@str.22 = [20 x i8] c"Closing connection.\00"
@str.23 = [53 x i8] c"Client mode requires an additional parameter! Usage:\00"
define void @client(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.23, i64 0, i64 0))
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = tail call dereferenceable_or_null(65535) i8* @malloc(i32 65535)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @createSocket(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.19, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.20, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.21, i64 0, i64 0))
br label %22
22: ; preds = %62, %11
%23 = call i32 @memset(i8* %12, i32 0, i32 65535)
%24 = call i32 @memset(i8* %13, i32 0, i32 256)
%25 = call i32 @memset(i8* %14, i32 0, i32 256)
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %12, i32 65535, i32 %26)
%28 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %13, i8* %14)
%29 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %64, label %31
31: ; preds = %22
%32 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = call i32 @memset(i8* %12, i32 0, i32 65535)
%36 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%37 = call i32 @strcat(i8* %12, i8* %14)
%38 = call i32 @strlen(i8* %12)
%39 = call i32 @send(i32 %17, i8* %12, i32 %38, i32 0)
%40 = call i32 @memset(i8* %12, i32 0, i32 65535)
%41 = call i32 @recv(i32 %17, i8* %12, i32 65535, i32 0)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %12)
%43 = call i32 @send(i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32 4, i32 0)
%44 = call i32 @receiveFile(i8* %14, i32 %17, i32 0)
br label %62
45: ; preds = %31
%46 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %60
48: ; preds = %45
%49 = call i32 @memset(i8* %12, i32 0, i32 65535)
%50 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
%51 = call i32 @strcat(i8* %12, i8* %14)
%52 = call i32 @strlen(i8* %12)
%53 = call i32 @send(i32 %17, i8* %12, i32 %52, i32 0)
%54 = call i32 @memset(i8* %12, i32 0, i32 65535)
%55 = call i32 @recv(i32 %17, i8* %12, i32 65535, i32 0)
%56 = call i32 @sendFile(i8* %14, i32 %17)
%57 = call i32 @memset(i8* %12, i32 0, i32 65535)
%58 = call i32 @recv(i32 %17, i8* %12, i32 65535, i32 0)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0), i8* %12)
br label %62
60: ; preds = %45
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0), i8* %13)
br label %62
62: ; preds = %34, %60, %48
%63 = call i32 @putchar(i32 10)
br label %22
64: ; preds = %22
%65 = call i32 @putchar(i32 10)
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.22, i64 0, i64 0))
%67 = call i32 @close(i32 %17)
ret void
}