#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 *, char);
int main() {
  union {
    int a;
    char b[2];
  } * p, u;
  p = &u;
  p->b[0] = 0x38;
  p->b[1] = 0x39;
  printf("%x\n", u.a);
  char *rp = (char *)p;
  printf("%x\n", rp[0]);
  printf("%x\n", rp[1]);
  printf("%x\n", rp[2]);
  printf("%x\n", rp[3]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x38,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x39,0x1(%rax)
mov    -0x18(%rbp),%eax
lea    0xec0(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
lea    0xea5(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
lea    0xe92(%rip),%rdi
movsbl 0x1(%rax),%esi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
lea    0xe7e(%rip),%rdi
movsbl 0x2(%rax),%esi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
lea    0xe6a(%rip),%rdi
movsbl 0x3(%rax),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x38,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x38,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x39,%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>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%union.anon = type { i32 }
@.str = [4 x i8] c"%x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %union.anon*
%3 = alloca %union.anon
%4 = alloca i8*
store i32 0, i32* %1
store %union.anon* %3, %union.anon** %2
%5 = load %union.anon*, %union.anon** %2
%6 = bitcast %union.anon* %5 to [2 x i8]*
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
store i8 56, i8* %7
%8 = load %union.anon*, %union.anon** %2
%9 = bitcast %union.anon* %8 to [2 x i8]*
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 1
store i8 57, i8* %10
%11 = bitcast %union.anon* %3 to i32*
%12 = load i32, i32* %11
%13 = trunc i32 %12 to i8
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %13)
%15 = load %union.anon*, %union.anon** %2
%16 = bitcast %union.anon* %15 to i8*
store i8* %16, i8** %4
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %19)
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = load i8, i8* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %27)
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 3
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %31)
ret i32 0
}

LLVM IR (-O2):
%union.anon = type { i32 }
@.str = [4 x i8] c"%x\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext 56)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext 56)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext 57)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext undef)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext undef)
ret i32 0
}