#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, int, ...);
main() {
  union {
    int l;
    char c[sizeof(int)];
  } u;
  int x0, x1, x2, x3;
  u.l = 0x012345678;
  x0 = u.c[0];
  x3 = u.c[sizeof(int) - 1];
  printf("x0 = 0x%x x3 = 0x%x (%s)\n", x0, x3,
         x3 == 0x78 ? "bigendian" : "littleendian");
  x0 = (u.l >> 24) & 0xff;
  x1 = (u.l >> 16) & 0xff;
  x2 = (u.l >> 8) & 0xff;
  x3 = u.l & 0xff;
  printf("big endian x0:x3: %x %x %x %x\n", x0, x1, x2, x3);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x12345678,-0x8(%rbp)
movsbl -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x18(%rbp),%edi
lea    0xee7(%rip),%rcx
lea    0xed6(%rip),%rax
cmp    $0x78,%edi
cmove  %rax,%rcx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
lea    0xefb(%rip),%rcx
mov    $0x78,%esi
mov    $0x12,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
mov    $0x12,%esi
mov    $0x34,%edx
mov    $0x56,%ecx
mov    $0x78,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%union.anon = type { i32 }
@.str = [26 x i8] c"x0 = 0x%x x3 = 0x%x (%s)\0A\00"
@.str.1 = [10 x i8] c"bigendian\00"
@.str.2 = [13 x i8] c"littleendian\00"
@.str.3 = [31 x i8] c"big endian x0:x3: %x %x %x %x\0A\00"
define i32 @main() {
%1 = alloca %union.anon
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast %union.anon* %1 to i32*
store i32 305419896, i32* %6
%7 = bitcast %union.anon* %1 to [4 x i8]*
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
store i32 %10, i32* %2
%11 = bitcast %union.anon* %1 to [4 x i8]*
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
store i32 %14, i32* %5
%15 = load i32, i32* %2
%16 = load i32, i32* %5
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 120
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0)
%21 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i8* %20)
%22 = bitcast %union.anon* %1 to i32*
%23 = load i32, i32* %22
%24 = ashr i32 %23, 24
%25 = and i32 %24, 255
store i32 %25, i32* %2
%26 = bitcast %union.anon* %1 to i32*
%27 = load i32, i32* %26
%28 = ashr i32 %27, 16
%29 = and i32 %28, 255
store i32 %29, i32* %3
%30 = bitcast %union.anon* %1 to i32*
%31 = load i32, i32* %30
%32 = ashr i32 %31, 8
%33 = and i32 %32, 255
store i32 %33, i32* %4
%34 = bitcast %union.anon* %1 to i32*
%35 = load i32, i32* %34
%36 = and i32 %35, 255
store i32 %36, i32* %5
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"x0 = 0x%x x3 = 0x%x (%s)\0A\00"
@.str.2 = [13 x i8] c"littleendian\00"
@.str.3 = [31 x i8] c"big endian x0:x3: %x %x %x %x\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 120, i32 18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 18, i32 52, i32 86, i32 120)
ret i32 0
}