#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 */
char windows1252_char(uint16_t chr) {
  static const uint16_t w1252chrs[] = {
      0x20ac, 0,      0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
      0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0,      0x017d, 0,
      0,      0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
      0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0,      0x017e, 0x0178};
  if (chr <= 0x7f || (chr >= 0xa0 && chr <= 0xff))
    return chr;
  for (unsigned int i = 0; i < sizeof w1252chrs / sizeof w1252chrs[0]; i++)
    if (chr == w1252chrs[i])
      return 0x80 + i;
  return 0;
}


x86 assembly (clang, -O0):
<windows1252_char>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x7f,-0x8(%rbp)
jle    112b <windows1252_char+0x2b>
cmpl   $0xa0,-0x8(%rbp)
jl     1136 <windows1252_char+0x36>
cmpl   $0xff,-0x8(%rbp)
jg     1136 <windows1252_char+0x36>
mov    -0x8(%rbp),%eax
mov    %al,-0x1(%rbp)
jmp    1189 <windows1252_char+0x89>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    $0x20,%rax
jae    1185 <windows1252_char+0x85>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    %ecx,%edx
lea    0xea7(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
jne    1172 <windows1252_char+0x72>
mov    -0xc(%rbp),%eax
add    $0x80,%eax
mov    %al,-0x1(%rbp)
jmp    1189 <windows1252_char+0x89>
jmp    1177 <windows1252_char+0x77>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <windows1252_char+0x3d>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<windows1252_char>:
cmp    $0x80,%edi
jl     1144 <windows1252_char+0x44>
lea    -0xa0(%rdi),%eax
cmp    $0x60,%eax
jb     1144 <windows1252_char+0x44>
xor    %eax,%eax
lea    0xee4(%rip),%rcx
nopl   0x0(%rax)
cmp    %edi,(%rcx,%rax,4)
je     114b <windows1252_char+0x4b>
cmp    %edi,0x4(%rcx,%rax,4)
je     1147 <windows1252_char+0x47>
cmp    %edi,0x8(%rcx,%rax,4)
je     114e <windows1252_char+0x4e>
cmp    %edi,0xc(%rcx,%rax,4)
je     1155 <windows1252_char+0x55>
add    $0x4,%rax
cmp    $0x20,%rax
jne    1120 <windows1252_char+0x20>
xor    %eax,%eax
ret
mov    %edi,%eax
ret
add    $0x1,%rax
xor    $0x80,%al
ret
add    $0x2,%rax
xor    $0x80,%al
ret
add    $0x3,%rax
xor    $0x80,%al
ret

LLVM IR (-O0):
@windows1252_char.w1252chrs = internal constant [32 x i32] [i32 8364, i32 0, i32 8218, i32 402, i32 8222, i32 8230, i32 8224, i32 8225, i32 710, i32 8240, i32 352, i32 8249, i32 338, i32 0, i32 381, i32 0, i32 0, i32 8216, i32 8217, i32 8220, i32 8221, i32 8226, i32 8211, i32 8212, i32 732, i32 8482, i32 353, i32 8250, i32 339, i32 0, i32 382, i32 376]
define signext i8 @windows1252_char(i32 %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 127
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, 160
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32, i32* %3
%12 = icmp sle i32 %11, 255
br i1 %12, label %13, label %16
13: ; preds = %10, %1
%14 = load i32, i32* %3
%15 = trunc i32 %14 to i8
store i8 %15, i8* %2
br label %37
16: ; preds = %10, %7
store i32 0, i32* %4
br label %17
17: ; preds = %33, %16
%18 = load i32, i32* %4
%19 = zext i32 %18 to i64
%20 = icmp ult i64 %19, 32
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [32 x i32], [32 x i32]* @windows1252_char.w1252chrs, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp eq i32 %22, %26
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = load i32, i32* %4
%30 = add i32 128, %29
%31 = trunc i32 %30 to i8
store i8 %31, i8* %2
br label %37
32: ; preds = %21
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add i32 %34, 1
store i32 %35, i32* %4
br label %17
36: ; preds = %17
store i8 0, i8* %2
br label %37
37: ; preds = %36, %28, %13
%38 = load i8, i8* %2
ret i8 %38
}

LLVM IR (-O2):
@windows1252_char.w1252chrs = internal unnamed_addr constant [32 x i32] [i32 8364, i32 0, i32 8218, i32 402, i32 8222, i32 8230, i32 8224, i32 8225, i32 710, i32 8240, i32 352, i32 8249, i32 338, i32 0, i32 381, i32 0, i32 0, i32 8216, i32 8217, i32 8220, i32 8221, i32 8226, i32 8211, i32 8212, i32 732, i32 8482, i32 353, i32 8250, i32 339, i32 0, i32 382, i32 376]
define signext i8 @windows1252_char(i32 %0) {
%2 = icmp slt i32 %0, 128
%3 = add i32 %0, -160
%4 = icmp ult i32 %3, 96
%5 = or i1 %2, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = trunc i32 %0 to i8
br label %35
8: ; preds = %1, %32
%9 = phi i64 [ %33, %32 ], [ 0, %1 ]
%10 = getelementptr inbounds [32 x i32], [32 x i32]* @windows1252_char.w1252chrs, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, %0
br i1 %12, label %13, label %17
13: ; preds = %27, %22, %17, %8
%14 = phi i64 [ %9, %8 ], [ %18, %17 ], [ %23, %22 ], [ %28, %27 ]
%15 = trunc i64 %14 to i8
%16 = xor i8 %15, -128
br label %35
17: ; preds = %8
%18 = or i64 %9, 1
%19 = getelementptr inbounds [32 x i32], [32 x i32]* @windows1252_char.w1252chrs, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, %0
br i1 %21, label %13, label %22
22: ; preds = %17
%23 = or i64 %9, 2
%24 = getelementptr inbounds [32 x i32], [32 x i32]* @windows1252_char.w1252chrs, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, %0
br i1 %26, label %13, label %27
27: ; preds = %22
%28 = or i64 %9, 3
%29 = getelementptr inbounds [32 x i32], [32 x i32]* @windows1252_char.w1252chrs, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, %0
br i1 %31, label %13, label %32
32: ; preds = %27
%33 = add nuw nsw i64 %9, 4
%34 = icmp eq i64 %33, 32
br i1 %34, label %35, label %8
35: ; preds = %32, %13, %6
%36 = phi i8 [ %7, %6 ], [ %16, %13 ], [ 0, %32 ]
ret i8 %36
}