#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void test1(void) {
  int i;
  struct T {
    const int *ptr;
    unsigned int foo : 1, bar : 1;
  } foo = {.bar = 1};
  for (i = 0; i < sizeof(struct T); ++i) {
    printf("%d ", ((char *)&foo)[i]);
  }
  printf(" (%lu)\n", sizeof(struct T));
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0x10,%rax
jae    1166 <test1+0x56>
movslq -0x4(%rbp),%rax
movsbl -0x18(%rbp,%rax,1),%esi
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1135 <test1+0x25>
lea    0xea7(%rip),%rdi
mov    $0x10,%esi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %rbx
lea    0xef8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
movsbl 0xed8(%rip),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsbl 0xeca(%rip),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsbl 0xebc(%rip),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsbl 0xeae(%rip),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsbl 0xea0(%rip),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsbl 0xe92(%rip),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsbl 0xe84(%rip),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xe2f(%rip),%rdi
mov    $0x10,%esi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.T = type { i32*, i8 }
@__const.test1.foo = %struct.T { i32* null, i8 2 }
@.str = [4 x i8] c"%d \00"
@.str.1 = [8 x i8] c" (%lu)\0A\00"
define void @test1() {
%1 = alloca i32
%2 = alloca %struct.T
%3 = bitcast %struct.T* %2 to i8*
store i32 0, i32* %1
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %1
%6 = sext i32 %5 to i64
%7 = icmp ult i64 %6, 16
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = bitcast %struct.T* %2 to i8*
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %8
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
br label %4
19: ; preds = %4
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 16)
ret void
}

LLVM IR (-O2):
%struct.T = type { i32*, i8 }
@__const.test1.foo = %struct.T { i32* null, i8 2 }
@.str = [4 x i8] c"%d \00"
@.str.1 = [8 x i8] c" (%lu)\0A\00"
define void @test1() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = load i8, i8* getelementptr inbounds (i8, i8* bitcast (%struct.T* @__const.test1.foo to i8*), i64 1)
%3 = sext i8 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i8, i8* getelementptr inbounds (i8, i8* bitcast (%struct.T* @__const.test1.foo to i8*), i64 2)
%6 = sext i8 %5 to i32
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i8, i8* getelementptr inbounds (i8, i8* bitcast (%struct.T* @__const.test1.foo to i8*), i64 3)
%9 = sext i8 %8 to i32
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i8, i8* getelementptr inbounds (i8, i8* bitcast (%struct.T* @__const.test1.foo to i8*), i64 4)
%12 = sext i8 %11 to i32
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i8, i8* getelementptr inbounds (i8, i8* bitcast (%struct.T* @__const.test1.foo to i8*), i64 5)
%15 = sext i8 %14 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i8, i8* getelementptr inbounds (i8, i8* bitcast (%struct.T* @__const.test1.foo to i8*), i64 6)
%18 = sext i8 %17 to i32
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i8, i8* getelementptr inbounds (i8, i8* bitcast (%struct.T* @__const.test1.foo to i8*), i64 7)
%21 = sext i8 %20 to i32
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 16)
ret void
}