#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ print_binary(int, int);
int /*<<< orphan*/ printf(char *);
void test_with_pointers() {
  printf("\n===== test_with_pointers\n");
  struct MyBitfieldType {
    uint8_t a : 1;
    uint8_t b : 1;
  };
  struct MyBitfieldType bitset;
  struct MyBitfieldType *bitset_pointer;
  bitset.a = 0;
  bitset.b = 1;
  printf("bitset.a                    : ");
  print_binary(bitset.a, 1);
  printf("bitset.b                    : ");
  print_binary(bitset.b, 1);
  bitset_pointer = &bitset;
  printf("bitset_pointer->a           : ");
  print_binary(bitset_pointer->a, 1);
  printf("bitset_pointer->b           : ");
  print_binary(bitset_pointer->b, 1);
  assert(bitset.a == bitset_pointer->a);
  assert(bitset.b == bitset_pointer->b);
}


x86 assembly (clang, -O0):
<test_with_pointers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%al
and    $0xfe,%al
or     $0x0,%al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
and    $0xfd,%al
or     $0x2,%al
mov    %al,-0x8(%rbp)
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%al
shl    $0x7,%al
sar    $0x7,%al
movsbl %al,%edi
mov    $0x1,%esi
call   1050 <print_binary@plt>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%al
shl    $0x6,%al
sar    $0x7,%al
movsbl %al,%edi
mov    $0x1,%esi
call   1050 <print_binary@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
shl    $0x7,%al
sar    $0x7,%al
movsbl %al,%edi
mov    $0x1,%esi
call   1050 <print_binary@plt>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
shl    $0x6,%al
sar    $0x7,%al
movsbl %al,%edi
mov    $0x1,%esi
call   1050 <print_binary@plt>
mov    -0x8(%rbp),%al
shl    $0x7,%al
sar    $0x7,%al
movsbl %al,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%cl
shl    $0x7,%cl
sar    $0x7,%cl
movsbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%al
shl    $0x6,%al
sar    $0x7,%al
movsbl %al,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%cl
shl    $0x6,%cl
sar    $0x7,%cl
movsbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_with_pointers>:
push   %rax
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <print_binary@plt>
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1060 <print_binary@plt>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <print_binary@plt>
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1060 <print_binary@plt>
mov    $0x1,%edi
call   1050 <assert@plt>
mov    $0x1,%edi
pop    %rax
jmp    1050 <assert@plt>

LLVM IR (-O0):
%struct.MyBitfieldType = type { i8, [3 x i8] }
@.str = [27 x i8] c"\0A===== test_with_pointers\0A\00"
@.str.1 = [31 x i8] c"bitset.a : \00"
@.str.2 = [31 x i8] c"bitset.b : \00"
@.str.3 = [31 x i8] c"bitset_pointer->a : \00"
@.str.4 = [31 x i8] c"bitset_pointer->b : \00"
define void @test_with_pointers() {
%1 = alloca %struct.MyBitfieldType
%2 = alloca %struct.MyBitfieldType*
%3 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = bitcast %struct.MyBitfieldType* %1 to i8*
%5 = load i8, i8* %4
%6 = and i8 %5, -2
%7 = or i8 %6, 0
store i8 %7, i8* %4
%8 = bitcast %struct.MyBitfieldType* %1 to i8*
%9 = load i8, i8* %8
%10 = and i8 %9, -3
%11 = or i8 %10, 2
store i8 %11, i8* %8
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%13 = bitcast %struct.MyBitfieldType* %1 to i8*
%14 = load i8, i8* %13
%15 = shl i8 %14, 7
%16 = ashr i8 %15, 7
%17 = sext i8 %16 to i32
%18 = call i32 @print_binary(i32 %17, i32 1)
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%20 = bitcast %struct.MyBitfieldType* %1 to i8*
%21 = load i8, i8* %20
%22 = shl i8 %21, 6
%23 = ashr i8 %22, 7
%24 = sext i8 %23 to i32
%25 = call i32 @print_binary(i32 %24, i32 1)
store %struct.MyBitfieldType* %1, %struct.MyBitfieldType** %2
%26 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%27 = load %struct.MyBitfieldType*, %struct.MyBitfieldType** %2
%28 = bitcast %struct.MyBitfieldType* %27 to i8*
%29 = load i8, i8* %28
%30 = shl i8 %29, 7
%31 = ashr i8 %30, 7
%32 = sext i8 %31 to i32
%33 = call i32 @print_binary(i32 %32, i32 1)
%34 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%35 = load %struct.MyBitfieldType*, %struct.MyBitfieldType** %2
%36 = bitcast %struct.MyBitfieldType* %35 to i8*
%37 = load i8, i8* %36
%38 = shl i8 %37, 6
%39 = ashr i8 %38, 7
%40 = sext i8 %39 to i32
%41 = call i32 @print_binary(i32 %40, i32 1)
%42 = bitcast %struct.MyBitfieldType* %1 to i8*
%43 = load i8, i8* %42
%44 = shl i8 %43, 7
%45 = ashr i8 %44, 7
%46 = sext i8 %45 to i32
%47 = load %struct.MyBitfieldType*, %struct.MyBitfieldType** %2
%48 = bitcast %struct.MyBitfieldType* %47 to i8*
%49 = load i8, i8* %48
%50 = shl i8 %49, 7
%51 = ashr i8 %50, 7
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %46, %52
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = bitcast %struct.MyBitfieldType* %1 to i8*
%57 = load i8, i8* %56
%58 = shl i8 %57, 6
%59 = ashr i8 %58, 7
%60 = sext i8 %59 to i32
%61 = load %struct.MyBitfieldType*, %struct.MyBitfieldType** %2
%62 = bitcast %struct.MyBitfieldType* %61 to i8*
%63 = load i8, i8* %62
%64 = shl i8 %63, 6
%65 = ashr i8 %64, 7
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %60, %66
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
ret void
}

LLVM IR (-O2):
%struct.MyBitfieldType = type { i8, [3 x i8] }
@.str.1 = [31 x i8] c"bitset.a : \00"
@.str.2 = [31 x i8] c"bitset.b : \00"
@.str.3 = [31 x i8] c"bitset_pointer->a : \00"
@.str.4 = [31 x i8] c"bitset_pointer->b : \00"
@str = [26 x i8] c"\0A===== test_with_pointers\00"
define void @test_with_pointers() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @print_binary(i32 0, i32 1)
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @print_binary(i32 -1, i32 1)
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @print_binary(i32 0, i32 1)
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @print_binary(i32 -1, i32 1)
%10 = tail call i32 @assert(i32 1)
%11 = tail call i32 @assert(i32 1)
ret void
}