#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 pcibios_read_config_byte(int /*<<< orphan*/, scalar_t__, int);
int /*<<< orphan*/ pcibios_write_config_byte(int /*<<< orphan*/, scalar_t__,
                                             int, unsigned char);
int /*<<< orphan*/ print_debug(char *);
int /*<<< orphan*/ print_debug_hex8(unsigned char);
void set_ram_command(unsigned command) {
  unsigned char byte;
  command &= 0x7;
  byte = pcibios_read_config_byte(0, ((0x00 << 3) + 0), 0x76);
  byte &= 0x1f;
  byte |= (command << 5);
  pcibios_write_config_byte(0, ((0x00 << 3) + 0), 0x76, byte);
  print_debug("set_ram_command 0x76.b=");
  print_debug_hex8(byte);
  print_debug("\n");
}


x86 assembly (clang, -O0):
<set_ram_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x4(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x76,%edx
call   1060 <pcibios_read_config_byte@plt>
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
and    $0x1f,%eax
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%ecx
shl    $0x5,%ecx
movzbl -0x5(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x5(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x76,%edx
movzbl -0x5(%rbp),%ecx
call   1040 <pcibios_write_config_byte@plt>
lea    0xe65(%rip),%rdi
call   1050 <print_debug@plt>
movzbl -0x5(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe68(%rip),%rdi
call   1050 <print_debug@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ram_command>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x76,%edx
call   1060 <pcibios_read_config_byte@plt>
and    $0x1f,%al
shl    $0x5,%bl
or     %al,%bl
movzbl %bl,%ebx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x76,%edx
mov    %ebx,%ecx
call   1040 <pcibios_write_config_byte@plt>
lea    0xe8e(%rip),%rdi
call   1050 <print_debug@plt>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe93(%rip),%rdi
pop    %rbx
jmp    1050 <print_debug@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"set_ram_command 0x76.b=\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @set_ram_command(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 7
store i32 %5, i32* %2
%6 = call zeroext i8 @pcibios_read_config_byte(i32 0, i64 0, i32 118)
store i8 %6, i8* %3
%7 = load i8, i8* %3
%8 = zext i8 %7 to i32
%9 = and i32 %8, 31
%10 = trunc i32 %9 to i8
store i8 %10, i8* %3
%11 = load i32, i32* %2
%12 = shl i32 %11, 5
%13 = load i8, i8* %3
%14 = zext i8 %13 to i32
%15 = or i32 %14, %12
%16 = trunc i32 %15 to i8
store i8 %16, i8* %3
%17 = load i8, i8* %3
%18 = call i32 @pcibios_write_config_byte(i32 0, i64 0, i32 118, i8 zeroext %17)
%19 = call i32 @print_debug(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%20 = load i8, i8* %3
%21 = call i32 @print_debug_hex8(i8 zeroext %20)
%22 = 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 = [24 x i8] c"set_ram_command 0x76.b=\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @set_ram_command(i32 %0) {
%2 = tail call zeroext i8 @pcibios_read_config_byte(i32 0, i64 0, i32 118)
%3 = and i8 %2, 31
%4 = trunc i32 %0 to i8
%5 = shl i8 %4, 5
%6 = or i8 %3, %5
%7 = tail call i32 @pcibios_write_config_byte(i32 0, i64 0, i32 118, i8 zeroext %6)
%8 = tail call i32 @print_debug(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @print_debug_hex8(i8 zeroext %6)
%10 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}