#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 manufacture_dump(void *data, void *payload, int len) {
  unsigned char *pp = (unsigned char *)payload;
  if (pp[0] != 0x05) {
    printf("Unknown command %d\n", pp[0]);
    return;
  }
  printf("MANUFACTURER_SPECIFIC_REPORT:\n");
  printf("  Manufacturer ID 1: 0x%02x\n", pp[1]);
  printf("  Manufacturer ID 2: 0x%02x\n", pp[2]);
  printf("  Product type ID 1: 0x%02x\n", pp[3]);
  printf("  Product type ID 2: 0x%02x\n", pp[4]);
  printf("  Product ID 1: 0x%02x\n", pp[5]);
  printf("  Product ID 2: 0x%02x\n", pp[6]);
}


x86 assembly (clang, -O0):
<manufacture_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    $0x5,%eax
je     1155 <manufacture_dump+0x45>
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e7 <manufacture_dump+0xd7>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%esi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x4(%rax),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x5(%rax),%esi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x6(%rax),%esi
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manufacture_dump>:
push   %rbx
mov    (%rsi),%al
cmp    $0x5,%al
jne    119c <manufacture_dump+0x7c>
mov    %rsi,%rbx
lea    0xf87(%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    0xede(%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    0xef4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x5(%rbx),%esi
lea    0xeff(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x6(%rbx),%al
lea    0xf06(%rip),%rdi
jmp    11a3 <manufacture_dump+0x83>
lea    0xe5d(%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 = [31 x i8] c"MANUFACTURER_SPECIFIC_REPORT:\0A\00"
@.str.2 = [29 x i8] c" Manufacturer ID 1: 0x%02x\0A\00"
@.str.3 = [29 x i8] c" Manufacturer ID 2: 0x%02x\0A\00"
@.str.4 = [29 x i8] c" Product type ID 1: 0x%02x\0A\00"
@.str.5 = [29 x i8] c" Product type ID 2: 0x%02x\0A\00"
@.str.6 = [24 x i8] c" Product ID 1: 0x%02x\0A\00"
@.str.7 = [24 x i8] c" Product ID 2: 0x%02x\0A\00"
define void @manufacture_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, 5
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 %52
20: ; preds = %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 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 ([29 x i8], [29 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 ([29 x i8], [29 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 ([29 x i8], [29 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 ([29 x i8], [29 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 ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %45)
%47 = load i8*, i8** %7
%48 = getelementptr inbounds i8, i8* %47, i64 6
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Unknown command %d\0A\00"
@.str.2 = [29 x i8] c" Manufacturer ID 1: 0x%02x\0A\00"
@.str.3 = [29 x i8] c" Manufacturer ID 2: 0x%02x\0A\00"
@.str.4 = [29 x i8] c" Product type ID 1: 0x%02x\0A\00"
@.str.5 = [29 x i8] c" Product type ID 2: 0x%02x\0A\00"
@.str.6 = [24 x i8] c" Product ID 1: 0x%02x\0A\00"
@.str.7 = [24 x i8] c" Product ID 2: 0x%02x\0A\00"
@str = [30 x i8] c"MANUFACTURER_SPECIFIC_REPORT:\00"
define void @manufacture_dump(i8* nocapture readnone %0, i8* nocapture %1, i32 %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 5
br i1 %5, label %6, label %30
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 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 ([29 x i8], [29 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 ([29 x i8], [29 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 ([29 x i8], [29 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 ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds i8, i8* %1, i64 5
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i8, i8* %1, i64 6
%29 = load i8, i8* %28
br label %30
30: ; preds = %3, %6
%31 = phi i8 [ %29, %6 ], [ %4, %3 ]
%32 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), %6 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %3 ]
%33 = zext i8 %31 to i32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %32, i32 %33)
ret void
}