#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 uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ print_data(int *, int);
int /*<<< orphan*/ printf(char *, int);
void dispatch_cmd(uint8_t *cmd, int size) {
  uint16_t source;
  switch (cmd[0]) {
  case 0x22:
    source = cmd[1] | cmd[2] << 8;
    printf("from: %X  ", source);
    print_data(cmd + 6, size - 6);
    break;
  }
}


x86 assembly (clang, -O0):
<dispatch_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sub    $0x22,%eax
jne    117b <dispatch_cmd+0x5b>
jmp    1143 <dispatch_cmd+0x23>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
add    $0x18,%rdi
mov    -0xc(%rbp),%esi
sub    $0x6,%esi
call   1040 <print_data@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispatch_cmd>:
push   %rbp
push   %rbx
push   %rax
cmpl   $0x22,(%rdi)
jne    1159 <dispatch_cmd+0x39>
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x8(%rdi),%esi
shl    $0x8,%esi
or     0x4(%rdi),%esi
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
add    $0x18,%rbx
add    $0xfffffffa,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <print_data@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"from: %X \00"
define void @dispatch_cmd(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32, i32* %7
switch i32 %8, label %25 [
i32 34, label %9
]
9: ; preds = %2
%10 = load i32*, i32** %3
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = load i32, i32* %11
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 2
%15 = load i32, i32* %14
%16 = shl i32 %15, 8
%17 = or i32 %12, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 6
%22 = load i32, i32* %4
%23 = sub nsw i32 %22, 6
%24 = call i32 @print_data(i32* %21, i32 %23)
br label %25
25: ; preds = %2, %9
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"from: %X \00"
define void @dispatch_cmd(i32* %0, i32 %1) {
%3 = load i32, i32* %0
%4 = icmp eq i32 %3, 34
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = load i32, i32* %8
%10 = shl i32 %9, 8
%11 = or i32 %10, %7
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i32, i32* %0, i64 6
%14 = add nsw i32 %1, -6
%15 = tail call i32 @print_data(i32* %13, i32 %14)
br label %16
16: ; preds = %2, %5
ret void
}