#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 uint16_t;

/* Variables and functions */
bool unicode_determine_endianess_utf16(uint16_t value, bool *reverse) {
  if (value == 0xFEFF) {
    if (reverse)
      *reverse = false;
    return true;
  } else if (value == 0xFFFE) {
    if (reverse)
      *reverse = true;
    return true;
  } else {
    if (reverse)
      *reverse = false;
    return false;
  }
}


x86 assembly (clang, -O0):
<unicode_determine_endianess_utf16>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0xfeff,-0x8(%rbp)
jne    1139 <unicode_determine_endianess_utf16+0x39>
cmpq   $0x0,-0x10(%rbp)
je     112d <unicode_determine_endianess_utf16+0x2d>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1183 <unicode_determine_endianess_utf16+0x83>
cmpl   $0xfffe,-0x8(%rbp)
jne    1167 <unicode_determine_endianess_utf16+0x67>
cmpq   $0x0,-0x10(%rbp)
je     115b <unicode_determine_endianess_utf16+0x5b>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1183 <unicode_determine_endianess_utf16+0x83>
cmpq   $0x0,-0x10(%rbp)
je     117c <unicode_determine_endianess_utf16+0x7c>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<unicode_determine_endianess_utf16>:
cmp    $0xfffe,%edi
je     111e <unicode_determine_endianess_utf16+0x1e>
xor    %ecx,%ecx
cmp    $0xfeff,%edi
je     1123 <unicode_determine_endianess_utf16+0x23>
mov    $0x0,%eax
test   %rsi,%rsi
jne    112d <unicode_determine_endianess_utf16+0x2d>
jmp    112f <unicode_determine_endianess_utf16+0x2f>
mov    $0x1,%ecx
mov    $0x1,%eax
test   %rsi,%rsi
je     112f <unicode_determine_endianess_utf16+0x2f>
mov    %ecx,(%rsi)
ret

LLVM IR (-O0):
define i32 @unicode_determine_endianess_utf16(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 65279
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load i32*, i32** %5
store i32 0, i32* %12
br label %13
13: ; preds = %11, %8
store i32 1, i32* %3
br label %29
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 65534
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32*, i32** %5
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32*, i32** %5
store i32 1, i32* %21
br label %22
22: ; preds = %20, %17
store i32 1, i32* %3
br label %29
23: ; preds = %14
%24 = load i32*, i32** %5
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32*, i32** %5
store i32 0, i32* %27
br label %28
28: ; preds = %26, %23
store i32 0, i32* %3
br label %29
29: ; preds = %28, %22, %13
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @unicode_determine_endianess_utf16(i32 %0, i32* writeonly %1) {
switch i32 %0, label %7 [
i32 65279, label %3
i32 65534, label %5
]
3: ; preds = %2
%4 = icmp eq i32* %1, null
br i1 %4, label %12, label %9
5: ; preds = %2
%6 = icmp eq i32* %1, null
br i1 %6, label %12, label %9
7: ; preds = %2
%8 = icmp eq i32* %1, null
br i1 %8, label %12, label %9
9: ; preds = %7, %5, %3
%10 = phi i32 [ 0, %3 ], [ 1, %5 ], [ 0, %7 ]
%11 = phi i32 [ 1, %3 ], [ 1, %5 ], [ 0, %7 ]
store i32 %10, i32* %1
br label %12
12: ; preds = %9, %7, %5, %3
%13 = phi i32 [ 1, %3 ], [ 1, %5 ], [ 0, %7 ], [ %11, %9 ]
ret i32 %13
}