#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 mtd_server_cmd_run_HOSTNAME(char *, char *);
int /*<<< orphan*/ mtd_srv_cmd_strTrim(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int mtd_srv_cmd_parseMessage(char *message) {
  char msg_cmd[strlen(message)];
  mtd_srv_cmd_strTrim(message, msg_cmd);
  if ((strncmp(msg_cmd, "HELP", 4) == 0) ||
      (strncmp(msg_cmd, "help", 4) == 0)) {
    sprintf(message,
            "[MTd]_HELP# MTulioD HELP menu: \n"
            "\t '-> HELP	: Show this menu. \n"
            "\t '-> HOSTNAME	: Get hostname info.\n"
            "\t '-> QUIT	: Close connection.\n",
            msg_cmd);
  } else if ((strncmp(msg_cmd, "QUIT", 4) == 0) ||
             (strncmp(msg_cmd, "quit", 4) == 0)) {
    sprintf(message, "[MTd]_%s# Closing connection.\n", msg_cmd);
    return 99;
  } else if ((strncmp(msg_cmd, "HOSTNAME", 8) == 0) ||
             (strncmp(msg_cmd, "hostname", 8) == 0)) {
    return mtd_server_cmd_run_HOSTNAME(msg_cmd, message);
  } else {
    sprintf(message, "[MTd]_ERR%% Command [%s] NOT FOUND.\n", msg_cmd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<mtd_srv_cmd_parseMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x30(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <mtd_srv_cmd_strTrim@plt>
mov    -0x30(%rbp),%rdi
lea    0xe62(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11d1 <mtd_srv_cmd_parseMessage+0x81>
mov    -0x30(%rbp),%rdi
lea    0xe48(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ea <mtd_srv_cmd_parseMessage+0x9a>
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1060 <sprintf@plt>
jmp    12c7 <mtd_srv_cmd_parseMessage+0x177>
mov    -0x30(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1228 <mtd_srv_cmd_parseMessage+0xd8>
mov    -0x30(%rbp),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    124f <mtd_srv_cmd_parseMessage+0xff>
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x63,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    12d5 <mtd_srv_cmd_parseMessage+0x185>
mov    -0x30(%rbp),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     128d <mtd_srv_cmd_parseMessage+0x13d>
mov    -0x30(%rbp),%rdi
lea    0xe45(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12a9 <mtd_srv_cmd_parseMessage+0x159>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <mtd_server_cmd_run_HOSTNAME@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    12d5 <mtd_srv_cmd_parseMessage+0x185>
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1060 <sprintf@plt>
jmp    12c2 <mtd_srv_cmd_parseMessage+0x172>
jmp    12c7 <mtd_srv_cmd_parseMessage+0x177>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtd_srv_cmd_parseMessage>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <mtd_srv_cmd_strTrim@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1220 <mtd_srv_cmd_parseMessage+0xd0>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1220 <mtd_srv_cmd_parseMessage+0xd0>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1236 <mtd_srv_cmd_parseMessage+0xe6>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1236 <mtd_srv_cmd_parseMessage+0xe6>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     124f <mtd_srv_cmd_parseMessage+0xff>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     124f <mtd_srv_cmd_parseMessage+0xff>
lea    0xea9(%rip),%rsi
jmp    1227 <mtd_srv_cmd_parseMessage+0xd7>
lea    0xde3(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
xor    %eax,%eax
jmp    125a <mtd_srv_cmd_parseMessage+0x10a>
lea    0xe59(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
mov    $0x63,%eax
jmp    125a <mtd_srv_cmd_parseMessage+0x10a>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <mtd_server_cmd_run_HOSTNAME@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HELP\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [130 x i8] c"[MTd]_HELP# MTulioD HELP menu: \0A\09 '-> HELP\09: Show this menu. \0A\09 '-> HOSTNAME\09: Get hostname info.\0A\09 '-> QUIT\09: Close connection.\0A\00"
@.str.3 = [5 x i8] c"QUIT\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [31 x i8] c"[MTd]_%s# Closing connection.\0A\00"
@.str.6 = [9 x i8] c"HOSTNAME\00"
@.str.7 = [9 x i8] c"hostname\00"
@.str.8 = [37 x i8] c"[MTd]_ERR%% Command [%s] NOT FOUND.\0A\00"
define i32 @mtd_srv_cmd_parseMessage(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca i8, i64 %9
store i64 %9, i64* %5
%12 = load i8*, i8** %3
%13 = call i32 @mtd_srv_cmd_strTrim(i8* %12, i8* %11)
%14 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %1
%17 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16, %1
%20 = load i8*, i8** %3
%21 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %45
22: ; preds = %16
%23 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25, %22
%29 = load i8*, i8** %3
%30 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %11)
store i32 99, i32* %2
store i32 1, i32* %6
br label %46
31: ; preds = %25
%32 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 8)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 8)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34, %31
%38 = load i8*, i8** %3
%39 = call i32 @mtd_server_cmd_run_HOSTNAME(i8* %11, i8* %38)
store i32 %39, i32* %2
store i32 1, i32* %6
br label %46
40: ; preds = %34
%41 = load i8*, i8** %3
%42 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %11)
br label %43
43: ; preds = %40
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44, %19
store i32 0, i32* %2
store i32 1, i32* %6
br label %46
46: ; preds = %45, %37, %28
%47 = load i8*, i8** %4
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@.str = [5 x i8] c"HELP\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [130 x i8] c"[MTd]_HELP# MTulioD HELP menu: \0A\09 '-> HELP\09: Show this menu. \0A\09 '-> HOSTNAME\09: Get hostname info.\0A\09 '-> QUIT\09: Close connection.\0A\00"
@.str.3 = [5 x i8] c"QUIT\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [31 x i8] c"[MTd]_%s# Closing connection.\0A\00"
@.str.6 = [9 x i8] c"HOSTNAME\00"
@.str.7 = [9 x i8] c"hostname\00"
@.str.8 = [37 x i8] c"[MTd]_ERR%% Command [%s] NOT FOUND.\0A\00"
define i32 @mtd_srv_cmd_parseMessage(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @mtd_srv_cmd_strTrim(i8* %0, i8* %4)
%6 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8, %1
%12 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([130 x i8], [130 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %31
13: ; preds = %8
%14 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16, %13
%20 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %31
21: ; preds = %16
%22 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 8)
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 8)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %21
%28 = call i32 @mtd_server_cmd_run_HOSTNAME(i8* %4, i8* %0)
br label %31
29: ; preds = %24
%30 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %31
31: ; preds = %11, %29, %27, %19
%32 = phi i32 [ 99, %19 ], [ %28, %27 ], [ 0, %29 ], [ 0, %11 ]
ret i32 %32
}