#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*/ action;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ addUser(int /*<<< orphan*/ *, int, char *);
int /*<<< orphan*/ command(int /*<<< orphan*/ *, int, char *);
int /*<<< orphan*/ logData(int /*<<< orphan*/ *, char *, char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
size_t readSock(int, char *, int);
int /*<<< orphan*/ writeSock(int, char *, int);
int adminFunctions(FILE *logfile, int sock) {
  char action[1024];
  size_t len;
  while (1) {
    writeSock(sock, "\x41\x41 READY!", sizeof("\x41\x41 READY!"));
    memset(action, 0, sizeof(action));
    len = readSock(sock, action, sizeof(action));
    if (action[0] == 0x26) {
      addUser(logfile, sock, action);
    } else if (action[0] == 0x25) {
      command(logfile, sock, action);
    } else {
      logData(logfile, "unknown action: %x", action[0]);
    }
  }
}


x86 assembly (clang, -O0):
<adminFunctions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xe84(%rip),%rsi
mov    $0xa,%edx
call   1080 <writeSock@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    -0xc(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <readSock@plt>
mov    %rax,-0x418(%rbp)
movsbl -0x410(%rbp),%eax
cmp    $0x26,%eax
jne    11dc <adminFunctions+0x7c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x410(%rbp),%rdx
call   1050 <addUser@plt>
jmp    1220 <adminFunctions+0xc0>
movsbl -0x410(%rbp),%eax
cmp    $0x25,%eax
jne    1204 <adminFunctions+0xa4>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x410(%rbp),%rdx
call   1060 <command@plt>
jmp    121b <adminFunctions+0xbb>
mov    -0x8(%rbp),%rdi
lea    0xdfb(%rip),%rsi
movsbl -0x410(%rbp),%edx
call   1030 <logData@plt>
jmp    1220 <adminFunctions+0xc0>
jmp    1172 <adminFunctions+0x12>

x86 assembly (clang, -O2):
<adminFunctions>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xe84(%rip),%r15
mov    %rsp,%r12
lea    0xe84(%rip),%r13
jmp    119d <adminFunctions+0x3d>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
call   1060 <command@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xa,%edx
call   1080 <writeSock@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x400,%edx
call   1040 <readSock@plt>
movzbl (%rsp),%eax
cmp    $0x25,%al
je     1190 <adminFunctions+0x30>
cmp    $0x26,%al
jne    11f0 <adminFunctions+0x90>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
call   1050 <addUser@plt>
jmp    119d <adminFunctions+0x3d>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edx
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <logData@plt>
jmp    119d <adminFunctions+0x3d>

LLVM IR (-O0):
@.str = [10 x i8] c"AA READY!\00"
@.str.1 = [19 x i8] c"unknown action: %x\00"
define i32 @adminFunctions(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %7
7: ; preds = %2, %40
%8 = load i32, i32* %4
%9 = call i32 @writeSock(i32 %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 10)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 1024)
%12 = load i32, i32* %4
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = call i64 @readSock(i32 %12, i8* %13, i32 1024)
store i64 %14, i64* %6
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 38
br i1 %18, label %19, label %24
19: ; preds = %7
%20 = load i32*, i32** %3
%21 = load i32, i32* %4
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%23 = call i32 @addUser(i32* %20, i32 %21, i8* %22)
br label %40
24: ; preds = %7
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 37
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i32*, i32** %3
%31 = load i32, i32* %4
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%33 = call i32 @command(i32* %30, i32 %31, i8* %32)
br label %39
34: ; preds = %24
%35 = load i32*, i32** %3
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%37 = load i8, i8* %36
%38 = call i32 @logData(i32* %35, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8 signext %37)
br label %39
39: ; preds = %34, %29
br label %40
40: ; preds = %39, %19
br label %7
}

LLVM IR (-O2):
@.str = [10 x i8] c"AA READY!\00"
@.str.1 = [19 x i8] c"unknown action: %x\00"
define i32 @adminFunctions(i32* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %14, %2
%6 = call i32 @writeSock(i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 10)
%7 = call i32 @memset(i8* %4, i32 0, i32 1024)
%8 = call i64 @readSock(i32 %1, i8* %4, i32 1024)
%9 = load i8, i8* %4
switch i8 %9, label %15 [
i8 38, label %10
i8 37, label %12
]
10: ; preds = %5
%11 = call i32 @addUser(i32* %0, i32 %1, i8* %4)
br label %14
12: ; preds = %5
%13 = call i32 @command(i32* %0, i32 %1, i8* %4)
br label %14
14: ; preds = %12, %15, %10
br label %5
15: ; preds = %5
%16 = call i32 @logData(i32* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8 signext %9)
br label %14
}