main(argc, argv) int argc;
char **argv;
{
  int num = 0x41424344;
  if (((((char *)&num)[0]) == 0x41) && ((((char *)&num)[1]) == 0x42) &&
      ((((char *)&num)[2]) == 0x43) && ((((char *)&num)[3]) == 0x44)) {
    printf("BIG ENDIAN\n");
  } else if (((((char *)&num)[3]) == 0x41) && ((((char *)&num)[2]) == 0x42) &&
             ((((char *)&num)[1]) == 0x43) && ((((char *)&num)[0]) == 0x44)) {
    printf("LITTLE ENDIAN\n");
  } else {
    printf("Odd Endian -- are you running on a PDP-11?\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x41424344,-0x14(%rbp)
movsbl -0x14(%rbp),%eax
cmp    $0x41,%eax
jne    1174 <main+0x64>
movsbl -0x13(%rbp),%eax
cmp    $0x42,%eax
jne    1174 <main+0x64>
movsbl -0x12(%rbp),%eax
cmp    $0x43,%eax
jne    1174 <main+0x64>
movsbl -0x11(%rbp),%eax
cmp    $0x44,%eax
jne    1174 <main+0x64>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <main+0xbe>
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
jne    11bb <main+0xab>
movsbl -0x12(%rbp),%eax
cmp    $0x42,%eax
jne    11bb <main+0xab>
movsbl -0x13(%rbp),%eax
cmp    $0x43,%eax
jne    11bb <main+0xab>
movsbl -0x14(%rbp),%eax
cmp    $0x44,%eax
jne    11bb <main+0xab>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <main+0xb9>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <main+0xbe>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [12 x i8] c"BIG ENDIAN\0A\00"
@.str.1 = [15 x i8] c"LITTLE ENDIAN\0A\00"
@.str.2 = [44 x i8] c"Odd Endian -- are you running on a PDP-11?\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1094861636, i32* %6
%7 = bitcast i32* %6 to i8*
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 65
br i1 %11, label %12, label %32
12: ; preds = %2
%13 = bitcast i32* %6 to i8*
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 66
br i1 %17, label %18, label %32
18: ; preds = %12
%19 = bitcast i32* %6 to i8*
%20 = getelementptr inbounds i8, i8* %19, i64 2
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 67
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = bitcast i32* %6 to i8*
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 68
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %61
32: ; preds = %24, %18, %12, %2
%33 = bitcast i32* %6 to i8*
%34 = getelementptr inbounds i8, i8* %33, i64 3
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 65
br i1 %37, label %38, label %58
38: ; preds = %32
%39 = bitcast i32* %6 to i8*
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 66
br i1 %43, label %44, label %58
44: ; preds = %38
%45 = bitcast i32* %6 to i8*
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 67
br i1 %49, label %50, label %58
50: ; preds = %44
%51 = bitcast i32* %6 to i8*
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 68
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %60
58: ; preds = %50, %44, %38, %32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
br label %61
61: ; preds = %60, %30
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@str = [14 x i8] c"LITTLE ENDIAN\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}