#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 char pci_read_config8(unsigned int, int);
int /*<<< orphan*/ print_debug(char *);
int /*<<< orphan*/ print_debug_char(char);
int /*<<< orphan*/ print_debug_hex8(unsigned char);
int /*<<< orphan*/ print_debug_pci_dev(unsigned int);
void dump_pci_device(unsigned dev) {
  int i;
  print_debug_pci_dev(dev);
  print_debug("\n");
  for (i = 0; i <= 255; i++) {
    unsigned char val;
    if ((i & 0x0f) == 0) {
      print_debug_hex8(i);
      print_debug_char(':');
    }
    val = pci_read_config8(dev, i);
    print_debug_char(' ');
    print_debug_hex8(val);
    if ((i & 0x0f) == 0x0f) {
      print_debug("\n");
    }
  }
}


x86 assembly (clang, -O0):
<dump_pci_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <print_debug_pci_dev@plt>
lea    0xe96(%rip),%rdi
call   1050 <print_debug@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xff,-0x8(%rbp)
jg     11f6 <dump_pci_device+0xa6>
mov    -0x8(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11a7 <dump_pci_device+0x57>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x3a,%edi
call   1060 <print_debug_char@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <pci_read_config8@plt>
mov    %al,-0x9(%rbp)
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
movzbl -0x9(%rbp),%edi
call   1030 <print_debug_hex8@plt>
mov    -0x8(%rbp),%eax
and    $0xf,%eax
cmp    $0xf,%eax
jne    11e3 <dump_pci_device+0x93>
lea    0xe22(%rip),%rdi
call   1050 <print_debug@plt>
jmp    11e8 <dump_pci_device+0x98>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <dump_pci_device+0x26>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_pci_device>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
call   1070 <print_debug_pci_dev@plt>
lea    0xe99(%rip),%r14
mov    %r14,%rdi
call   1050 <print_debug@plt>
xor    %ebp,%ebp
jmp    118b <dump_pci_device+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11d4 <dump_pci_device+0x84>
mov    %ebp,%ebx
and    $0xf,%ebx
jne    11a5 <dump_pci_device+0x55>
movzbl %bpl,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x3a,%edi
call   1060 <print_debug_char@plt>
mov    %r15d,%edi
mov    %ebp,%esi
call   1040 <pci_read_config8@plt>
mov    %eax,%r12d
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
movzbl %r12b,%edi
call   1030 <print_debug_hex8@plt>
cmp    $0xf,%ebx
jne    1180 <dump_pci_device+0x30>
mov    %r14,%rdi
call   1050 <print_debug@plt>
jmp    1180 <dump_pci_device+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @dump_pci_device(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @print_debug_pci_dev(i32 %5)
%7 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %33, %1
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 255
br i1 %10, label %11, label %36
11: ; preds = %8
%12 = load i32, i32* %3
%13 = and i32 %12, 15
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* %3
%17 = trunc i32 %16 to i8
%18 = call i32 @print_debug_hex8(i8 zeroext %17)
%19 = call i32 @print_debug_char(i8 signext 58)
br label %20
20: ; preds = %15, %11
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call zeroext i8 @pci_read_config8(i32 %21, i32 %22)
store i8 %23, i8* %4
%24 = call i32 @print_debug_char(i8 signext 32)
%25 = load i8, i8* %4
%26 = call i32 @print_debug_hex8(i8 zeroext %25)
%27 = load i32, i32* %3
%28 = and i32 %27, 15
%29 = icmp eq i32 %28, 15
br i1 %29, label %30, label %32
30: ; preds = %20
%31 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %20
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %8
36: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define void @dump_pci_device(i32 %0) {
%2 = tail call i32 @print_debug_pci_dev(i32 %0)
%3 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %1, %19
%5 = phi i32 [ 0, %1 ], [ %20, %19 ]
%6 = and i32 %5, 15
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = trunc i32 %5 to i8
%10 = tail call i32 @print_debug_hex8(i8 zeroext %9)
%11 = tail call i32 @print_debug_char(i8 signext 58)
br label %12
12: ; preds = %8, %4
%13 = tail call zeroext i8 @pci_read_config8(i32 %0, i32 %5)
%14 = tail call i32 @print_debug_char(i8 signext 32)
%15 = tail call i32 @print_debug_hex8(i8 zeroext %13)
%16 = icmp eq i32 %6, 15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = add nuw nsw i32 %5, 1
%21 = icmp eq i32 %20, 256
br i1 %21, label %22, label %4
22: ; preds = %19
ret void
}