#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 */
scalar_t__ little_endian();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ test_little_endian();
int main() {
  if (!test_little_endian()) {
    printf("Little endian test failed!\n");
    return 1;
  }
  printf("This computer is ");
  if (little_endian()) {
    printf("little-endian.\n");
  } else {
    printf("big-endian.\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <test_little_endian@plt>
cmp    $0x0,%eax
jne    1167 <main+0x37>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a1 <main+0x71>
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <little_endian@plt>
cmp    $0x0,%rax
je     1195 <main+0x65>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
jmp    11a1 <main+0x71>
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <test_little_endian@plt>
test   %eax,%eax
je     1178 <main+0x38>
lea    0xeab(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <little_endian@plt>
test   %rax,%rax
lea    0xec2(%rip),%rax
lea    0xec7(%rip),%rdi
cmove  %rax,%rdi
jmp    1184 <main+0x44>
mov    $0x1,%ebx
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Little endian test failed!\0A\00"
@.str.1 = [18 x i8] c"This computer is \00"
@.str.2 = [16 x i8] c"little-endian.\0A\00"
@.str.3 = [13 x i8] c"big-endian.\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @test_little_endian()
%3 = icmp ne i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %14
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = call i64 (...) @little_endian()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %14
12: ; preds = %6
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %4, %12, %10
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"This computer is \00"
@str = [27 x i8] c"Little endian test failed!\00"
@str.4 = [12 x i8] c"big-endian.\00"
@str.5 = [15 x i8] c"little-endian.\00"
define i32 @main() {
%1 = tail call i32 (...) @test_little_endian()
%2 = icmp eq i32 %1, 0
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i64 (...) @little_endian()
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0)
br label %8
8: ; preds = %3, %0
%9 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), %0 ], [ %7, %3 ]
%10 = phi i32 [ 1, %0 ], [ 0, %3 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %10
}