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

/* Variables and functions */
int us_bits_get_octlet(void *, int);
int /*<<< orphan*/ us_bits_set_sexlet(void *, int, int);
void us_bits_set_sexlet_bitfield(void *base, uint16_t offset, uint16_t msb,
                                 uint16_t lsb, uint64_t newbits) {
  uint64_t v = us_bits_get_octlet(base, offset);
  v = (((newbits) << (47 - ((lsb)))) |
       (((v)) & ((~(((0xffffffffffffULL) >> (48 - ((((lsb) - (msb) + 1)))))
                    << (47 - ((((lsb))))))) &
                 0xffffffffffffULL)));
  us_bits_set_sexlet(base, offset, v);
}


x86 assembly (clang, -O0):
<us_bits_set_sexlet_bitfield>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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_octlet@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x2f,%ecx
sub    -0x14(%rbp),%ecx
shl    %cl,%eax
cltq
movslq -0x1c(%rbp),%rcx
mov    %rcx,-0x28(%rbp)
mov    -0x14(%rbp),%edx
sub    -0x10(%rbp),%edx
add    $0x1,%edx
mov    $0x30,%ecx
sub    %edx,%ecx
mov    %ecx,%ecx
movabs $0xffffffffffff,%rdx
shr    %cl,%rdx
mov    $0x2f,%ecx
sub    -0x14(%rbp),%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    -0x28(%rbp),%rcx
xor    $0xffffffffffffffff,%rdx
movabs $0xffffffffffff,%rsi
and    %rsi,%rdx
and    %rdx,%rcx
or     %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <us_bits_set_sexlet@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<us_bits_set_sexlet_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_octlet@plt>
mov    $0x2f,%sil
sub    %bpl,%sil
mov    %esi,%ecx
shl    %cl,%r12d
sub    %ebp,%ebx
add    $0x2f,%bl
movabs $0xffffffffffff,%rdx
mov    %ebx,%ecx
shr    %cl,%rdx
mov    %esi,%ecx
shl    %cl,%rdx
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_sexlet@plt>

LLVM IR (-O0):
define void @us_bits_set_sexlet_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_octlet(i8* %12, i32 %13)
store i32 %14, i32* %11
%15 = load i32, i32* %10
%16 = load i32, i32* %9
%17 = sub nsw i32 47, %16
%18 = shl i32 %15, %17
%19 = sext i32 %18 to i64
%20 = load i32, i32* %11
%21 = sext i32 %20 to i64
%22 = load i32, i32* %9
%23 = load i32, i32* %8
%24 = sub nsw i32 %22, %23
%25 = add nsw i32 %24, 1
%26 = sub nsw i32 48, %25
%27 = zext i32 %26 to i64
%28 = lshr i64 281474976710655, %27
%29 = load i32, i32* %9
%30 = sub nsw i32 47, %29
%31 = zext i32 %30 to i64
%32 = shl i64 %28, %31
%33 = xor i64 %32, -1
%34 = and i64 %33, 281474976710655
%35 = and i64 %21, %34
%36 = or i64 %19, %35
%37 = trunc i64 %36 to i32
store i32 %37, i32* %11
%38 = load i8*, i8** %6
%39 = load i32, i32* %7
%40 = load i32, i32* %11
%41 = call i32 @us_bits_set_sexlet(i8* %38, i32 %39, i32 %40)
ret void
}

LLVM IR (-O2):
define void @us_bits_set_sexlet_bitfield(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @us_bits_get_octlet(i8* %0, i32 %1)
%7 = sub nsw i32 47, %3
%8 = shl i32 %4, %7
%9 = add i32 %2, 47
%10 = sub i32 %9, %3
%11 = zext i32 %10 to i64
%12 = lshr i64 281474976710655, %11
%13 = zext i32 %7 to i64
%14 = shl i64 %12, %13
%15 = trunc i64 %14 to i32
%16 = xor i32 %15, -1
%17 = and i32 %6, %16
%18 = or i32 %17, %8
%19 = tail call i32 @us_bits_set_sexlet(i8* %0, i32 %1, i32 %18)
ret void
}