__attribute__((no, noclone)) void fn1(void) {
  volatile struct S {
    char a[1];
    char b;
  } s;
  volatile int i;
  asm("" : : "r"(&s.a) : "memory");
  i = s.a[0];
  asm("" : : "r"(&s.a) : "memory");
  i = s.a[1];
  volatile struct S *p = &s;
  asm("" : : "r"(&p->a) : "memory");
  i = p->a[0];
  asm("" : : "r"(&p->a) : "memory");
  i = p->a[1];
}


x86 assembly (clang, -O0):
<fn1>:
push   %rbp
mov    %rsp,%rbp
lea    -0x8(%rbp),%rax
mov    -0x8(%rbp),%al
movsbl %al,%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rax
mov    -0x7(%rbp),%al
movsbl %al,%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x18(%rbp),%rax
mov    (%rax),%al
movsbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%al
movsbl %al,%eax
mov    %eax,-0xc(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn1>:
lea    -0x8(%rsp),%rax
movsbl -0x8(%rsp),%ecx
mov    %ecx,-0x4(%rsp)
movsbl -0x7(%rsp),%ecx
mov    %ecx,-0x4(%rsp)
movsbl -0x8(%rsp),%ecx
mov    %ecx,-0x4(%rsp)
movsbl -0x7(%rsp),%eax
mov    %eax,-0x4(%rsp)
ret

LLVM IR (-O0):
%struct.S = type { [1 x i8], i8 }
define void @fn1() {
%1 = alloca %struct.S
%2 = alloca i32
%3 = alloca %struct.S*
%4 = getelementptr inbounds %struct.S, %struct.S* %1, i32 0, i32 0
%5 = getelementptr inbounds %struct.S, %struct.S* %1, i32 0, i32 0
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%7 = load volatile i8, i8* %6
%8 = sext i8 %7 to i32
store volatile i32 %8, i32* %2
%9 = getelementptr inbounds %struct.S, %struct.S* %1, i32 0, i32 0
%10 = getelementptr inbounds %struct.S, %struct.S* %1, i32 0, i32 0
%11 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 1
%12 = load volatile i8, i8* %11
%13 = sext i8 %12 to i32
store volatile i32 %13, i32* %2
store %struct.S* %1, %struct.S** %3
%14 = load %struct.S*, %struct.S** %3
%15 = getelementptr inbounds %struct.S, %struct.S* %14, i32 0, i32 0
%16 = load %struct.S*, %struct.S** %3
%17 = getelementptr inbounds %struct.S, %struct.S* %16, i32 0, i32 0
%18 = getelementptr inbounds [1 x i8], [1 x i8]* %17, i64 0, i64 0
%19 = load volatile i8, i8* %18
%20 = sext i8 %19 to i32
store volatile i32 %20, i32* %2
%21 = load %struct.S*, %struct.S** %3
%22 = getelementptr inbounds %struct.S, %struct.S* %21, i32 0, i32 0
%23 = load %struct.S*, %struct.S** %3
%24 = getelementptr inbounds %struct.S, %struct.S* %23, i32 0, i32 0
%25 = getelementptr inbounds [1 x i8], [1 x i8]* %24, i64 0, i64 1
%26 = load volatile i8, i8* %25
%27 = sext i8 %26 to i32
store volatile i32 %27, i32* %2
ret void
}

LLVM IR (-O2):
%struct.S = type { [1 x i8], i8 }
define void @fn1() {
%1 = alloca %struct.S
%2 = alloca i32
%3 = getelementptr inbounds %struct.S, %struct.S* %1, i64 0, i32 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds %struct.S, %struct.S* %1, i64 0, i32 0
%6 = load volatile i8, i8* %3
%7 = sext i8 %6 to i32
store volatile i32 %7, i32* %2
%8 = getelementptr inbounds %struct.S, %struct.S* %1, i64 0, i32 0, i64 1
%9 = load volatile i8, i8* %8
%10 = sext i8 %9 to i32
store volatile i32 %10, i32* %2
%11 = load volatile i8, i8* %3
%12 = sext i8 %11 to i32
store volatile i32 %12, i32* %2
%13 = load volatile i8, i8* %8
%14 = sext i8 %13 to i32
store volatile i32 %14, i32* %2
ret void
}