#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ stderr;
int decode_referrals_vpd(unsigned char *b, int len) {
  unsigned int u;
  if (len < 16) {
    fprintf(stderr, "Referrals VPD page length too short=%d\n", len);
    return 97;
  }
  u = ((unsigned int)b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
  printf("  User data segment size: %u\n", u);
  u = ((unsigned int)b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15];
  printf("  User data segment multiplier: %u\n", u);
  return 0;
}


x86 assembly (clang, -O0):
<decode_referrals_vpd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    115d <decode_referrals_vpd+0x3d>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xeb4(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x61,-0x4(%rbp)
jmp    11e6 <decode_referrals_vpd+0xc6>
mov    -0x10(%rbp),%rax
movzbl 0x8(%rax),%eax
shl    $0x18,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x9(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xa(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xb(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl 0xc(%rax),%eax
shl    $0x18,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xd(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xe(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xf(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_referrals_vpd>:
push   %rbx
cmp    $0xf,%esi
jg     1144 <decode_referrals_vpd+0x24>
mov    %esi,%edx
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    0xec8(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x61,%eax
pop    %rbx
ret
mov    %rdi,%rbx
mov    0x8(%rdi),%esi
bswap  %esi
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rbx),%esi
bswap  %esi
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [40 x i8] c"Referrals VPD page length too short=%d\0A\00"
@.str.1 = [30 x i8] c" User data segment size: %u\0A\00"
@.str.2 = [36 x i8] c" User data segment multiplier: %u\0A\00"
define i32 @decode_referrals_vpd(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* %5
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 97, i32* %3
br label %62
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 8
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl i32 %17, 24
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 9
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = shl i32 %22, 16
%24 = or i32 %18, %23
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 10
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = shl i32 %28, 8
%30 = or i32 %24, %29
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 11
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = or i32 %30, %34
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 12
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = shl i32 %41, 24
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 13
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = shl i32 %46, 16
%48 = or i32 %42, %47
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i64 14
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = shl i32 %52, 8
%54 = or i32 %48, %53
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 15
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = or i32 %54, %58
store i32 %59, i32* %6
%60 = load i32, i32* %6
%61 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %60)
store i32 0, i32* %3
br label %62
62: ; preds = %13, %9
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"Referrals VPD page length too short=%d\0A\00"
@.str.1 = [30 x i8] c" User data segment size: %u\0A\00"
@.str.2 = [36 x i8] c" User data segment multiplier: %u\0A\00"
define i32 @decode_referrals_vpd(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 16
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 ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %46
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 8
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = shl nuw i32 %10, 24
%12 = getelementptr inbounds i8, i8* %0, i64 9
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %14, 16
%16 = or i32 %15, %11
%17 = getelementptr inbounds i8, i8* %0, i64 10
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl nuw nsw i32 %19, 8
%21 = or i32 %16, %20
%22 = getelementptr inbounds i8, i8* %0, i64 11
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = or i32 %21, %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds i8, i8* %0, i64 12
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = shl nuw i32 %29, 24
%31 = getelementptr inbounds i8, i8* %0, i64 13
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl nuw nsw i32 %33, 16
%35 = or i32 %34, %30
%36 = getelementptr inbounds i8, i8* %0, i64 14
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = shl nuw nsw i32 %38, 8
%40 = or i32 %35, %39
%41 = getelementptr inbounds i8, i8* %0, i64 15
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = or i32 %40, %43
%45 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %7, %4
%47 = phi i32 [ 97, %4 ], [ 0, %7 ]
ret i32 %47
}