#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 /*<<< orphan*/ u;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
void main() {
  struct student {
    int i;
    char ch;
    char *str;
    double exp;
  };
  union stateMachine {
    char character;
    int number;
    char *str;
    double exp;
  };
  printf("sizeof int:%d,sizeof char:%d,sizeof char*:%d,sizeof double:%d\n",
         sizeof(int), sizeof(char), sizeof(char *), sizeof(double));
  printf("sizeof struct:%d\n", sizeof(struct student));
  printf("sizeof union:%d\n", sizeof(union stateMachine));
  union {
    int i;
    char a[2];
  } * p, u;
  printf("\nsizeof union:%d %d\n", sizeof(*p), sizeof(u));
  p = &u;
  p->a[0] = 0x39;
  p->a[1] = 0x38;
  printf("union value p->i:%x,p->a[0]:%c,p->a[1]:%c\n", p->i, p->a[0], p->a[1]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    $0x8,%r8d
mov    %r8,%rcx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
mov    $0x18,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
mov    $0x4,%esi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x39,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x38,0x1(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%ecx
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x1,%edx
mov    $0x8,%ecx
mov    $0x8,%r8d
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
mov    $0x18,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
mov    $0x4,%edx
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
mov    $0x3839,%esi
mov    $0x39,%edx
mov    $0x38,%ecx
xor    %eax,%eax
pop    %r8
jmp    1030 <printf@plt>

LLVM IR (-O0):
%union.anon = type { i32 }
@.str = [63 x i8] c"sizeof int:%d,sizeof char:%d,sizeof char*:%d,sizeof double:%d\0A\00"
@.str.1 = [18 x i8] c"sizeof struct:%d\0A\00"
@.str.2 = [17 x i8] c"sizeof union:%d\0A\00"
@.str.3 = [21 x i8] c"\0Asizeof union:%d %d\0A\00"
@.str.4 = [43 x i8] c"union value p->i:%x,p->a[0]:%c,p->a[1]:%c\0A\00"
define void @main() {
%1 = alloca %union.anon*
%2 = alloca %union.anon
%3 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i32 4, i64 1, i64 8, i64 8)
%4 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 24)
%5 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 8)
%6 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 4, i64 4)
store %union.anon* %2, %union.anon** %1
%7 = load %union.anon*, %union.anon** %1
%8 = bitcast %union.anon* %7 to [2 x i8]*
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8 57, i8* %9
%10 = load %union.anon*, %union.anon** %1
%11 = bitcast %union.anon* %10 to [2 x i8]*
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %11, i64 0, i64 1
store i8 56, i8* %12
%13 = load %union.anon*, %union.anon** %1
%14 = bitcast %union.anon* %13 to i32*
%15 = load i32, i32* %14
%16 = load %union.anon*, %union.anon** %1
%17 = bitcast %union.anon* %16 to [2 x i8]*
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %17, i64 0, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load %union.anon*, %union.anon** %1
%22 = bitcast %union.anon* %21 to [2 x i8]*
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %22, i64 0, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %15, i32 %20, i32 %25)
ret void
}

LLVM IR (-O2):
%union.anon = type { i32 }
@.str = [63 x i8] c"sizeof int:%d,sizeof char:%d,sizeof char*:%d,sizeof double:%d\0A\00"
@.str.1 = [18 x i8] c"sizeof struct:%d\0A\00"
@.str.2 = [17 x i8] c"sizeof union:%d\0A\00"
@.str.3 = [21 x i8] c"\0Asizeof union:%d %d\0A\00"
@.str.4 = [43 x i8] c"union value p->i:%x,p->a[0]:%c,p->a[1]:%c\0A\00"
define void @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i32 4, i64 1, i64 8, i64 8)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 24)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 8)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 4, i64 4)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 14393, i32 57, i32 56)
ret void
}