#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 */
typedef struct ds TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ st;
struct ds {
  unsigned int b00l03;
  unsigned int b03l01;
  unsigned int b04l18;
  unsigned int b1Cl04;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ hexlify(char *, TYPE_1__ *, int);
int /*<<< orphan*/ memset(TYPE_1__ *, int, int);
void ex_bitfield(void) {
  struct ds {
    unsigned int b00l03 : 3;
    unsigned int b03l01 : 1;
    unsigned int b04l18 : 24;
    unsigned int b1Cl04 : 4;
  } st;
  assert(4 == sizeof(st));
  memset(&st, 0xFF, sizeof(st));
  st.b00l03 = 3;
  st.b04l18 = 24;
  st.b1Cl04 = 4;
  hexlify("bitfield lsb on le", &st, sizeof(st));
}


x86 assembly (clang, -O0):
<ex_bitfield>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1050 <assert@plt>
lea    -0x8(%rbp),%rdi
mov    $0xff,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%eax
and    $0xfffffff8,%eax
or     $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf000000f,%eax
or     $0x180,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfffffff,%eax
or     $0x40000000,%eax
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x4,%edx
call   1040 <hexlify@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex_bitfield>:
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
call   1050 <assert@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    0x8(%rsp),%eax
and    $0x8,%eax
or     $0x40000183,%eax
mov    %eax,0x8(%rsp)
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1040 <hexlify@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.ds = type { i32 }
%struct.ds.0 = type { i32, i32, i32, i32 }
@.str = [19 x i8] c"bitfield lsb on le\00"
define void @ex_bitfield() {
%1 = alloca %struct.ds
%2 = call i32 @assert(i32 1)
%3 = bitcast %struct.ds* %1 to %struct.ds.0*
%4 = call i32 @memset(%struct.ds.0* %3, i32 255, i32 4)
%5 = bitcast %struct.ds* %1 to i32*
%6 = load i32, i32* %5
%7 = and i32 %6, -8
%8 = or i32 %7, 3
store i32 %8, i32* %5
%9 = bitcast %struct.ds* %1 to i32*
%10 = load i32, i32* %9
%11 = and i32 %10, -268435441
%12 = or i32 %11, 384
store i32 %12, i32* %9
%13 = bitcast %struct.ds* %1 to i32*
%14 = load i32, i32* %13
%15 = and i32 %14, 268435455
%16 = or i32 %15, 1073741824
store i32 %16, i32* %13
%17 = bitcast %struct.ds* %1 to %struct.ds.0*
%18 = call i32 @hexlify(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.ds.0* %17, i32 4)
ret void
}

LLVM IR (-O2):
%struct.ds = type { i32 }
%struct.ds.0 = type { i32, i32, i32, i32 }
@.str = [19 x i8] c"bitfield lsb on le\00"
define void @ex_bitfield() {
%1 = alloca %struct.ds
%2 = bitcast %struct.ds* %1 to i8*
%3 = tail call i32 @assert(i32 1)
%4 = bitcast %struct.ds* %1 to %struct.ds.0*
%5 = call i32 @memset(%struct.ds.0* %4, i32 255, i32 4)
%6 = getelementptr inbounds %struct.ds, %struct.ds* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = and i32 %7, 8
%9 = or i32 %8, 1073742211
store i32 %9, i32* %6
%10 = call i32 @hexlify(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.ds.0* %4, i32 4)
ret void
}