#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 */
typedef int u_char;

/* Variables and functions */
int /*<<< orphan*/ print_size(int);
int /*<<< orphan*/ printf(char *, ...);
void dump_bar(u_char *p, int len) {
  if (len < 6) {
    printf("\tWrong length for BAR tuple\n");
    return;
  }
  printf("\tBAR %d: size = ", *p & 7);
  print_size(((*((p + 2) + 3) << 24) | (*((p + 2) + 2) << 16) |
              (*((p + 2) + 1) << 8) | *(p + 2)));
  printf(", %s%s%s%s\n", (*p & 0x10) ? "I/O" : "Memory",
         (*p & 0x20) ? ", Prefetch" : "", (*p & 0x40) ? ", Cacheable" : "",
         (*p & 0x80) ? ", <1Mb" : "");
}


x86 assembly (clang, -O0):
<dump_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    114c <dump_bar+0x2c>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121a <dump_bar+0xfa>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
and    $0x7,%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edi
shl    $0x18,%edi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%eax
shl    $0x10,%eax
or     %eax,%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%eax
shl    $0x8,%eax
or     %eax,%edi
mov    -0x8(%rbp),%rax
or     0x8(%rax),%edi
call   1030 <print_size@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
and    $0x10,%ecx
lea    0xe9d(%rip),%rsi
lea    0xe92(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
and    $0x20,%ecx
lea    0xe5d(%rip),%rdx
lea    0xe7f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
and    $0x40,%edi
lea    0xe3f(%rip),%rcx
lea    0xe6c(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
and    $0x80,%edi
lea    0xe1e(%rip),%r8
lea    0xe57(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r8
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_bar>:
cmp    $0x5,%esi
jg     1141 <dump_bar+0x11>
lea    0xf0a(%rip),%rdi
jmp    1030 <puts@plt>
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%esi
and    $0x7,%esi
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%eax
shl    $0x18,%eax
mov    0xc(%rbx),%edi
mov    0x10(%rbx),%ecx
shl    $0x10,%ecx
or     %eax,%ecx
shl    $0x8,%edi
or     %ecx,%edi
or     0x8(%rbx),%edi
call   1040 <print_size@plt>
mov    (%rbx),%eax
test   $0x10,%al
lea    0xea0(%rip),%rcx
lea    0xe95(%rip),%rsi
cmove  %rcx,%rsi
test   $0x20,%al
lea    0xe87(%rip),%rdi
lea    0xe8c(%rip),%rdx
cmove  %rdi,%rdx
test   $0x40,%al
lea    0xe8a(%rip),%rcx
cmove  %rdi,%rcx
test   $0x80,%al
lea    0xe89(%rip),%r8
cmove  %rdi,%r8
lea    0xe50(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"\09Wrong length for BAR tuple\0A\00"
@.str.1 = [17 x i8] c"\09BAR %d: size = \00"
@.str.2 = [12 x i8] c", %s%s%s%s\0A\00"
@.str.3 = [4 x i8] c"I/O\00"
@.str.4 = [7 x i8] c"Memory\00"
@.str.5 = [11 x i8] c", Prefetch\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c", Cacheable\00"
@.str.8 = [7 x i8] c", <1Mb\00"
define void @dump_bar(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp slt i32 %5, 6
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %61
9: ; preds = %2
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
%12 = and i32 %11, 7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 2
%16 = getelementptr inbounds i32, i32* %15, i64 3
%17 = load i32, i32* %16
%18 = shl i32 %17, 24
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 2
%21 = getelementptr inbounds i32, i32* %20, i64 2
%22 = load i32, i32* %21
%23 = shl i32 %22, 16
%24 = or i32 %18, %23
%25 = load i32*, i32** %3
%26 = getelementptr inbounds i32, i32* %25, i64 2
%27 = getelementptr inbounds i32, i32* %26, i64 1
%28 = load i32, i32* %27
%29 = shl i32 %28, 8
%30 = or i32 %24, %29
%31 = load i32*, i32** %3
%32 = getelementptr inbounds i32, i32* %31, i64 2
%33 = load i32, i32* %32
%34 = or i32 %30, %33
%35 = call i32 @print_size(i32 %34)
%36 = load i32*, i32** %3
%37 = load i32, i32* %36
%38 = and i32 %37, 16
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0)
%42 = load i32*, i32** %3
%43 = load i32, i32* %42
%44 = and i32 %43, 32
%45 = icmp ne i32 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0)
%48 = load i32*, i32** %3
%49 = load i32, i32* %48
%50 = and i32 %49, 64
%51 = icmp ne i32 %50, 0
%52 = zext i1 %51 to i64
%53 = select i1 %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0)
%54 = load i32*, i32** %3
%55 = load i32, i32* %54
%56 = and i32 %55, 128
%57 = icmp ne i32 %56, 0
%58 = zext i1 %57 to i64
%59 = select i1 %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* %47, i8* %53, i8* %59)
br label %61
61: ; preds = %9, %7
ret void
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"\09BAR %d: size = \00"
@.str.2 = [12 x i8] c", %s%s%s%s\0A\00"
@.str.3 = [4 x i8] c"I/O\00"
@.str.4 = [7 x i8] c"Memory\00"
@.str.5 = [11 x i8] c", Prefetch\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c", Cacheable\00"
@.str.8 = [7 x i8] c", <1Mb\00"
@str = [28 x i8] c"\09Wrong length for BAR tuple\00"
define void @dump_bar(i32* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 6
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %39
6: ; preds = %2
%7 = load i32, i32* %0
%8 = and i32 %7, 7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds i32, i32* %0, i64 2
%11 = getelementptr inbounds i32, i32* %0, i64 5
%12 = load i32, i32* %11
%13 = shl i32 %12, 24
%14 = getelementptr inbounds i32, i32* %0, i64 4
%15 = load i32, i32* %14
%16 = shl i32 %15, 16
%17 = or i32 %16, %13
%18 = getelementptr inbounds i32, i32* %0, i64 3
%19 = load i32, i32* %18
%20 = shl i32 %19, 8
%21 = or i32 %17, %20
%22 = load i32, i32* %10
%23 = or i32 %21, %22
%24 = tail call i32 @print_size(i32 %23)
%25 = load i32, i32* %0
%26 = and i32 %25, 16
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%29 = and i32 %25, 32
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0)
%32 = and i32 %25, 64
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0)
%35 = and i32 %25, 128
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %31, i8* %34, i8* %37)
br label %39
39: ; preds = %6, %4
ret void
}