#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 int /*<<< orphan*/ i;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ show_mem_rep(char *, int);
int main() {
  unsigned int i = 1025;
  char *c = (char *)&i;
  if (*c)
    printf("Little endian\n");
  else
    printf("Big endian\n");
  show_mem_rep((char *)&i, sizeof(i));
  int p = 256;
  printf("p=%d\n", p);
  ((((p) >> 24) & 0x000000FF) | (((p) >> 8) & 0x0000FF00) |
   (((p) << 8) & 0x00FF0000) | (((p) << 24) & 0xFF000000));
  printf("p=%d\n", p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x401,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     115e <main+0x3e>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116c <main+0x4c>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1040 <show_mem_rep@plt>
movl   $0x100,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x401,0xc(%rsp)
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
call   1050 <show_mem_rep@plt>
lea    0xea1(%rip),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Little endian\0A\00"
@.str.1 = [12 x i8] c"Big endian\0A\00"
@.str.2 = [6 x i8] c"p=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
store i32 1025, i32* %2
%5 = bitcast i32* %2 to i8*
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = bitcast i32* %2 to i8*
%15 = call i32 @show_mem_rep(i8* %14, i32 4)
store i32 256, i32* %4
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %4
%19 = ashr i32 %18, 24
%20 = and i32 %19, 255
%21 = load i32, i32* %4
%22 = ashr i32 %21, 8
%23 = and i32 %22, 65280
%24 = or i32 %20, %23
%25 = load i32, i32* %4
%26 = shl i32 %25, 8
%27 = and i32 %26, 16711680
%28 = or i32 %24, %27
%29 = load i32, i32* %4
%30 = shl i32 %29, 24
%31 = and i32 %30, -16777216
%32 = or i32 %28, %31
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"p=%d\0A\00"
@str.3 = [14 x i8] c"Little endian\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1025, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
%4 = call i32 @show_mem_rep(i8* %2, i32 4)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 256)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 256)
ret i32 0
}