#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*/ shortvalue;
typedef int /*<<< orphan*/ longvalue;
typedef int /*<<< orphan*/ intvalue;
typedef int /*<<< orphan*/ floatvalue;
typedef int /*<<< orphan*/ doublevalue;
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int EXIT_SUCCESS;
int check_end();
int print_all_byte(void *, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  if (check_end() == 1) {
    printf("大端\n");
  } else {
    printf("小端\n");
  }
  short shortvalue = 0x1234;
  if (print_all_byte((void *)&shortvalue, sizeof(shortvalue)) != -1) {
    printf("print SHORT success!\n\n");
  }
  int intvalue = 0x12345678;
  if (print_all_byte((void *)&intvalue, sizeof(intvalue)) != -1) {
    printf("print INT success!\n\n");
  }
  long longvalue = 0x87654321;
  if (print_all_byte((void *)&longvalue, sizeof(longvalue)) != -1) {
    printf("print LONG success!\n\n");
  }
  float floatvalue = 0.12345678;
  if (print_all_byte((void *)&floatvalue, sizeof(floatvalue)) != -1) {
    printf("printf FLOAT success!\n\n");
  }
  double doublevalue = 0.12345678;
  if (print_all_byte((void *)&doublevalue, sizeof(doublevalue)) != -1) {
    printf("printf DOUBLE success!\n\n");
  }
  int array[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 1234};
  if (print_all_byte((void *)array, sizeof(array)) != -1) {
    printf("printf ARRAY success!\n\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <check_end@plt>
cmp    $0x1,%eax
jne    1170 <main+0x30>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
jmp    117c <main+0x3c>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
movw   $0x1234,-0x6(%rbp)
lea    -0x6(%rbp),%rdi
mov    $0x2,%esi
call   1060 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     11a5 <main+0x65>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
movl   $0x12345678,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
call   1060 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     11cf <main+0x8f>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x87654321,%eax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1060 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     11fb <main+0xbb>
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
movss  0xdfd(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x4,%esi
call   1060 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     122b <main+0xeb>
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
movsd  0xdd5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
call   1060 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     125b <main+0x11b>
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x50(%rbp),%rdi
mov    $0x28,%esi
call   1060 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     1293 <main+0x153>
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
xor    %eax,%eax
call   1030 <check_end@plt>
cmp    $0x1,%eax
lea    0xf6f(%rip),%rax
lea    0xedc(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
movw   $0x1234,0x6(%rsp)
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
call   1050 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     117c <main+0x4c>
lea    0xf27(%rip),%rdi
call   1040 <puts@plt>
movl   $0x12345678,0xc(%rsp)
12
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
call   1050 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     11a4 <main+0x74>
lea    0xeeb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x87654321,%eax
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%rdi
mov    $0x8,%esi
call   1050 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     11ce <main+0x9e>
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
movl   $0x3dfcd6e9,0x8(%rsp)
3d
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
call   1050 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     11f6 <main+0xc6>
lea    0xe6d(%rip),%rdi
call   1040 <puts@plt>
movabs $0x3fbf9add1091c895,%rax
9a bf 3f
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x8,%esi
call   1050 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     1225 <main+0xf5>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
mov    0xdf4(%rip),%rax
mov    %rax,0x40(%rsp)
movaps 0xdd8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xdbc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x28,%esi
call   1050 <print_all_byte@plt>
cmp    $0xffffffff,%eax
je     1269 <main+0x139>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\E5\A4\A7\E7\AB\AF\0A\00"
@.str.1 = [8 x i8] c"\E5\B0\8F\E7\AB\AF\0A\00"
@.str.2 = [23 x i8] c"print SHORT success!\0A\0A\00"
@.str.3 = [21 x i8] c"print INT success!\0A\0A\00"
@.str.4 = [22 x i8] c"print LONG success!\0A\0A\00"
@.str.5 = [24 x i8] c"printf FLOAT success!\0A\0A\00"
@.str.6 = [25 x i8] c"printf DOUBLE success!\0A\0A\00"
@__const.main.array = [10 x i32] [i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 1234]
@.str.7 = [24 x i8] c"printf ARRAY success!\0A\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i32
%4 = alloca i64
%5 = alloca float
%6 = alloca double
%7 = alloca [10 x i32]
store i32 0, i32* %1
%8 = call i32 (...) @check_end()
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
store i16 4660, i16* %2
%15 = bitcast i16* %2 to i8*
%16 = call i32 @print_all_byte(i8* %15, i32 2)
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
store i32 305419896, i32* %3
%21 = bitcast i32* %3 to i8*
%22 = call i32 @print_all_byte(i8* %21, i32 4)
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
store i64 2271560481, i64* %4
%27 = bitcast i64* %4 to i8*
%28 = call i32 @print_all_byte(i8* %27, i32 8)
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
store float 0x3FBF9ADD20000000, float* %5
%33 = bitcast float* %5 to i8*
%34 = call i32 @print_all_byte(i8* %33, i32 4)
%35 = icmp ne i32 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
store double 0x3FBF9ADD1091C895, double* %6
%39 = bitcast double* %6 to i8*
%40 = call i32 @print_all_byte(i8* %39, i32 8)
%41 = icmp ne i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %44
44: ; preds = %42, %38
%45 = bitcast [10 x i32]* %7 to i8*
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%47 = bitcast i32* %46 to i8*
%48 = call i32 @print_all_byte(i8* %47, i32 40)
%49 = icmp ne i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %52
52: ; preds = %50, %44
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}

LLVM IR (-O2):
@__const.main.array = [10 x i32] [i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 1234]
@EXIT_SUCCESS = global i32 0
@str = [7 x i8] c"\E5\B0\8F\E7\AB\AF\00"
@str.8 = [23 x i8] c"printf ARRAY success!\0A\00"
@str.9 = [24 x i8] c"printf DOUBLE success!\0A\00"
@str.10 = [23 x i8] c"printf FLOAT success!\0A\00"
@str.11 = [21 x i8] c"print LONG success!\0A\00"
@str.12 = [20 x i8] c"print INT success!\0A\00"
@str.13 = [22 x i8] c"print SHORT success!\0A\00"
@str.14 = [7 x i8] c"\E5\A4\A7\E7\AB\AF\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i32
%3 = alloca i64
%4 = alloca float
%5 = alloca double
%6 = alloca [10 x i32]
%7 = tail call i32 (...) @check_end()
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
%11 = bitcast i16* %1 to i8*
store i16 4660, i16* %1
%12 = call i32 @print_all_byte(i8* %11, i32 2)
%13 = icmp eq i32 %12, -1
br i1 %13, label %16, label %14
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = bitcast i32* %2 to i8*
store i32 305419896, i32* %2
%18 = call i32 @print_all_byte(i8* %17, i32 4)
%19 = icmp eq i32 %18, -1
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = bitcast i64* %3 to i8*
store i64 2271560481, i64* %3
%24 = call i32 @print_all_byte(i8* %23, i32 8)
%25 = icmp eq i32 %24, -1
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = bitcast float* %4 to i8*
store float 0x3FBF9ADD20000000, float* %4
%30 = call i32 @print_all_byte(i8* %29, i32 4)
%31 = icmp eq i32 %30, -1
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = bitcast double* %5 to i8*
store double 0x3FBF9ADD1091C895, double* %5
%36 = call i32 @print_all_byte(i8* %35, i32 8)
%37 = icmp eq i32 %36, -1
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = bitcast [10 x i32]* %6 to i8*
%42 = call i32 @print_all_byte(i8* %41, i32 40)
%43 = icmp eq i32 %42, -1
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}