#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 main(void) {
  typedef struct {
    unsigned short a : 1;
    unsigned short b : 1;
    unsigned short c : 1;
    unsigned short d : 4;
  } field;
  field f;
  f.a = 0;
  printf("%d\n", f.a);
  f.a = f.a + 1;
  printf("%d\n", f.a);
  f.a = f.a + 1;
  printf("%d\n", f.a);
  printf("\n");
  f.d = 1;
  f.d = f.d + 1;
  printf("%d\n", f.d);
  printf("size of field: %zu bytes\n", sizeof(field));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%al
and    $0xfe,%al
or     $0x0,%al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movzwl %ax,%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movzwl %ax,%eax
add    $0x1,%eax
mov    %al,%cl
mov    -0x8(%rbp),%al
and    $0x1,%cl
and    $0xfe,%al
or     %cl,%al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movzwl %ax,%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movzwl %ax,%eax
add    $0x1,%eax
mov    %al,%cl
mov    -0x8(%rbp),%al
and    $0x1,%cl
and    $0xfe,%al
or     %cl,%al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movzwl %ax,%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%al
and    $0x87,%al
or     $0x8,%al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
shr    $0x3,%al
and    $0xf,%al
movzbl %al,%eax
movzwl %ax,%eax
add    $0x1,%eax
mov    %al,%cl
mov    -0x8(%rbp),%al
and    $0xf,%cl
shl    $0x3,%cl
and    $0x87,%al
or     %cl,%al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
shr    $0x3,%al
and    $0xf,%al
movzbl %al,%eax
movzwl %ax,%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf8(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.field = type { i8, i8 }
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [26 x i8] c"size of field: %zu bytes\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.field
store i32 0, i32* %1
%3 = bitcast %struct.field* %2 to i8*
%4 = load i8, i8* %3
%5 = and i8 %4, -2
%6 = or i8 %5, 0
store i8 %6, i8* %3
%7 = bitcast %struct.field* %2 to i8*
%8 = load i8, i8* %7
%9 = and i8 %8, 1
%10 = zext i8 %9 to i16
%11 = zext i16 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = bitcast %struct.field* %2 to i8*
%14 = load i8, i8* %13
%15 = and i8 %14, 1
%16 = zext i8 %15 to i16
%17 = zext i16 %16 to i32
%18 = add nsw i32 %17, 1
%19 = trunc i32 %18 to i16
%20 = bitcast %struct.field* %2 to i8*
%21 = trunc i16 %19 to i8
%22 = load i8, i8* %20
%23 = and i8 %21, 1
%24 = and i8 %22, -2
%25 = or i8 %24, %23
store i8 %25, i8* %20
%26 = zext i8 %23 to i16
%27 = bitcast %struct.field* %2 to i8*
%28 = load i8, i8* %27
%29 = and i8 %28, 1
%30 = zext i8 %29 to i16
%31 = zext i16 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = bitcast %struct.field* %2 to i8*
%34 = load i8, i8* %33
%35 = and i8 %34, 1
%36 = zext i8 %35 to i16
%37 = zext i16 %36 to i32
%38 = add nsw i32 %37, 1
%39 = trunc i32 %38 to i16
%40 = bitcast %struct.field* %2 to i8*
%41 = trunc i16 %39 to i8
%42 = load i8, i8* %40
%43 = and i8 %41, 1
%44 = and i8 %42, -2
%45 = or i8 %44, %43
store i8 %45, i8* %40
%46 = zext i8 %43 to i16
%47 = bitcast %struct.field* %2 to i8*
%48 = load i8, i8* %47
%49 = and i8 %48, 1
%50 = zext i8 %49 to i16
%51 = zext i16 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%54 = bitcast %struct.field* %2 to i8*
%55 = load i8, i8* %54
%56 = and i8 %55, -121
%57 = or i8 %56, 8
store i8 %57, i8* %54
%58 = bitcast %struct.field* %2 to i8*
%59 = load i8, i8* %58
%60 = lshr i8 %59, 3
%61 = and i8 %60, 15
%62 = zext i8 %61 to i16
%63 = zext i16 %62 to i32
%64 = add nsw i32 %63, 1
%65 = trunc i32 %64 to i16
%66 = bitcast %struct.field* %2 to i8*
%67 = trunc i16 %65 to i8
%68 = load i8, i8* %66
%69 = and i8 %67, 15
%70 = shl i8 %69, 3
%71 = and i8 %68, -121
%72 = or i8 %71, %70
store i8 %72, i8* %66
%73 = zext i8 %69 to i16
%74 = bitcast %struct.field* %2 to i8*
%75 = load i8, i8* %74
%76 = lshr i8 %75, 3
%77 = and i8 %76, 15
%78 = zext i8 %77 to i16
%79 = zext i16 %78 to i32
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %79)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 2)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.2 = [26 x i8] c"size of field: %zu bytes\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 2)
ret i32 0
}