#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 scalar_t__ function;
typedef scalar_t__ device;

/* Variables and functions */
int /*<<< orphan*/ outd(int, unsigned int);
void writePCIConfigReg(unsigned char bus, unsigned char device,
                       unsigned char function, unsigned char reg,
                       unsigned int value) {
  unsigned int pci_address =
      ((((unsigned int)(bus)) << 16) | (((unsigned int)((device)&0x1F)) << 11) |
       (((unsigned int)((function)&0x7)) << 8) |
       ((unsigned int)(((reg) << 2) & 0xFC)) | (unsigned int)0x80000000);
  ;
  outd(0xCF8, pci_address);
  outd(0xCFC, value);
}


x86 assembly (clang, -O0):
<writePCIConfigReg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %cl,-0x3(%rbp)
mov    %al,-0x4(%rbp)
mov    %r8d,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x10,%eax
movzbl -0x2(%rbp),%ecx
and    $0x1f,%ecx
shl    $0xb,%ecx
or     %ecx,%eax
movzbl -0x3(%rbp),%ecx
and    $0x7,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x4(%rbp),%ecx
shl    $0x2,%ecx
and    $0xfc,%ecx
or     %ecx,%eax
or     $0x80000000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0xcf8,%edi
call   1030 <outd@plt>
mov    -0x8(%rbp),%esi
mov    $0xcfc,%edi
call   1030 <outd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writePCIConfigReg>:
push   %rbx
mov    %r8d,%ebx
shl    $0x10,%edi
and    $0x1f,%esi
shl    $0xb,%esi
or     %edi,%esi
and    $0x7,%edx
shl    $0x8,%edx
or     %esi,%edx
and    $0x3f,%ecx
lea    (%rdx,%rcx,4),%esi
add    $0x80000000,%esi
mov    $0xcf8,%edi
call   1030 <outd@plt>
mov    $0xcfc,%edi
mov    %ebx,%esi
pop    %rbx
jmp    1030 <outd@plt>

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

LLVM IR (-O2):
define void @writePCIConfigReg(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i32 %4) {
%6 = zext i8 %0 to i32
%7 = shl nuw nsw i32 %6, 16
%8 = and i8 %1, 31
%9 = zext i8 %8 to i32
%10 = shl nuw nsw i32 %9, 11
%11 = or i32 %10, %7
%12 = and i8 %2, 7
%13 = zext i8 %12 to i32
%14 = shl nuw nsw i32 %13, 8
%15 = or i32 %11, %14
%16 = zext i8 %3 to i32
%17 = shl nuw nsw i32 %16, 2
%18 = and i32 %17, 252
%19 = or i32 %15, %18
%20 = or i32 %19, -2147483648
%21 = tail call i32 @outd(i32 3320, i32 %20)
%22 = tail call i32 @outd(i32 3324, i32 %4)
ret void
}