#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*/ y;
typedef int /*<<< orphan*/ x;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int EXIT_SUCCESS;
int check_end();
int /*<<< orphan*/ print_bit(void *, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  if (check_end() == 1) {
    printf("大端模式\n");
  } else {
    printf("小端模式\n");
  }
  int a = 1;
  print_bit((void *)&a, sizeof(a));
  int b = -1;
  print_bit((void *)&b, sizeof(b));
  int x = 0x2B;
  print_bit((void *)&x, sizeof(x));
  int y = -0x2B;
  print_bit((void *)&y, sizeof(y));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <check_end@plt>
cmp    $0x1,%eax
jne    1160 <main+0x30>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
jmp    116c <main+0x3c>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
movl   $0xffffffff,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
movl   $0x2b,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
movl   $0xffffffd5,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1030 <check_end@plt>
cmp    $0x1,%eax
lea    0xec8(%rip),%rax
lea    0xeb4(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
movl   $0x1,0x14(%rsp)
lea    0x14(%rsp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
movl   $0xffffffff,0x10(%rsp)
ff
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
movl   $0x2b,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
movl   $0xffffffd5,0x8(%rsp)
ff
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
call   1050 <print_bit@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\E5\A4\A7\E7\AB\AF\E6\A8\A1\E5\BC\8F\0A\00"
@.str.1 = [14 x i8] c"\E5\B0\8F\E7\AB\AF\E6\A8\A1\E5\BC\8F\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @check_end()
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
store i32 1, i32* %2
%13 = bitcast i32* %2 to i8*
%14 = call i32 @print_bit(i8* %13, i32 4)
store i32 -1, i32* %3
%15 = bitcast i32* %3 to i8*
%16 = call i32 @print_bit(i8* %15, i32 4)
store i32 43, i32* %4
%17 = bitcast i32* %4 to i8*
%18 = call i32 @print_bit(i8* %17, i32 4)
store i32 -43, i32* %5
%19 = bitcast i32* %5 to i8*
%20 = call i32 @print_bit(i8* %19, i32 4)
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [13 x i8] c"\E5\B0\8F\E7\AB\AF\E6\A8\A1\E5\BC\8F\00"
@str.2 = [13 x i8] c"\E5\A4\A7\E7\AB\AF\E6\A8\A1\E5\BC\8F\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = tail call i32 (...) @check_end()
%6 = icmp eq i32 %5, 1
%7 = select i1 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
%9 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%10 = call i32 @print_bit(i8* %9, i32 4)
%11 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%12 = call i32 @print_bit(i8* %11, i32 4)
%13 = bitcast i32* %3 to i8*
store i32 43, i32* %3
%14 = call i32 @print_bit(i8* %13, i32 4)
%15 = bitcast i32* %4 to i8*
store i32 -43, i32* %4
%16 = call i32 @print_bit(i8* %15, i32 4)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}