#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 unsigned char uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, unsigned char, unsigned char);
int main(int argc, char *argv[]) {
  uint32_t d = 0x01234567;
  unsigned char *p = (unsigned char *)&d;
  uint32_t e = (p[3] & 0xff);
  e += (p[2] & 0xff) << 8;
  e += (p[1] & 0xff) << 16;
  e += (p[0] & 0xff) << 24;
  printf("%s_ENDIAN: 0x%08x -> 0x%08x\n",
         ((e ^ d) == 0x66666666) ? "LIL" : "BIG", d, e);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x67,-0x11(%rbp)
lea    -0x11(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xff,%eax
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
movzbl -0x21(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
movzbl -0x21(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%ecx
and    $0xff,%ecx
shl    $0x18,%ecx
movzbl -0x21(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x21(%rbp)
movzbl -0x21(%rbp),%ecx
movzbl -0x11(%rbp),%eax
xor    %eax,%ecx
lea    0xe81(%rip),%rsi
lea    0xe76(%rip),%rax
cmp    $0x66666666,%ecx
cmove  %rax,%rsi
mov    -0x11(%rbp),%al
lea    0xe45(%rip),%rdi
movzbl %al,%edx
movzbl -0x21(%rbp),%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x67,%edx
xor    %ecx,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"%s_ENDIAN: 0x%08x -> 0x%08x\0A\00"
@.str.1 = [4 x i8] c"LIL\00"
@.str.2 = [4 x i8] c"BIG\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 103, i8* %6
store i8* %6, i8** %7
%9 = load i8*, i8** %7
%10 = getelementptr inbounds i8, i8* %9, i64 3
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i8
store i8 %14, i8* %8
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = and i32 %18, 255
%20 = shl i32 %19, 8
%21 = load i8, i8* %8
%22 = zext i8 %21 to i32
%23 = add nsw i32 %22, %20
%24 = trunc i32 %23 to i8
store i8 %24, i8* %8
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = and i32 %28, 255
%30 = shl i32 %29, 16
%31 = load i8, i8* %8
%32 = zext i8 %31 to i32
%33 = add nsw i32 %32, %30
%34 = trunc i32 %33 to i8
store i8 %34, i8* %8
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = and i32 %38, 255
%40 = shl i32 %39, 24
%41 = load i8, i8* %8
%42 = zext i8 %41 to i32
%43 = add nsw i32 %42, %40
%44 = trunc i32 %43 to i8
store i8 %44, i8* %8
%45 = load i8, i8* %8
%46 = zext i8 %45 to i32
%47 = load i8, i8* %6
%48 = zext i8 %47 to i32
%49 = xor i32 %46, %48
%50 = icmp eq i32 %49, 1717986918
%51 = zext i1 %50 to i64
%52 = select i1 %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%53 = load i8, i8* %6
%54 = load i8, i8* %8
%55 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %52, i8 zeroext %53, i8 zeroext %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"%s_ENDIAN: 0x%08x -> 0x%08x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* poison, i8 zeroext 103, i8 zeroext poison)
ret i32 0
}