#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*/ printf(char *);
void printCmdType(unsigned char *cmd) {
  printf("+++");
  if (cmd[6] & 0x80)
    printf(">>>");
  if (cmd[0] == 0 && cmd[1] == 0) {
    switch (cmd[6] & 0x7f) {
    case 0:
      printf("--- Init           ---\n");
      break;
    case 1:
      printf("--- OpenChannel    ---\n");
      break;
    case 2:
      printf("--- CloseChannel   ---\n");
      break;
    case 3:
      printf("--- Credit         ---\n");
      break;
    case 4:
      printf("--- CreditRequest  ---\n");
      break;
    case 8:
      printf("--- Exit           ---\n");
      break;
    case 9:
      printf("--- GetSocketID    ---\n");
      break;
    case 10:
      printf("--- GetServiceName ---\n");
      break;
    case 0x45:
      printf("--- EnterD4Mode    ---\n");
      break;
    case 0x7f:
      printf("--- Error          ---\n");
      break;
    default:
      printf("--- ?????????????? ---\n");
      break;
    }
  } else {
    printf("--- Send Data      ---\n");
  }
}


x86 assembly (clang, -O0):
<printCmdType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movzbl 0x6(%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     114a <printCmdType+0x3a>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    12d8 <printCmdType+0x1c8>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    12d8 <printCmdType+0x1c8>
mov    -0x8(%rbp),%rax
movzbl 0x6(%rax),%eax
and    $0x7f,%eax
mov    %eax,-0xc(%rbp)
je     121d <printCmdType+0x10d>
jmp    1184 <printCmdType+0x74>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     122e <printCmdType+0x11e>
jmp    1195 <printCmdType+0x85>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     123f <printCmdType+0x12f>
jmp    11a6 <printCmdType+0x96>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     1250 <printCmdType+0x140>
jmp    11b7 <printCmdType+0xa7>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
je     1261 <printCmdType+0x151>
jmp    11c8 <printCmdType+0xb8>
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
je     1272 <printCmdType+0x162>
jmp    11d9 <printCmdType+0xc9>
mov    -0xc(%rbp),%eax
sub    $0x9,%eax
je     1283 <printCmdType+0x173>
jmp    11ea <printCmdType+0xda>
mov    -0xc(%rbp),%eax
sub    $0xa,%eax
je     1294 <printCmdType+0x184>
jmp    11fb <printCmdType+0xeb>
mov    -0xc(%rbp),%eax
sub    $0x45,%eax
je     12a5 <printCmdType+0x195>
jmp    120c <printCmdType+0xfc>
mov    -0xc(%rbp),%eax
sub    $0x7f,%eax
je     12b6 <printCmdType+0x1a6>
jmp    12c7 <printCmdType+0x1b7>
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xdeb(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xdf2(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xe00(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
jmp    12d3 <printCmdType+0x1c3>
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
jmp    12e4 <printCmdType+0x1d4>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printCmdType>:
push   %rbx
mov    %rdi,%rbx
lea    0xfed(%rip),%rdi
call   1040 <printf@plt>
cmpb   $0x0,0x6(%rbx)
jns    1142 <printCmdType+0x22>
lea    0xfdf(%rip),%rdi
call   1040 <printf@plt>
lea    0xfd7(%rip),%rdi
cmpb   $0x0,(%rbx)
je     1154 <printCmdType+0x34>
pop    %rbx
jmp    1030 <puts@plt>
cmpb   $0x0,0x1(%rbx)
jne    114e <printCmdType+0x2e>
movzbl 0x6(%rbx),%eax
and    $0x7f,%eax
cmp    $0x45,%eax
ja     118a <printCmdType+0x6a>
lea    0x1099(%rip),%rdi
lea    0xe8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x106b(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
cmp    $0x7f,%eax
jne    119c <printCmdType+0x7c>
lea    0xfa1(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0x107a(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0x1028(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0x1004(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xfe0(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xfbc(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xf98(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xf74(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xf50(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"+++\00"
@.str.1 = [4 x i8] c">>>\00"
@.str.2 = [24 x i8] c"--- Init ---\0A\00"
@.str.3 = [24 x i8] c"--- OpenChannel ---\0A\00"
@.str.4 = [24 x i8] c"--- CloseChannel ---\0A\00"
@.str.5 = [24 x i8] c"--- Credit ---\0A\00"
@.str.6 = [24 x i8] c"--- CreditRequest ---\0A\00"
@.str.7 = [24 x i8] c"--- Exit ---\0A\00"
@.str.8 = [24 x i8] c"--- GetSocketID ---\0A\00"
@.str.9 = [24 x i8] c"--- GetServiceName ---\0A\00"
@.str.10 = [24 x i8] c"--- EnterD4Mode ---\0A\00"
@.str.11 = [24 x i8] c"--- Error ---\0A\00"
@.str.12 = [24 x i8] c"--- ?????????????? ---\0A\00"
@.str.13 = [24 x i8] c"--- Send Data ---\0A\00"
define void @printCmdType(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 6
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = and i32 %7, 128
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %53
18: ; preds = %12
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %53
24: ; preds = %18
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 6
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = and i32 %28, 127
switch i32 %29, label %50 [
i32 0, label %30
i32 1, label %32
i32 2, label %34
i32 3, label %36
i32 4, label %38
i32 8, label %40
i32 9, label %42
i32 10, label %44
i32 69, label %46
i32 127, label %48
]
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %52
32: ; preds = %24
%33 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %52
34: ; preds = %24
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %52
36: ; preds = %24
%37 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %52
38: ; preds = %24
%39 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %52
40: ; preds = %24
%41 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %52
42: ; preds = %24
%43 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %52
44: ; preds = %24
%45 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %52
46: ; preds = %24
%47 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %52
48: ; preds = %24
%49 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
br label %52
50: ; preds = %24
%51 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
br label %52
52: ; preds = %50, %48, %46, %44, %42, %40, %38, %36, %34, %32, %30
br label %55
53: ; preds = %18, %12
%54 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
br label %55
55: ; preds = %53, %52
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"+++\00"
@.str.1 = [4 x i8] c">>>\00"
@str = [23 x i8] c"--- Send Data ---\00"
@str.14 = [23 x i8] c"--- Error ---\00"
@str.15 = [23 x i8] c"--- EnterD4Mode ---\00"
@str.16 = [23 x i8] c"--- GetServiceName ---\00"
@str.17 = [23 x i8] c"--- GetSocketID ---\00"
@str.18 = [23 x i8] c"--- Exit ---\00"
@str.19 = [23 x i8] c"--- CreditRequest ---\00"
@str.20 = [23 x i8] c"--- Credit ---\00"
@str.21 = [23 x i8] c"--- CloseChannel ---\00"
@str.22 = [23 x i8] c"--- OpenChannel ---\00"
@str.23 = [23 x i8] c"--- Init ---\00"
@str.24 = [23 x i8] c"--- ?????????????? ---\00"
define void @printCmdType(i8* nocapture %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds i8, i8* %0, i64 6
%4 = load i8, i8* %3
%5 = icmp sgt i8 %4, -1
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i8, i8* %3
%17 = and i8 %16, 127
%18 = zext i8 %17 to i32
switch i32 %18, label %28 [
i32 0, label %29
i32 1, label %19
i32 2, label %20
i32 3, label %21
i32 4, label %22
i32 8, label %23
i32 9, label %24
i32 10, label %25
i32 69, label %26
i32 127, label %27
]
19: ; preds = %15
br label %29
20: ; preds = %15
br label %29
21: ; preds = %15
br label %29
22: ; preds = %15
br label %29
23: ; preds = %15
br label %29
24: ; preds = %15
br label %29
25: ; preds = %15
br label %29
26: ; preds = %15
br label %29
27: ; preds = %15
br label %29
28: ; preds = %15
br label %29
29: ; preds = %8, %11, %15, %19, %20, %21, %22, %23, %24, %25, %26, %27, %28
%30 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.22, i64 0, i64 0), %19 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.21, i64 0, i64 0), %20 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.20, i64 0, i64 0), %21 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.19, i64 0, i64 0), %22 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0), %23 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0), %24 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0), %25 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0), %26 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.14, i64 0, i64 0), %27 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.24, i64 0, i64 0), %28 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.23, i64 0, i64 0), %15 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), %8 ]
%31 = tail call i32 @puts(i8* dereferenceable(1) %30)
ret void
}