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


x86 assembly (clang, -O0):
<size_t_endianness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
movb   $0x1,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jne    1147 <size_t_endianness+0x37>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117e <size_t_endianness+0x6e>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
movb   $0x1,-0x9(%rbp)
cmpq   $0x1,-0x10(%rbp)
jne    1176 <size_t_endianness+0x66>
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117e <size_t_endianness+0x6e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<size_t_endianness>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
movb   $0x1,0x8(%rsp)
cmpq   $0x1,0x8(%rsp)
jne    113c <size_t_endianness+0x2c>
lea    0xec6(%rip),%rbx
jmp    1165 <size_t_endianness+0x55>
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
movb   $0x1,0xf(%rsp)
cmpq   $0x1,0x8(%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* @size_t_endianness() {
%1 = alloca i8*
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 8)
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
store i8 1, i8* %5
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%7 = bitcast i8* %6 to i64*
%8 = load i64, i64* %7
%9 = icmp eq i64 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %1
br label %21
11: ; preds = %0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 8)
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 7
store i8 1, i8* %14
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%16 = bitcast i8* %15 to i64*
%17 = load i64, i64* %16
%18 = icmp eq i64 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %11
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %21
20: ; preds = %11
store i8* null, i8** %1
br label %21
21: ; preds = %20, %19, %10
%22 = load i8*, i8** %1
ret i8* %22
}

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