#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*/ memset(unsigned char *, int /*<<< orphan*/, int);
char *short_endianness(void) {
  unsigned char arr[sizeof(short)];
  if (sizeof(short) == 1) {
    return NULL;
  }
  memset(arr, 0, sizeof arr);
  arr[0] = 1;
  if (*((short *)arr) == 1) {
    return "little-endian";
  }
  memset(arr, 0, sizeof arr);
  arr[sizeof arr - 1] = 1;
  if (*((short *)arr) == 1) {
    return "big-endian";
  }
  return NULL;
}


x86 assembly (clang, -O0):
<short_endianness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xa(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <memset@plt>
movb   $0x1,-0xa(%rbp)
movswl -0xa(%rbp),%eax
cmp    $0x1,%eax
jne    1149 <short_endianness+0x39>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1182 <short_endianness+0x72>
lea    -0xa(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <memset@plt>
movb   $0x1,-0x9(%rbp)
movswl -0xa(%rbp),%eax
cmp    $0x1,%eax
jne    117a <short_endianness+0x6a>
lea    0xe9d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1182 <short_endianness+0x72>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<short_endianness>:
push   %rbx
sub    $0x10,%rsp
lea    0xe(%rsp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <memset@plt>
movb   $0x1,0xe(%rsp)
cmpw   $0x1,0xe(%rsp)
jne    113c <short_endianness+0x2c>
lea    0xec6(%rip),%rbx
jmp    1165 <short_endianness+0x55>
lea    0xe(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <memset@plt>
movb   $0x1,0xf(%rsp)
cmpw   $0x1,0xe(%rsp)
lea    0xead(%rip),%rax
cmove  %rax,%rbx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"little-endian\00"
@.str.1 = [11 x i8] c"big-endian\00"
define i8* @short_endianness() {
%1 = alloca i8*
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 2)
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
store i8 1, i8* %5
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%7 = bitcast i8* %6 to i16*
%8 = load i16, i16* %7
%9 = sext i16 %8 to i32
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %1
br label %23
12: ; preds = %0
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 2)
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 1, i8* %15
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%17 = bitcast i8* %16 to i16*
%18 = load i16, i16* %17
%19 = sext i16 %18 to i32
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %12
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %23
22: ; preds = %12
store i8* null, i8** %1
br label %23
23: ; preds = %22, %21, %11
%24 = load i8*, i8** %1
ret i8* %24
}

LLVM IR (-O2):
@.str = [14 x i8] c"little-endian\00"
@.str.1 = [11 x i8] c"big-endian\00"
define i8* @short_endianness() {
%1 = alloca i16
%2 = bitcast i16* %1 to i8*
%3 = call i32 @memset(i8* %2, i32 0, i32 2)
store i8 1, i8* %2
%4 = load i16, i16* %1
%5 = icmp eq i16 %4, 1
br i1 %5, label %13, label %6
6: ; preds = %0
%7 = bitcast i16* %1 to [2 x i8]*
%8 = call i32 @memset(i8* %2, i32 0, i32 2)
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 1
store i8 1, i8* %9
%10 = load i16, i16* %1
%11 = icmp eq i16 %10, 1
%12 = select i1 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* null
br label %13
13: ; preds = %6, %0
%14 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %0 ], [ %12, %6 ]
ret i8* %14
}