#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 */
unsigned long pci_read_config32(unsigned int, int);
int /*<<< orphan*/ print_debug(char *);
int /*<<< orphan*/ print_debug_char(char);
int /*<<< orphan*/ print_debug_hex16(int);
int /*<<< orphan*/ print_debug_hex32(int /*<<< orphan*/);
int /*<<< orphan*/ read32(unsigned long);
void dump_bar14(unsigned dev) {
  int i;
  unsigned long bar;
  print_debug("BAR 14 Dump\n");
  bar = pci_read_config32(dev, 0x14);
  for (i = 0; i <= 0x300; i += 4) {
    if ((i % 4) == 0) {
      print_debug("\n");
      print_debug_hex16(i);
      print_debug_char(' ');
    }
    print_debug_hex32(read32(bar + i));
    print_debug_char(' ');
  }
  print_debug("\n");
}


x86 assembly (clang, -O0):
<dump_bar14>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
call   1070 <print_debug@plt>
mov    -0x4(%rbp),%edi
mov    $0x14,%esi
call   1030 <pci_read_config32@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x300,-0x8(%rbp)
jg     11fd <dump_bar14+0x9d>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ce <dump_bar14+0x6e>
lea    0xe54(%rip),%rdi
call   1070 <print_debug@plt>
mov    -0x8(%rbp),%edi
call   1040 <print_debug_hex16@plt>
mov    $0x20,%edi
call   1080 <print_debug_char@plt>
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
call   1060 <read32@plt>
mov    %eax,%edi
call   1050 <print_debug_hex32@plt>
mov    $0x20,%edi
call   1080 <print_debug_char@plt>
mov    -0x8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
jmp    118f <dump_bar14+0x2f>
lea    0xe07(%rip),%rdi
call   1070 <print_debug@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_bar14>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xe92(%rip),%rdi
call   1070 <print_debug@plt>
mov    %ebx,%edi
mov    $0x14,%esi
call   1030 <pci_read_config32@plt>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xe80(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1070 <print_debug@plt>
mov    %ebx,%edi
call   1040 <print_debug_hex16@plt>
mov    $0x20,%edi
call   1080 <print_debug_char@plt>
lea    (%r14,%rbx,1),%rdi
call   1060 <read32@plt>
mov    %eax,%edi
call   1050 <print_debug_hex32@plt>
mov    $0x20,%edi
call   1080 <print_debug_char@plt>
lea    0x4(%rbx),%rax
cmp    $0x2fd,%rbx
mov    %rax,%rbx
jb     1190 <dump_bar14+0x30>
lea    0xe31(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <print_debug@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"BAR 14 Dump\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @dump_bar14(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %2
%5 = call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %2
%7 = call i64 @pci_read_config32(i32 %6, i32 20)
store i64 %7, i64* %4
store i32 0, i32* %3
br label %8
8: ; preds = %28, %1
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 768
br i1 %10, label %11, label %31
11: ; preds = %8
%12 = load i32, i32* %3
%13 = srem i32 %12, 4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* %3
%18 = call i32 @print_debug_hex16(i32 %17)
%19 = call i32 @print_debug_char(i8 signext 32)
br label %20
20: ; preds = %15, %11
%21 = load i64, i64* %4
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = add i64 %21, %23
%25 = call i32 @read32(i64 %24)
%26 = call i32 @print_debug_hex32(i32 %25)
%27 = call i32 @print_debug_char(i8 signext 32)
br label %28
28: ; preds = %20
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 4
store i32 %30, i32* %3
br label %8
31: ; preds = %8
%32 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"BAR 14 Dump\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @dump_bar14(i32 %0) {
%2 = tail call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = tail call i64 @pci_read_config32(i32 %0, i32 20)
br label %4
4: ; preds = %1, %4
%5 = phi i64 [ 0, %1 ], [ %14, %4 ]
%6 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = trunc i64 %5 to i32
%8 = tail call i32 @print_debug_hex16(i32 %7)
%9 = tail call i32 @print_debug_char(i8 signext 32)
%10 = add i64 %3, %5
%11 = tail call i32 @read32(i64 %10)
%12 = tail call i32 @print_debug_hex32(i32 %11)
%13 = tail call i32 @print_debug_char(i8 signext 32)
%14 = add nuw nsw i64 %5, 4
%15 = icmp ult i64 %5, 765
br i1 %15, label %4, label %16
16: ; preds = %4
%17 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}