#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 unsigned int value;

/* Variables and functions */
long aml_read_vcbus(unsigned int);
int /*<<< orphan*/ aml_write_vcbus(unsigned int, long);
void W_APB_BIT(unsigned int reg, unsigned int value, unsigned int start,
               unsigned int len) {
  aml_write_vcbus(reg,
                  ((aml_read_vcbus(reg) & ~(((1L << (len)) - 1) << (start))) |
                   (((value) & ((1L << (len)) - 1)) << (start))));
}


x86 assembly (clang, -O0):
<W_APB_BIT>:
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    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <aml_read_vcbus@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rsi
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
sub    $0x1,%rax
mov    -0xc(%rbp),%ecx
shl    %cl,%rax
xor    $0xffffffffffffffff,%rax
and    %rax,%rsi
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%rdx
mov    %rdx,%rcx
sub    $0x1,%rcx
and    %rcx,%rax
mov    -0xc(%rbp),%ecx
shl    %cl,%rax
or     %rax,%rsi
call   1030 <aml_write_vcbus@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<W_APB_BIT>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
call   1040 <aml_read_vcbus@plt>
mov    $0xffffffffffffffff,%rsi
mov    %ebx,%ecx
shl    %cl,%rsi
not    %rsi
mov    %rsi,%rdx
mov    %ebp,%ecx
shl    %cl,%rdx
not    %rdx
and    %rax,%rdx
and    %r14d,%esi
shl    %cl,%rsi
or     %rdx,%rsi
mov    %r15d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <aml_write_vcbus@plt>

LLVM IR (-O0):
define void @W_APB_BIT(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = load i32, i32* %5
%11 = call i64 @aml_read_vcbus(i32 %10)
%12 = load i32, i32* %8
%13 = zext i32 %12 to i64
%14 = shl i64 1, %13
%15 = sub nsw i64 %14, 1
%16 = load i32, i32* %7
%17 = zext i32 %16 to i64
%18 = shl i64 %15, %17
%19 = xor i64 %18, -1
%20 = and i64 %11, %19
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = load i32, i32* %8
%24 = zext i32 %23 to i64
%25 = shl i64 1, %24
%26 = sub nsw i64 %25, 1
%27 = and i64 %22, %26
%28 = load i32, i32* %7
%29 = zext i32 %28 to i64
%30 = shl i64 %27, %29
%31 = or i64 %20, %30
%32 = call i32 @aml_write_vcbus(i32 %9, i64 %31)
ret void
}

LLVM IR (-O2):
define void @W_APB_BIT(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i64 @aml_read_vcbus(i32 %0)
%6 = zext i32 %3 to i64
%7 = shl nsw i64 -1, %6
%8 = xor i64 %7, -1
%9 = zext i32 %2 to i64
%10 = shl i64 %8, %9
%11 = xor i64 %10, -1
%12 = and i64 %5, %11
%13 = zext i32 %1 to i64
%14 = and i64 %8, %13
%15 = shl i64 %14, %9
%16 = or i64 %12, %15
%17 = tail call i32 @aml_write_vcbus(i32 %0, i64 %16)
ret void
}