#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*/ decode_designation_descriptor(unsigned char const *, int,
                                                 int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int decode_block_thin_prov_vpd(unsigned char *b, int len) {
  int dp;
  if (len < 4) {
    fprintf(stderr, "Thin provisioning page too short=%d\n", len);
    return 97;
  }
  dp = !!(b[5] & 0x1);
  printf("  Threshold exponent: %d\n", b[4]);
  printf("  Descriptor present: %d\n", dp);
  if (dp) {
    const unsigned char *ucp;
    int i_len;
    ucp = b + 8;
    i_len = ucp[3];
    if (0 == i_len) {
      fprintf(stderr,
              "Thin provisioning page provisioning group "
              "descriptor too short=%d\n",
              i_len);
      return 0;
    }
    printf("  Provisioning group descriptor\n");
    decode_designation_descriptor(ucp, i_len, 0, 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<decode_block_thin_prov_vpd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    116d <decode_block_thin_prov_vpd+0x3d>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x61,-0x4(%rbp)
jmp    1229 <decode_block_thin_prov_vpd+0xf9>
mov    -0x10(%rbp),%rax
movzbl 0x5(%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     1222 <decode_block_thin_prov_vpd+0xf2>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
jne    1201 <decode_block_thin_prov_vpd+0xd1>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xe69(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1229 <decode_block_thin_prov_vpd+0xf9>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1050 <decode_designation_descriptor@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_block_thin_prov_vpd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x3,%esi
jg     116f <decode_block_thin_prov_vpd+0x2f>
mov    %esi,%edx
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x61,%r15d
jmp    11f1 <decode_block_thin_prov_vpd+0xb1>
mov    %rdi,%r12
movzbl 0x5(%rdi),%ebx
mov    %ebx,%ebp
and    $0x1,%ebp
movzbl 0x4(%rdi),%esi
lea    0xe9f(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
and    $0x1,%ebx
je     11f1 <decode_block_thin_prov_vpd+0xb1>
movzbl 0xb(%r12),%r14d
test   %r14d,%r14d
je     11d7 <decode_block_thin_prov_vpd+0x97>
add    $0x8,%r12
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
xor    %r15d,%r15d
mov    %r12,%rdi
mov    %r14d,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1060 <decode_designation_descriptor@plt>
jmp    11f1 <decode_block_thin_prov_vpd+0xb1>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
xor    %r15d,%r15d
xor    %edx,%edx
call   1050 <fprintf@plt>
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"Thin provisioning page too short=%d\0A\00"
@.str.1 = [26 x i8] c" Threshold exponent: %d\0A\00"
@.str.2 = [26 x i8] c" Descriptor present: %d\0A\00"
@.str.3 = [67 x i8] c"Thin provisioning page provisioning group descriptor too short=%d\0A\00"
@.str.4 = [33 x i8] c" Provisioning group descriptor\0A\00"
define i32 @decode_block_thin_prov_vpd(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i32, i32* %5
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 97, i32* %3
br label %53
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 5
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
store i32 %24, i32* %6
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 4
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %6
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %52
34: ; preds = %15
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 8
store i8* %36, i8** %7
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 3
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = icmp eq i32 0, %41
br i1 %42, label %43, label %47
43: ; preds = %34
%44 = load i32, i32* @stderr
%45 = load i32, i32* %8
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 %45)
store i32 0, i32* %3
br label %53
47: ; preds = %34
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%49 = load i8*, i8** %7
%50 = load i32, i32* %8
%51 = call i32 @decode_designation_descriptor(i8* %49, i32 %50, i32 0, i32 1)
br label %52
52: ; preds = %47, %15
store i32 0, i32* %3
br label %53
53: ; preds = %52, %43, %11
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"Thin provisioning page too short=%d\0A\00"
@.str.1 = [26 x i8] c" Threshold exponent: %d\0A\00"
@.str.2 = [26 x i8] c" Descriptor present: %d\0A\00"
@.str.3 = [67 x i8] c"Thin provisioning page provisioning group descriptor too short=%d\0A\00"
@str = [32 x i8] c" Provisioning group descriptor\00"
define i32 @decode_block_thin_prov_vpd(i8* %0, i32 %1) {
%3 = icmp slt i32 %1, 4
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %30
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 5
%9 = load i8, i8* %8
%10 = and i8 %9, 1
%11 = icmp eq i8 %10, 0
%12 = zext i8 %10 to i32
%13 = getelementptr inbounds i8, i8* %0, i64 4
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br i1 %11, label %30, label %18
18: ; preds = %7
%19 = getelementptr inbounds i8, i8* %0, i64 11
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %30
25: ; preds = %18
%26 = zext i8 %20 to i32
%27 = getelementptr inbounds i8, i8* %0, i64 8
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @decode_designation_descriptor(i8* %27, i32 %26, i32 0, i32 1)
br label %30
30: ; preds = %22, %25, %7, %4
%31 = phi i32 [ 97, %4 ], [ 0, %7 ], [ 0, %25 ], [ 0, %22 ]
ret i32 %31
}