#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int stuff(char *, char *);
int /*<<< orphan*/ writen(int, char *, int);
void ActUponClientInput(char *input, int sockfd) {
  int i, a;
  char commandName[256];
  char gameName[256];
  char optionstring[64];
  int option;
  char response[1024];
  char buffer[1024];
  input += 2;
  for (i = 0; input[i] != ' '; i++)
    commandName[i] = input[i];
  commandName[i] = (char)NULL;
  input++;
  if (!strcmp(commandName, "GameList")) {
    FILE *filep;
    printf("Just read a GameList packet\n");
    if ((filep = fopen("gamelist.txt", "r")) == NULL) {
      close(sockfd);
      return;
    }
    fgets(response + 2, 1020, filep);
    response[strlen(response) - 1] = (char)NULL;
    fclose(filep);
  } else if (!strcmp(commandName, "GameOptions")) {
  } else if (!strcmp(commandName, "Primitive")) {
  } else if (!strcmp(commandName, "DoMove")) {
  } else if (!strcmp(commandName, "Value")) {
  } else if (!strcmp(commandName, "Analyze")) {
  } else if (!strcmp(commandName, "GenerateMoves")) {
  } else if (!strcmp(commandName, "PrintPosition")) {
  } else if (!strcmp(commandName, "PrintMove")) {
  } else if (!strcmp(commandName, "ConvertTextInputToMove")) {
  }
  a = stuff(buffer, response);
  writen(sockfd, buffer, a);
}


x86 assembly (clang, -O0):
<ActUponClientInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11ee <ActUponClientInput+0x5e>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x120(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b5 <ActUponClientInput+0x25>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x120(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
lea    -0x120(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12a5 <ActUponClientInput+0x115>
lea    0xde0(%rip),%rdi
call   1050 <printf@plt>
lea    0xdf1(%rip),%rdi
lea    0xdf7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0xa78(%rbp)
cmp    $0x0,%rax
jne    125f <ActUponClientInput+0xcf>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
jmp    1423 <ActUponClientInput+0x293>
lea    -0x670(%rbp),%rdi
add    $0x2,%rdi
mov    -0xa78(%rbp),%rdx
mov    $0x3fc,%esi
call   1080 <fgets@plt>
lea    -0x670(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x670(%rbp,%rax,1)
mov    -0xa78(%rbp),%rdi
call   1030 <fclose@plt>
jmp    13fb <ActUponClientInput+0x26b>
lea    -0x120(%rbp),%rdi
lea    0xd82(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12c6 <ActUponClientInput+0x136>
jmp    13f6 <ActUponClientInput+0x266>
lea    -0x120(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12e7 <ActUponClientInput+0x157>
jmp    13f1 <ActUponClientInput+0x261>
lea    -0x120(%rbp),%rdi
lea    0xd56(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1308 <ActUponClientInput+0x178>
jmp    13ec <ActUponClientInput+0x25c>
lea    -0x120(%rbp),%rdi
lea    0xd3c(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1329 <ActUponClientInput+0x199>
jmp    13e7 <ActUponClientInput+0x257>
lea    -0x120(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    134a <ActUponClientInput+0x1ba>
jmp    13e2 <ActUponClientInput+0x252>
lea    -0x120(%rbp),%rdi
lea    0xd08(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    136b <ActUponClientInput+0x1db>
jmp    13dd <ActUponClientInput+0x24d>
lea    -0x120(%rbp),%rdi
lea    0xcf5(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    138c <ActUponClientInput+0x1fc>
jmp    13d8 <ActUponClientInput+0x248>
lea    -0x120(%rbp),%rdi
lea    0xce2(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    13ad <ActUponClientInput+0x21d>
jmp    13d3 <ActUponClientInput+0x243>
lea    -0x120(%rbp),%rdi
lea    0xccb(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    13ce <ActUponClientInput+0x23e>
jmp    13ce <ActUponClientInput+0x23e>
jmp    13d3 <ActUponClientInput+0x243>
jmp    13d8 <ActUponClientInput+0x248>
jmp    13dd <ActUponClientInput+0x24d>
jmp    13e2 <ActUponClientInput+0x252>
jmp    13e7 <ActUponClientInput+0x257>
jmp    13ec <ActUponClientInput+0x25c>
jmp    13f1 <ActUponClientInput+0x261>
jmp    13f6 <ActUponClientInput+0x266>
jmp    13fb <ActUponClientInput+0x26b>
lea    -0xa70(%rbp),%rdi
lea    -0x670(%rbp),%rsi
call   1060 <stuff@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
lea    -0xa70(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   10b0 <writen@plt>
add    $0xa80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ActUponClientInput>:
push   %rbp
push   %r14
push   %rbx
sub    $0x900,%rsp
mov    %esi,%ebp
mov    0x2(%rdi),%al
cmp    $0x20,%al
jne    1198 <ActUponClientInput+0x18>
xor    %eax,%eax
jmp    11b2 <ActUponClientInput+0x32>
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %al,(%rsp,%rcx,1)
movzbl 0x3(%rdi,%rcx,1),%eax
add    $0x1,%rcx
cmp    $0x20,%al
jne    11a0 <ActUponClientInput+0x20>
mov    %ecx,%eax
movb   $0x0,(%rsp,%rax,1)
movabs $0x7473694c656d6147,%rax
69 73 74
xor    (%rsp),%rax
movzbl 0x8(%rsp),%ecx
or     %rax,%rcx
jne    122a <ActUponClientInput+0xaa>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
lea    0xe28(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     125a <ActUponClientInput+0xda>
mov    %rax,%rbx
lea    0x102(%rsp),%rdi
mov    $0x3fc,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
lea    0x100(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0x500(%rsp),%rbx
lea    0x100(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <stuff@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   10a0 <writen@plt>
add    $0x900,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %ebp,%edi
add    $0x900,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <close@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"GameList\00"
@.str.1 = [29 x i8] c"Just read a GameList packet\0A\00"
@.str.2 = [13 x i8] c"gamelist.txt\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [12 x i8] c"GameOptions\00"
@.str.5 = [10 x i8] c"Primitive\00"
@.str.6 = [7 x i8] c"DoMove\00"
@.str.7 = [6 x i8] c"Value\00"
@.str.8 = [8 x i8] c"Analyze\00"
@.str.9 = [14 x i8] c"GenerateMoves\00"
@.str.10 = [14 x i8] c"PrintPosition\00"
@.str.11 = [10 x i8] c"PrintMove\00"
@.str.12 = [23 x i8] c"ConvertTextInputToMove\00"
define void @ActUponClientInput(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca [64 x i8]
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca [1024 x i8]
%13 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 2
store i8* %15, i8** %3
store i32 0, i32* %5
br label %16
16: ; preds = %33, %2
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 32
br i1 %23, label %24, label %36
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %31
store i8 %29, i8* %32
br label %33
33: ; preds = %24
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %16
36: ; preds = %16
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %38
store i8 0, i8* %39
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %3
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%43 = call i32 @strcmp(i8* %42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %64, label %45
45: ; preds = %36
%46 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %47, i32** %13
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load i32, i32* %4
%51 = call i32 @close(i32 %50)
br label %126
52: ; preds = %45
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%54 = getelementptr inbounds i8, i8* %53, i64 2
%55 = load i32*, i32** %13
%56 = call i32 @fgets(i8* %54, i32 1020, i32* %55)
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %60
store i8 0, i8* %61
%62 = load i32*, i32** %13
%63 = call i32 @fclose(i32* %62)
br label %118
64: ; preds = %36
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %69, label %68
68: ; preds = %64
br label %117
69: ; preds = %64
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%71 = call i32 @strcmp(i8* %70, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%72 = icmp ne i32 %71, 0
br i1 %72, label %74, label %73
73: ; preds = %69
br label %116
74: ; preds = %69
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%76 = call i32 @strcmp(i8* %75, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%77 = icmp ne i32 %76, 0
br i1 %77, label %79, label %78
78: ; preds = %74
br label %115
79: ; preds = %74
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%81 = call i32 @strcmp(i8* %80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%82 = icmp ne i32 %81, 0
br i1 %82, label %84, label %83
83: ; preds = %79
br label %114
84: ; preds = %79
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%86 = call i32 @strcmp(i8* %85, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%87 = icmp ne i32 %86, 0
br i1 %87, label %89, label %88
88: ; preds = %84
br label %113
89: ; preds = %84
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%91 = call i32 @strcmp(i8* %90, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%92 = icmp ne i32 %91, 0
br i1 %92, label %94, label %93
93: ; preds = %89
br label %112
94: ; preds = %89
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%96 = call i32 @strcmp(i8* %95, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%97 = icmp ne i32 %96, 0
br i1 %97, label %99, label %98
98: ; preds = %94
br label %111
99: ; preds = %94
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%101 = call i32 @strcmp(i8* %100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%102 = icmp ne i32 %101, 0
br i1 %102, label %104, label %103
103: ; preds = %99
br label %110
104: ; preds = %99
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%106 = call i32 @strcmp(i8* %105, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
%107 = icmp ne i32 %106, 0
br i1 %107, label %109, label %108
108: ; preds = %104
br label %109
109: ; preds = %108, %104
br label %110
110: ; preds = %109, %103
br label %111
111: ; preds = %110, %98
br label %112
112: ; preds = %111, %93
br label %113
113: ; preds = %112, %88
br label %114
114: ; preds = %113, %83
br label %115
115: ; preds = %114, %78
br label %116
116: ; preds = %115, %73
br label %117
117: ; preds = %116, %68
br label %118
118: ; preds = %117, %52
%119 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%121 = call i32 @stuff(i8* %119, i8* %120)
store i32 %121, i32* %6
%122 = load i32, i32* %4
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%124 = load i32, i32* %6
%125 = call i32 @writen(i32 %122, i8* %123, i32 %124)
br label %126
126: ; preds = %118, %49
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"GameList\00"
@.str.2 = [13 x i8] c"gamelist.txt\00"
@.str.3 = [2 x i8] c"r\00"
@str = [28 x i8] c"Just read a GameList packet\00"
define void @ActUponClientInput(i8* nocapture %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 32
br i1 %11, label %22, label %12
12: ; preds = %2, %12
%13 = phi i64 [ %16, %12 ], [ 0, %2 ]
%14 = phi i8 [ %18, %12 ], [ %10, %2 ]
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %13
store i8 %14, i8* %15
%16 = add nuw nsw i64 %13, 1
%17 = getelementptr inbounds i8, i8* %9, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 32
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = and i64 %16, 4294967295
br label %22
22: ; preds = %20, %2
%23 = phi i64 [ 0, %2 ], [ %21, %20 ]
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
%25 = call i32 @bcmp(i8* dereferenceable(9) %6, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 9)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %41
27: ; preds = %22
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%29 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call i32 @close(i32 %1)
br label %44
33: ; preds = %27
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 2
%35 = call i32 @fgets(i8* %34, i32 1020, i32* %29)
%36 = call i32 @strlen(i8* %7)
%37 = add nsw i32 %36, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %38
store i8 0, i8* %39
%40 = call i32 @fclose(i32* %29)
br label %41
41: ; preds = %33, %22
%42 = call i32 @stuff(i8* %8, i8* %7)
%43 = call i32 @writen(i32 %1, i8* %8, i32 %42)
br label %44
44: ; preds = %31, %41
ret void
}