#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 */
int /*<<< orphan*/ pci_read_config_dword(unsigned char, unsigned char,
                                         unsigned char, unsigned char,
                                         unsigned int *);
int pci_read_config_byte(unsigned char bus, unsigned char slot,
                         unsigned char function, unsigned char offset,
                         unsigned char *val) {
  unsigned int v;
  pci_read_config_dword(bus, slot, function, offset & ~3, &v);
  *val = 0xff & (v >> (8 * (offset & 3)));
  return 0x00;
}


x86 assembly (clang, -O0):
<pci_read_config_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    %r8,-0x10(%rbp)
mov    -0x1(%rbp),%sil
mov    -0x2(%rbp),%dl
mov    -0x3(%rbp),%cl
movzbl -0x4(%rbp),%eax
and    $0xfffffffc,%eax
lea    -0x14(%rbp),%r8
movzbl %sil,%edi
movzbl %dl,%esi
movzbl %cl,%edx
movzbl %al,%ecx
call   1030 <pci_read_config_dword@plt>
mov    -0x14(%rbp),%eax
movzbl -0x4(%rbp),%ecx
and    $0x3,%ecx
shl    $0x3,%ecx
shr    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pci_read_config_byte>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%ebx
and    $0xfffffffc,%ecx
lea    0x4(%rsp),%r8
call   1030 <pci_read_config_dword@plt>
mov    0x4(%rsp),%eax
lea    0x0(,%rbx,8),%ecx
shr    %cl,%eax
mov    %al,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @pci_read_config_byte(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8* %4) {
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8*
%11 = alloca i32
store i8 %0, i8* %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i8 %3, i8* %9
store i8* %4, i8** %10
%12 = load i8, i8* %6
%13 = load i8, i8* %7
%14 = load i8, i8* %8
%15 = load i8, i8* %9
%16 = zext i8 %15 to i32
%17 = and i32 %16, -4
%18 = trunc i32 %17 to i8
%19 = call i32 @pci_read_config_dword(i8 zeroext %12, i8 zeroext %13, i8 zeroext %14, i8 zeroext %18, i32* %11)
%20 = load i32, i32* %11
%21 = load i8, i8* %9
%22 = zext i8 %21 to i32
%23 = and i32 %22, 3
%24 = mul nsw i32 8, %23
%25 = lshr i32 %20, %24
%26 = and i32 255, %25
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %10
store i8 %27, i8* %28
ret i32 0
}

LLVM IR (-O2):
define i32 @pci_read_config_byte(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8* nocapture writeonly %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = and i8 %3, -4
%9 = call i32 @pci_read_config_dword(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %8, i32* %6)
%10 = load i32, i32* %6
%11 = shl i8 %3, 3
%12 = and i8 %11, 24
%13 = zext i8 %12 to i32
%14 = lshr i32 %10, %13
%15 = trunc i32 %14 to i8
store i8 %15, i8* %4
ret i32 0
}