int endian(void) {
  long long foo = 0x0102030405060708LL;
  unsigned char *c, c1, c2, c3, c4, c5, c6, c7, c8;
  c = (char *)&foo;
  c1 = *c++;
  c2 = *c++;
  c3 = *c++;
  c4 = *c++;
  c5 = *c++;
  c6 = *c++;
  c7 = *c++;
  c8 = *c;
  if ((c1 == 0x08) && (c2 = 0x07) && (c3 == 0x06) && (c4 == 0x05) &&
      (c5 == 0x04) && (c6 == 0x03) && (c7 == 0x02) && (c8 == 0x01))
    return (1);
  if ((c1 == 0x01) && (c2 = 0x02) && (c3 == 0x03) && (c4 == 0x04) &&
      (c5 == 0x05) && (c6 == 0x06) && (c7 == 0x07) && (c8 == 0x08))
    return (2);
  if ((c1 == 0x04) && (c2 = 0x03) && (c3 == 0x02) && (c4 == 0x01) &&
      (c5 == 0x08) && (c6 == 0x07) && (c7 == 0x06) && (c8 == 0x05))
    return (3);
  return (-1);
}


x86 assembly (clang, -O0):
<endian>:
push   %rbp
mov    %rsp,%rbp
movabs $0x102030405060708,%rax
03 02 01
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1b(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1d(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1e(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1f(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x20(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x8,%eax
jne    1229 <endian+0x129>
movb   $0x7,-0x1a(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    11cf <endian+0xcf>
jmp    1229 <endian+0x129>
movzbl -0x1b(%rbp),%eax
cmp    $0x6,%eax
jne    1229 <endian+0x129>
movzbl -0x1c(%rbp),%eax
cmp    $0x5,%eax
jne    1229 <endian+0x129>
movzbl -0x1d(%rbp),%eax
cmp    $0x4,%eax
jne    1229 <endian+0x129>
movzbl -0x1e(%rbp),%eax
cmp    $0x3,%eax
jne    1229 <endian+0x129>
movzbl -0x1f(%rbp),%eax
cmp    $0x2,%eax
jne    1229 <endian+0x129>
movzbl -0x20(%rbp),%eax
cmp    $0x1,%eax
jne    1229 <endian+0x129>
movl   $0x1,-0x4(%rbp)
jmp    1324 <endian+0x224>
movzbl -0x19(%rbp),%eax
cmp    $0x1,%eax
jne    12a3 <endian+0x1a3>
movb   $0x2,-0x1a(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1249 <endian+0x149>
jmp    12a3 <endian+0x1a3>
movzbl -0x1b(%rbp),%eax
cmp    $0x3,%eax
jne    12a3 <endian+0x1a3>
movzbl -0x1c(%rbp),%eax
cmp    $0x4,%eax
jne    12a3 <endian+0x1a3>
movzbl -0x1d(%rbp),%eax
cmp    $0x5,%eax
jne    12a3 <endian+0x1a3>
movzbl -0x1e(%rbp),%eax
cmp    $0x6,%eax
jne    12a3 <endian+0x1a3>
movzbl -0x1f(%rbp),%eax
cmp    $0x7,%eax
jne    12a3 <endian+0x1a3>
movzbl -0x20(%rbp),%eax
cmp    $0x8,%eax
jne    12a3 <endian+0x1a3>
movl   $0x2,-0x4(%rbp)
jmp    1324 <endian+0x224>
movzbl -0x19(%rbp),%eax
cmp    $0x4,%eax
jne    131d <endian+0x21d>
movb   $0x3,-0x1a(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    12c3 <endian+0x1c3>
jmp    131d <endian+0x21d>
movzbl -0x1b(%rbp),%eax
cmp    $0x2,%eax
jne    131d <endian+0x21d>
movzbl -0x1c(%rbp),%eax
cmp    $0x1,%eax
jne    131d <endian+0x21d>
movzbl -0x1d(%rbp),%eax
cmp    $0x8,%eax
jne    131d <endian+0x21d>
movzbl -0x1e(%rbp),%eax
cmp    $0x7,%eax
jne    131d <endian+0x21d>
movzbl -0x1f(%rbp),%eax
cmp    $0x6,%eax
jne    131d <endian+0x21d>
movzbl -0x20(%rbp),%eax
cmp    $0x5,%eax
jne    131d <endian+0x21d>
movl   $0x3,-0x4(%rbp)
jmp    1324 <endian+0x224>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<endian>:
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @endian() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
store i64 72623859790382856, i64* %2
%12 = bitcast i64* %2 to i8*
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
%15 = load i8, i8* %13
store i8 %15, i8* %4
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
%18 = load i8, i8* %16
store i8 %18, i8* %5
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
%21 = load i8, i8* %19
store i8 %21, i8* %6
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
%24 = load i8, i8* %22
store i8 %24, i8* %7
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
%27 = load i8, i8* %25
store i8 %27, i8* %8
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %3
%30 = load i8, i8* %28
store i8 %30, i8* %9
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
%33 = load i8, i8* %31
store i8 %33, i8* %10
%34 = load i8*, i8** %3
%35 = load i8, i8* %34
store i8 %35, i8* %11
%36 = load i8, i8* %4
%37 = zext i8 %36 to i32
%38 = icmp eq i32 %37, 8
br i1 %38, label %39, label %65
39: ; preds = %0
store i8 7, i8* %5
br i1 true, label %40, label %65
40: ; preds = %39
%41 = load i8, i8* %6
%42 = zext i8 %41 to i32
%43 = icmp eq i32 %42, 6
br i1 %43, label %44, label %65
44: ; preds = %40
%45 = load i8, i8* %7
%46 = zext i8 %45 to i32
%47 = icmp eq i32 %46, 5
br i1 %47, label %48, label %65
48: ; preds = %44
%49 = load i8, i8* %8
%50 = zext i8 %49 to i32
%51 = icmp eq i32 %50, 4
br i1 %51, label %52, label %65
52: ; preds = %48
%53 = load i8, i8* %9
%54 = zext i8 %53 to i32
%55 = icmp eq i32 %54, 3
br i1 %55, label %56, label %65
56: ; preds = %52
%57 = load i8, i8* %10
%58 = zext i8 %57 to i32
%59 = icmp eq i32 %58, 2
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = load i8, i8* %11
%62 = zext i8 %61 to i32
%63 = icmp eq i32 %62, 1
br i1 %63, label %64, label %65
64: ; preds = %60
store i32 1, i32* %1
br label %126
65: ; preds = %60, %56, %52, %48, %44, %40, %39, %0
%66 = load i8, i8* %4
%67 = zext i8 %66 to i32
%68 = icmp eq i32 %67, 1
br i1 %68, label %69, label %95
69: ; preds = %65
store i8 2, i8* %5
br i1 true, label %70, label %95
70: ; preds = %69
%71 = load i8, i8* %6
%72 = zext i8 %71 to i32
%73 = icmp eq i32 %72, 3
br i1 %73, label %74, label %95
74: ; preds = %70
%75 = load i8, i8* %7
%76 = zext i8 %75 to i32
%77 = icmp eq i32 %76, 4
br i1 %77, label %78, label %95
78: ; preds = %74
%79 = load i8, i8* %8
%80 = zext i8 %79 to i32
%81 = icmp eq i32 %80, 5
br i1 %81, label %82, label %95
82: ; preds = %78
%83 = load i8, i8* %9
%84 = zext i8 %83 to i32
%85 = icmp eq i32 %84, 6
br i1 %85, label %86, label %95
86: ; preds = %82
%87 = load i8, i8* %10
%88 = zext i8 %87 to i32
%89 = icmp eq i32 %88, 7
br i1 %89, label %90, label %95
90: ; preds = %86
%91 = load i8, i8* %11
%92 = zext i8 %91 to i32
%93 = icmp eq i32 %92, 8
br i1 %93, label %94, label %95
94: ; preds = %90
store i32 2, i32* %1
br label %126
95: ; preds = %90, %86, %82, %78, %74, %70, %69, %65
%96 = load i8, i8* %4
%97 = zext i8 %96 to i32
%98 = icmp eq i32 %97, 4
br i1 %98, label %99, label %125
99: ; preds = %95
store i8 3, i8* %5
br i1 true, label %100, label %125
100: ; preds = %99
%101 = load i8, i8* %6
%102 = zext i8 %101 to i32
%103 = icmp eq i32 %102, 2
br i1 %103, label %104, label %125
104: ; preds = %100
%105 = load i8, i8* %7
%106 = zext i8 %105 to i32
%107 = icmp eq i32 %106, 1
br i1 %107, label %108, label %125
108: ; preds = %104
%109 = load i8, i8* %8
%110 = zext i8 %109 to i32
%111 = icmp eq i32 %110, 8
br i1 %111, label %112, label %125
112: ; preds = %108
%113 = load i8, i8* %9
%114 = zext i8 %113 to i32
%115 = icmp eq i32 %114, 7
br i1 %115, label %116, label %125
116: ; preds = %112
%117 = load i8, i8* %10
%118 = zext i8 %117 to i32
%119 = icmp eq i32 %118, 6
br i1 %119, label %120, label %125
120: ; preds = %116
%121 = load i8, i8* %11
%122 = zext i8 %121 to i32
%123 = icmp eq i32 %122, 5
br i1 %123, label %124, label %125
124: ; preds = %120
store i32 3, i32* %1
br label %126
125: ; preds = %120, %116, %112, %108, %104, %100, %99, %95
store i32 -1, i32* %1
br label %126
126: ; preds = %125, %124, %94, %64
%127 = load i32, i32* %1
ret i32 %127
}

LLVM IR (-O2):
define i32 @endian() {
ret i32 1
}