#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*/ handleCloseCommand(char *, int);
int /*<<< orphan*/ handleOpenCommand(char *, int);
int /*<<< orphan*/ handleREADCommand(char *, int);
int /*<<< orphan*/ logM(char *);
scalar_t__ strncmp(char *, char *, int);
void handleCommand(char *buff, int socket) {
  if (strncmp("OPEN", buff, 3) == 0) {
    logM("[handleCommand] Ricevuta richiesta OPEN\n");
    handleOpenCommand(buff, socket);
  } else if (strncmp("CLOS", buff, 3) == 0) {
    logM("[handleCommand] Ricevuta richiesta CLOSE\n");
    handleCloseCommand(buff, socket);
  } else if (strncmp("READ", buff, 3) == 0) {
    logM("[handleCommand] Ricevuta richiesta READ\n");
    handleREADCommand(buff, socket);
  } else {
    logM("[handleCommand] Comando sconosciuto.\n");
  }
}


x86 assembly (clang, -O0):
<handleCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    119b <handleCommand+0x4b>
lea    0xe80(%rip),%rdi
call   1070 <logM@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <handleOpenCommand@plt>
jmp    1229 <handleCommand+0xd9>
mov    -0x8(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d7 <handleCommand+0x87>
lea    0xe72(%rip),%rdi
call   1070 <logM@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <handleCloseCommand@plt>
jmp    1224 <handleCommand+0xd4>
mov    -0x8(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1213 <handleCommand+0xc3>
lea    0xe65(%rip),%rdi
call   1070 <logM@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <handleREADCommand@plt>
jmp    121f <handleCommand+0xcf>
lea    0xe71(%rip),%rdi
call   1070 <logM@plt>
jmp    1224 <handleCommand+0xd4>
jmp    1229 <handleCommand+0xd9>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleCommand>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b5 <handleCommand+0x65>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11d1 <handleCommand+0x81>
lea    0xecc(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ed <handleCommand+0x9d>
lea    0xee1(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <logM@plt>
lea    0xe49(%rip),%rdi
call   1070 <logM@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <handleOpenCommand@plt>
lea    0xe5b(%rip),%rdi
call   1070 <logM@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <handleCloseCommand@plt>
lea    0xe6e(%rip),%rdi
call   1070 <logM@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <handleREADCommand@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"OPEN\00"
@.str.1 = [41 x i8] c"[handleCommand] Ricevuta richiesta OPEN\0A\00"
@.str.2 = [5 x i8] c"CLOS\00"
@.str.3 = [42 x i8] c"[handleCommand] Ricevuta richiesta CLOSE\0A\00"
@.str.4 = [5 x i8] c"READ\00"
@.str.5 = [41 x i8] c"[handleCommand] Ricevuta richiesta READ\0A\00"
@.str.6 = [38 x i8] c"[handleCommand] Comando sconosciuto.\0A\00"
define void @handleCommand(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i32 3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = call i32 @logM(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 @handleOpenCommand(i8* %10, i32 %11)
br label %35
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = call i32 @logM(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%19 = load i8*, i8** %3
%20 = load i32, i32* %4
%21 = call i32 @handleCloseCommand(i8* %19, i32 %20)
br label %34
22: ; preds = %13
%23 = load i8*, i8** %3
%24 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %23, i32 3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = call i32 @logM(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%28 = load i8*, i8** %3
%29 = load i32, i32* %4
%30 = call i32 @handleREADCommand(i8* %28, i32 %29)
br label %33
31: ; preds = %22
%32 = call i32 @logM(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %33
33: ; preds = %31, %26
br label %34
34: ; preds = %33, %17
br label %35
35: ; preds = %34, %8
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"OPEN\00"
@.str.1 = [41 x i8] c"[handleCommand] Ricevuta richiesta OPEN\0A\00"
@.str.2 = [5 x i8] c"CLOS\00"
@.str.3 = [42 x i8] c"[handleCommand] Ricevuta richiesta CLOSE\0A\00"
@.str.4 = [5 x i8] c"READ\00"
@.str.5 = [41 x i8] c"[handleCommand] Ricevuta richiesta READ\0A\00"
@.str.6 = [38 x i8] c"[handleCommand] Comando sconosciuto.\0A\00"
define void @handleCommand(i8* %0, i32 %1) {
%3 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 3)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @logM(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @handleOpenCommand(i8* %0, i32 %1)
br label %22
8: ; preds = %2
%9 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 @logM(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @handleCloseCommand(i8* %0, i32 %1)
br label %22
14: ; preds = %8
%15 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i32 @logM(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%19 = tail call i32 @handleREADCommand(i8* %0, i32 %1)
br label %22
20: ; preds = %14
%21 = tail call i32 @logM(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %22
22: ; preds = %11, %20, %17, %5
ret void
}