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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int wchars_size(wchar_t c) {
  if (c > 55295 && c < 57344)
    exit(-1);
  if (c < 128)
    return (1);
  else if (c < 2048)
    return (2);
  else if (c < 65536)
    return (3);
  else if (c < 1114112)
    return (4);
  else
    exit(-1);
  return (0);
}


x86 assembly (clang, -O0):
<wchars_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0xd7ff,-0x8(%rbp)
jle    113f <wchars_size+0x2f>
cmpl   $0xe000,-0x8(%rbp)
jge    113f <wchars_size+0x2f>
mov    $0xffffffff,%edi
call   1030 <exit@plt>
cmpl   $0x80,-0x8(%rbp)
jge    1158 <wchars_size+0x48>
movl   $0x1,-0x4(%rbp)
jmp    11ad <wchars_size+0x9d>
cmpl   $0x800,-0x8(%rbp)
jge    1171 <wchars_size+0x61>
movl   $0x2,-0x4(%rbp)
jmp    11ad <wchars_size+0x9d>
cmpl   $0x10000,-0x8(%rbp)
jge    118a <wchars_size+0x7a>
movl   $0x3,-0x4(%rbp)
jmp    11ad <wchars_size+0x9d>
cmpl   $0x110000,-0x8(%rbp)
jge    11a3 <wchars_size+0x93>
movl   $0x4,-0x4(%rbp)
jmp    11ad <wchars_size+0x9d>
mov    $0xffffffff,%edi
call   1030 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wchars_size>:
push   %rax
mov    %edi,%eax
and    $0xfffff800,%eax
cmp    $0xd800,%eax
je     1155 <wchars_size+0x45>
mov    $0x1,%eax
cmp    $0x80,%edi
jl     1153 <wchars_size+0x43>
mov    $0x2,%eax
cmp    $0x800,%edi
jb     1153 <wchars_size+0x43>
mov    $0x3,%eax
cmp    $0x10000,%edi
jb     1153 <wchars_size+0x43>
mov    $0x4,%eax
cmp    $0x110000,%edi
jae    1155 <wchars_size+0x45>
pop    %rcx
ret
mov    $0xffffffff,%edi
call   1030 <exit@plt>

LLVM IR (-O0):
define i32 @wchars_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 55295
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 57344
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %6, %1
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 128
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %2
br label %29
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 2048
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 2, i32* %2
br label %29
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 65536
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 3, i32* %2
br label %29
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 1114112
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 4, i32* %2
br label %29
27: ; preds = %23
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %26, %22, %18, %14
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @wchars_size(i32 %0) {
%2 = and i32 %0, -2048
%3 = icmp eq i32 %2, 55296
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @exit(i32 -1)
unreachable
6: ; preds = %1
%7 = icmp slt i32 %0, 128
br i1 %7, label %16, label %8
8: ; preds = %6
%9 = icmp ult i32 %0, 2048
br i1 %9, label %16, label %10
10: ; preds = %8
%11 = icmp ult i32 %0, 65536
br i1 %11, label %16, label %12
12: ; preds = %10
%13 = icmp ult i32 %0, 1114112
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %12, %10, %8, %6
%17 = phi i32 [ 1, %6 ], [ 2, %8 ], [ 3, %10 ], [ 4, %12 ]
ret i32 %17
}