#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 int uint32_t;
typedef int uint16_t;
typedef scalar_t__ msb;
typedef int lsb;

/* Variables and functions */
int us_bits_get_quadlet(void *, int);
int /*<<< orphan*/ us_bits_set_quadlet(void *, int, int);
void us_bits_set_quadlet_bitfield(void *base, uint16_t offset, uint16_t msb,
                                  uint16_t lsb, uint32_t newbits) {
  uint32_t v = us_bits_get_quadlet(base, offset);
  v = (((newbits) << (31 - ((lsb)))) |
       (((v)) & ((~(((0xffffffff) >> (32 - ((((lsb) - (msb) + 1)))))
                    << (31 - ((((lsb))))))) &
                 0xffffffff)));
  us_bits_set_quadlet(base, offset, v);
}


x86 assembly (clang, -O0):
<us_bits_set_quadlet_bitfield>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <us_bits_get_quadlet@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x1f,%ecx
sub    -0x14(%rbp),%ecx
shl    %cl,%eax
mov    -0x1c(%rbp),%ecx
mov    %ecx,-0x20(%rbp)
mov    -0x14(%rbp),%edx
sub    -0x10(%rbp),%edx
add    $0x1,%edx
mov    $0x20,%ecx
sub    %edx,%ecx
mov    $0xffffffff,%edx
shr    %cl,%edx
mov    $0x1f,%ecx
sub    -0x14(%rbp),%ecx
shl    %cl,%edx
mov    -0x20(%rbp),%ecx
xor    $0xffffffff,%edx
and    $0xffffffff,%edx
and    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <us_bits_set_quadlet@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<us_bits_set_quadlet_bitfield>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r12d
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%r15
call   1030 <us_bits_get_quadlet@plt>
mov    $0x1f,%sil
sub    %bpl,%sil
mov    %esi,%ecx
shl    %cl,%r12d
sub    %ebp,%ebx
add    $0x1f,%bl
mov    $0xffffffff,%edx
mov    %ebx,%ecx
shr    %cl,%edx
mov    %esi,%ecx
shl    %cl,%edx
not    %edx
and    %eax,%edx
or     %r12d,%edx
mov    %r15,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <us_bits_set_quadlet@plt>

LLVM IR (-O0):
define void @us_bits_set_quadlet_bitfield(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i32 @us_bits_get_quadlet(i8* %12, i32 %13)
store i32 %14, i32* %11
%15 = load i32, i32* %10
%16 = load i32, i32* %9
%17 = sub nsw i32 31, %16
%18 = shl i32 %15, %17
%19 = load i32, i32* %11
%20 = load i32, i32* %9
%21 = load i32, i32* %8
%22 = sub nsw i32 %20, %21
%23 = add nsw i32 %22, 1
%24 = sub nsw i32 32, %23
%25 = lshr i32 -1, %24
%26 = load i32, i32* %9
%27 = sub nsw i32 31, %26
%28 = shl i32 %25, %27
%29 = xor i32 %28, -1
%30 = and i32 %29, -1
%31 = and i32 %19, %30
%32 = or i32 %18, %31
store i32 %32, i32* %11
%33 = load i8*, i8** %6
%34 = load i32, i32* %7
%35 = load i32, i32* %11
%36 = call i32 @us_bits_set_quadlet(i8* %33, i32 %34, i32 %35)
ret void
}

LLVM IR (-O2):
define void @us_bits_set_quadlet_bitfield(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @us_bits_get_quadlet(i8* %0, i32 %1)
%7 = sub nsw i32 31, %3
%8 = shl i32 %4, %7
%9 = add i32 %2, 31
%10 = sub i32 %9, %3
%11 = lshr i32 -1, %10
%12 = shl i32 %11, %7
%13 = xor i32 %12, -1
%14 = and i32 %6, %13
%15 = or i32 %14, %8
%16 = tail call i32 @us_bits_set_quadlet(i8* %0, i32 %1, i32 %15)
ret void
}