#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*/ dStrHex(char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ decode_block_thin_prov_vpd(unsigned char *, int);
int /*<<< orphan*/ decode_tapealert_supported_vpd(unsigned char *, int);
int /*<<< orphan*/ printf(char *, int);
void decode_b2_vpd(unsigned char *buff, int len, int do_hex, int pdt) {
  if (do_hex) {
    dStrHex((const char *)buff, len, 0);
    return;
  }
  switch (pdt) {
  case 0x0:
  case 0x4:
  case 0x7:
    decode_block_thin_prov_vpd(buff, len);
    break;
  case 0x1:
  case 0x8:
    decode_tapealert_supported_vpd(buff, len);
    break;
  default:
    printf("  Unable to decode pdt=0x%x, in hex:\n", pdt);
    dStrHex((const char *)buff, len, 0);
    break;
  }
}


x86 assembly (clang, -O0):
<decode_b2_vpd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1172 <decode_b2_vpd+0x32>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1040 <dStrHex@plt>
jmp    1208 <decode_b2_vpd+0xc8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     11c9 <decode_b2_vpd+0x89>
jmp    1185 <decode_b2_vpd+0x45>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     11da <decode_b2_vpd+0x9a>
jmp    1196 <decode_b2_vpd+0x56>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
je     11c9 <decode_b2_vpd+0x89>
jmp    11a7 <decode_b2_vpd+0x67>
mov    -0x18(%rbp),%eax
sub    $0x7,%eax
je     11c9 <decode_b2_vpd+0x89>
jmp    11b8 <decode_b2_vpd+0x78>
mov    -0x18(%rbp),%eax
sub    $0x8,%eax
je     11da <decode_b2_vpd+0x9a>
jmp    11eb <decode_b2_vpd+0xab>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <decode_block_thin_prov_vpd@plt>
jmp    1208 <decode_b2_vpd+0xc8>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <decode_tapealert_supported_vpd@plt>
jmp    1208 <decode_b2_vpd+0xc8>
mov    -0x14(%rbp),%esi
lea    0xe0b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1040 <dStrHex@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_b2_vpd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
test   %edx,%edx
je     115e <decode_b2_vpd+0x1e>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <dStrHex@plt>
cmp    $0x8,%ecx
ja     1197 <decode_b2_vpd+0x57>
mov    $0x91,%eax
bt     %ecx,%eax
jae    117d <decode_b2_vpd+0x3d>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <decode_block_thin_prov_vpd@plt>
mov    $0x102,%eax
bt     %ecx,%eax
jae    1197 <decode_b2_vpd+0x57>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <decode_tapealert_supported_vpd@plt>
lea    0xe62(%rip),%rdi
mov    %ecx,%esi
call   1050 <printf@plt>
jmp    114c <decode_b2_vpd+0xc>

LLVM IR (-O0):
@.str = [38 x i8] c" Unable to decode pdt=0x%x, in hex:\0A\00"
define void @decode_b2_vpd(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = call i32 @dStrHex(i8* %12, i32 %13, i32 0)
br label %31
15: ; preds = %4
%16 = load i32, i32* %8
switch i32 %16, label %25 [
i32 0, label %17
i32 4, label %17
i32 7, label %17
i32 1, label %21
i32 8, label %21
]
17: ; preds = %15, %15, %15
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = call i32 @decode_block_thin_prov_vpd(i8* %18, i32 %19)
br label %31
21: ; preds = %15, %15
%22 = load i8*, i8** %5
%23 = load i32, i32* %6
%24 = call i32 @decode_tapealert_supported_vpd(i8* %22, i32 %23)
br label %31
25: ; preds = %15
%26 = load i32, i32* %8
%27 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i8*, i8** %5
%29 = load i32, i32* %6
%30 = call i32 @dStrHex(i8* %28, i32 %29, i32 0)
br label %31
31: ; preds = %11, %25, %21, %17
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c" Unable to decode pdt=0x%x, in hex:\0A\00"
define void @decode_b2_vpd(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @dStrHex(i8* %0, i32 %1, i32 0)
br label %16
8: ; preds = %4
switch i32 %3, label %13 [
i32 0, label %9
i32 4, label %9
i32 7, label %9
i32 1, label %11
i32 8, label %11
]
9: ; preds = %8, %8, %8
%10 = tail call i32 @decode_block_thin_prov_vpd(i8* %0, i32 %1)
br label %16
11: ; preds = %8, %8
%12 = tail call i32 @decode_tapealert_supported_vpd(i8* %0, i32 %1)
br label %16
13: ; preds = %8
%14 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %3)
%15 = tail call i32 @dStrHex(i8* %0, i32 %1, i32 0)
br label %16
16: ; preds = %6, %13, %11, %9
ret void
}