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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x1,-0x8(%rbp)
movsbl -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x18(%rbp),%edi
lea    0xee2(%rip),%rcx
lea    0xed1(%rip),%rax
cmp    $0x1,%edi
cmove  %rax,%rcx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
sar    $0x18,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
sar    $0x10,%rax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
sar    $0x8,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe91(%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    0xef7(%rip),%rcx
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%union.anon = type { i64 }
@.str = [22 x i8] c"x0 = %d x3 = %d (%s)\0A\00"
@.str.1 = [10 x i8] c"bigendian\00"
@.str.2 = [13 x i8] c"littleendian\00"
@.str.3 = [20 x i8] c"x0:x3: %d %d %d %d\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 i64*
store i64 1, i64* %6
%7 = bitcast %union.anon* %1 to [8 x i8]*
%8 = getelementptr inbounds [8 x i8], [8 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 [8 x i8]*
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 7
%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, 1
%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 ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i8* %20)
%22 = bitcast %union.anon* %1 to i64*
%23 = load i64, i64* %22
%24 = ashr i64 %23, 24
%25 = trunc i64 %24 to i32
store i32 %25, i32* %2
%26 = bitcast %union.anon* %1 to i64*
%27 = load i64, i64* %26
%28 = ashr i64 %27, 16
%29 = trunc i64 %28 to i32
store i32 %29, i32* %3
%30 = bitcast %union.anon* %1 to i64*
%31 = load i64, i64* %30
%32 = ashr i64 %31, 8
%33 = trunc i64 %32 to i32
store i32 %33, i32* %4
%34 = bitcast %union.anon* %1 to i64*
%35 = load i64, i64* %34
%36 = and i64 %35, 255
%37 = trunc i64 %36 to i32
store i32 %37, i32* %5
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %39, i32 %40, i32 %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"x0 = %d x3 = %d (%s)\0A\00"
@.str.2 = [13 x i8] c"littleendian\00"
@.str.3 = [20 x i8] c"x0:x3: %d %d %d %d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1, i32 0, 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 ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 0, i32 1)
ret i32 0
}