#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 int inl_p(int);
int /*<<< orphan*/ outl_p(unsigned int, int);
unsigned int extended_pci_read(int bus, int device, int func, int offset) {
  unsigned int tmp, value;
  tmp = 0x80000000 | ((offset & 0xf00) << 16) | ((bus & 0xff) << 16) |
        ((device & 0x1f) << 11) | ((func & 0x7) << 0x8) | (offset & 0xfc);
  outl_p(tmp, 0xcf8);
  value = inl_p(0xcfc);
  return value;
}


x86 assembly (clang, -O0):
<extended_pci_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0xf00,%eax
shl    $0x10,%eax
or     $0x80000000,%eax
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%ecx
and    $0x1f,%ecx
shl    $0xb,%ecx
or     %ecx,%eax
mov    -0xc(%rbp),%ecx
and    $0x7,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%ecx
and    $0xfc,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0xcf8,%esi
call   1040 <outl_p@plt>
mov    $0xcfc,%edi
call   1030 <inl_p@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extended_pci_read>:
push   %rax
mov    %ecx,%eax
shl    $0x10,%eax
and    $0xf000000,%eax
movzbl %dil,%edi
shl    $0x10,%edi
shl    $0xb,%esi
movzwl %si,%esi
or     %edi,%esi
and    $0x7,%edx
shl    $0x8,%edx
or     %esi,%edx
and    $0xfc,%ecx
or     %edx,%ecx
lea    (%rax,%rcx,1),%edi
add    $0x80000000,%edi
mov    $0xcf8,%esi
call   1040 <outl_p@plt>
mov    $0xcfc,%edi
pop    %rax
jmp    1030 <inl_p@plt>

LLVM IR (-O0):
define i32 @extended_pci_read(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %8
%12 = and i32 %11, 3840
%13 = shl i32 %12, 16
%14 = or i32 -2147483648, %13
%15 = load i32, i32* %5
%16 = and i32 %15, 255
%17 = shl i32 %16, 16
%18 = or i32 %14, %17
%19 = load i32, i32* %6
%20 = and i32 %19, 31
%21 = shl i32 %20, 11
%22 = or i32 %18, %21
%23 = load i32, i32* %7
%24 = and i32 %23, 7
%25 = shl i32 %24, 8
%26 = or i32 %22, %25
%27 = load i32, i32* %8
%28 = and i32 %27, 252
%29 = or i32 %26, %28
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = call i32 @outl_p(i32 %30, i32 3320)
%32 = call i32 @inl_p(i32 3324)
store i32 %32, i32* %10
%33 = load i32, i32* %10
ret i32 %33
}

LLVM IR (-O2):
define i32 @extended_pci_read(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = shl i32 %3, 16
%6 = and i32 %5, 251658240
%7 = shl i32 %0, 16
%8 = and i32 %7, 16711680
%9 = shl i32 %1, 11
%10 = and i32 %9, 63488
%11 = shl i32 %2, 8
%12 = and i32 %11, 1792
%13 = and i32 %3, 252
%14 = or i32 %8, %10
%15 = or i32 %14, %12
%16 = or i32 %15, %13
%17 = or i32 %16, %6
%18 = or i32 %17, -2147483648
%19 = tail call i32 @outl_p(i32 %18, i32 3320)
%20 = tail call i32 @inl_p(i32 3324)
ret i32 %20
}