#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 version_dump(void *data, void *payload, int len) {
  unsigned char *pp = (unsigned char *)payload;
  if (pp[0] != 0x12) {
    printf("Unknown command %d\n", pp[0]);
    return;
  }
  printf("VERSION_REPORT:\n");
  printf("  Z-Wave library type: %d\n", pp[1]);
  printf("  Z-Wave protocol version: %d\n", pp[2]);
  printf("  Z-Wave protocol sub version: %d\n", pp[3]);
  printf("  Application version: %d\n", pp[4]);
  printf("  Application sub version: %d\n", pp[5]);
}


x86 assembly (clang, -O0):
<version_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x12,%eax
je     1155 <version_dump+0x45>
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d1 <version_dump+0xc1>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x4(%rax),%esi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x5(%rax),%esi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<version_dump>:
push   %rbx
mov    (%rsi),%al
cmp    $0x12,%al
jne    118a <version_dump+0x6a>
mov    %rsi,%rbx
lea    0xf7a(%rip),%rdi
call   1030 <puts@plt>
movzbl 0x1(%rbx),%esi
lea    0xed3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x2(%rbx),%esi
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x3(%rbx),%esi
lea    0xee9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x4(%rbx),%esi
lea    0xefa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x5(%rbx),%al
lea    0xf04(%rip),%rdi
jmp    1191 <version_dump+0x71>
lea    0xe6f(%rip),%rdi
movzbl %al,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Unknown command %d\0A\00"
@.str.1 = [17 x i8] c"VERSION_REPORT:\0A\00"
@.str.2 = [27 x i8] c" Z-Wave library type: %d\0A\00"
@.str.3 = [31 x i8] c" Z-Wave protocol version: %d\0A\00"
@.str.4 = [35 x i8] c" Z-Wave protocol sub version: %d\0A\00"
@.str.5 = [27 x i8] c" Application version: %d\0A\00"
@.str.6 = [31 x i8] c" Application sub version: %d\0A\00"
define void @version_dump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = icmp ne i32 %12, 18
br i1 %13, label %14, label %20
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %47
20: ; preds = %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 2
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 4
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i64 5
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Unknown command %d\0A\00"
@.str.2 = [27 x i8] c" Z-Wave library type: %d\0A\00"
@.str.3 = [31 x i8] c" Z-Wave protocol version: %d\0A\00"
@.str.4 = [35 x i8] c" Z-Wave protocol sub version: %d\0A\00"
@.str.5 = [27 x i8] c" Application version: %d\0A\00"
@.str.6 = [31 x i8] c" Application sub version: %d\0A\00"
@str = [16 x i8] c"VERSION_REPORT:\00"
define void @version_dump(i8* nocapture readnone %0, i8* nocapture %1, i32 %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 18
br i1 %5, label %6, label %26
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds i8, i8* %1, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i8, i8* %1, i64 3
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds i8, i8* %1, i64 4
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds i8, i8* %1, i64 5
%25 = load i8, i8* %24
br label %26
26: ; preds = %3, %6
%27 = phi i8 [ %25, %6 ], [ %4, %3 ]
%28 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), %6 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %3 ]
%29 = zext i8 %27 to i32
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28, i32 %29)
ret void
}