#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*/ aDia;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int fts5_remove_diacritic(int c, int bComplex) {
  unsigned short aDia[] = {
      0,     1797,  1848,  1859,  1891,  1928,  1940,  1995,  2024,  2040,
      2060,  2110,  2168,  2206,  2264,  2286,  2344,  2383,  2472,  2488,
      2516,  2596,  2668,  2732,  2782,  2842,  2894,  2954,  2984,  3000,
      3028,  3336,  3456,  3696,  3712,  3728,  3744,  3766,  3832,  3896,
      3912,  3928,  3944,  3968,  4008,  4040,  4056,  4106,  4138,  4170,
      4202,  4234,  4266,  4296,  4312,  4344,  4408,  4424,  4442,  4472,
      4488,  4504,  6148,  6198,  6264,  6280,  6360,  6429,  6505,  6529,
      61448, 61468, 61512, 61534, 61592, 61610, 61642, 61672, 61688, 61704,
      61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914, 61948, 61998,
      62062, 62122, 62154, 62184, 62200, 62218, 62252, 62302, 62364, 62410,
      62442, 62478, 62536, 62554, 62584, 62604, 62640, 62648, 62656, 62664,
      62730, 62766, 62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118,
      63182, 63242, 63274, 63310, 63368, 63390,
  };
  unsigned char aChar[] = {
      '\0',
      'a',
      'c',
      'e',
      'i',
      'n',
      'o',
      'u',
      'y',
      'y',
      'a',
      'c',
      'd',
      'e',
      'e',
      'g',
      'h',
      'i',
      'j',
      'k',
      'l',
      'n',
      'o',
      'r',
      's',
      't',
      'u',
      'u',
      'w',
      'y',
      'z',
      'o',
      'u',
      'a',
      'i',
      'o',
      'u',
      'u' | ((unsigned char)0x80),
      'a' | ((unsigned char)0x80),
      'g',
      'k',
      'o',
      'o' | ((unsigned char)0x80),
      'j',
      'g',
      'n',
      'a' | ((unsigned char)0x80),
      'a',
      'e',
      'i',
      'o',
      'r',
      'u',
      's',
      't',
      'h',
      'a',
      'e',
      'o' | ((unsigned char)0x80),
      'o',
      'o' | ((unsigned char)0x80),
      'y',
      '\0',
      '\0',
      '\0',
      '\0',
      '\0',
      '\0',
      '\0',
      '\0',
      'a',
      'b',
      'c' | ((unsigned char)0x80),
      'd',
      'd',
      'e' | ((unsigned char)0x80),
      'e',
      'e' | ((unsigned char)0x80),
      'f',
      'g',
      'h',
      'h',
      'i',
      'i' | ((unsigned char)0x80),
      'k',
      'l',
      'l' | ((unsigned char)0x80),
      'l',
      'm',
      'n',
      'o' | ((unsigned char)0x80),
      'p',
      'r',
      'r' | ((unsigned char)0x80),
      'r',
      's',
      's' | ((unsigned char)0x80),
      't',
      'u',
      'u' | ((unsigned char)0x80),
      'v',
      'w',
      'w',
      'x',
      'y',
      'z',
      'h',
      't',
      'w',
      'y',
      'a',
      'a' | ((unsigned char)0x80),
      'a' | ((unsigned char)0x80),
      'a' | ((unsigned char)0x80),
      'e',
      'e' | ((unsigned char)0x80),
      'e' | ((unsigned char)0x80),
      'i',
      'o',
      'o' | ((unsigned char)0x80),
      'o' | ((unsigned char)0x80),
      'o' | ((unsigned char)0x80),
      'u',
      'u' | ((unsigned char)0x80),
      'u' | ((unsigned char)0x80),
      'y',
  };
  unsigned int key = (((unsigned int)c) << 3) | 0x00000007;
  int iRes = 0;
  int iHi = sizeof(aDia) / sizeof(aDia[0]) - 1;
  int iLo = 0;
  while (iHi >= iLo) {
    int iTest = (iHi + iLo) / 2;
    if (key >= aDia[iTest]) {
      iRes = iTest;
      iLo = iTest + 1;
    } else {
      iHi = iTest - 1;
    }
  }
  assert(key >= aDia[iRes]);
  if (bComplex == 0 && (aChar[iRes] & 0x80))
    return c;
  return (c > (aDia[iRes] >> 3) + (aDia[iRes] & 0x07))
             ? c
             : ((int)aChar[iRes] & 0x7F);
}


x86 assembly (clang, -O0):
<fts5_remove_diacritic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xec1(%rip),%rsi
mov    $0xfc,%edx
call   1040 <memcpy@plt>
lea    -0x190(%rbp),%rdi
lea    0xfa9(%rip),%rsi
mov    $0x7e,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
or     $0x7,%eax
mov    %eax,-0x194(%rbp)
movl   $0x0,-0x198(%rbp)
movl   $0x7d,-0x19c(%rbp)
movl   $0x0,-0x1a0(%rbp)
mov    -0x19c(%rbp),%eax
cmp    -0x1a0(%rbp),%eax
jl     120b <fts5_remove_diacritic+0xeb>
mov    -0x19c(%rbp),%eax
add    -0x1a0(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1a4(%rbp)
mov    -0x194(%rbp),%eax
movslq -0x1a4(%rbp),%rcx
movzwl -0x110(%rbp,%rcx,2),%ecx
ff
cmp    %ecx,%eax
jb     11f7 <fts5_remove_diacritic+0xd7>
mov    -0x1a4(%rbp),%eax
mov    %eax,-0x198(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a0(%rbp)
jmp    1206 <fts5_remove_diacritic+0xe6>
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x19c(%rbp)
jmp    118e <fts5_remove_diacritic+0x6e>
mov    -0x194(%rbp),%eax
movslq -0x198(%rbp),%rcx
movzwl -0x110(%rbp,%rcx,2),%ecx
ff
cmp    %ecx,%eax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1261 <fts5_remove_diacritic+0x141>
movslq -0x198(%rbp),%rax
movzbl -0x190(%rbp,%rax,1),%eax
ff
and    $0x80,%eax
cmp    $0x0,%eax
je     1261 <fts5_remove_diacritic+0x141>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12c1 <fts5_remove_diacritic+0x1a1>
mov    -0x8(%rbp),%eax
movslq -0x198(%rbp),%rcx
movzwl -0x110(%rbp,%rcx,2),%ecx
ff
sar    $0x3,%ecx
movslq -0x198(%rbp),%rdx
movzwl -0x110(%rbp,%rdx,2),%edx
ff
and    $0x7,%edx
add    %edx,%ecx
cmp    %ecx,%eax
jle    12a0 <fts5_remove_diacritic+0x180>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
jmp    12b8 <fts5_remove_diacritic+0x198>
movslq -0x198(%rbp),%rax
movzbl -0x190(%rbp,%rax,1),%eax
ff
and    $0x7f,%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts5_remove_diacritic>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
lea    0x7(,%r15,8),%eax
mov    $0x7d,%ebp
xor    %edx,%edx
lea    0xecd(%rip),%rcx
xor    %edi,%edi
jmp    1149 <fts5_remove_diacritic+0x39>
nopw   0x0(%rax,%rax,1)
lea    0x1(%rsi),%edx
mov    %esi,%edi
cmp    %edx,%ebp
jl     1169 <fts5_remove_diacritic+0x59>
lea    (%rdx,%rbp,1),%ebx
mov    %ebx,%esi
shr    $0x1f,%esi
add    %ebx,%esi
sar    %esi
movslq %esi,%rbx
movzwl (%rcx,%rbx,2),%ebx
cmp    %ebx,%eax
jae    1140 <fts5_remove_diacritic+0x30>
add    $0xffffffff,%esi
mov    %esi,%ebp
cmp    %edx,%ebp
jge    1149 <fts5_remove_diacritic+0x39>
movslq %edi,%rbp
movzwl (%rcx,%rbp,2),%ebx
xor    %edi,%edi
cmp    %ebx,%eax
setae  %dil
call   1030 <assert@plt>
test   %r14d,%r14d
jne    1190 <fts5_remove_diacritic+0x80>
lea    0xf77(%rip),%rax
cmpb   $0x0,0x0(%rbp,%rax,1)
js     11b0 <fts5_remove_diacritic+0xa0>
mov    %ebx,%eax
shr    $0x3,%eax
and    $0x7,%ebx
add    %eax,%ebx
cmp    %r15d,%ebx
jl     11b0 <fts5_remove_diacritic+0xa0>
lea    0xf5a(%rip),%rax
movzbl 0x0(%rbp,%rax,1),%r15d
and    $0x7f,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.fts5_remove_diacritic.aDia = [126 x i16] [i16 0, i16 1797, i16 1848, i16 1859, i16 1891, i16 1928, i16 1940, i16 1995, i16 2024, i16 2040, i16 2060, i16 2110, i16 2168, i16 2206, i16 2264, i16 2286, i16 2344, i16 2383, i16 2472, i16 2488, i16 2516, i16 2596, i16 2668, i16 2732, i16 2782, i16 2842, i16 2894, i16 2954, i16 2984, i16 3000, i16 3028, i16 3336, i16 3456, i16 3696, i16 3712, i16 3728, i16 3744, i16 3766, i16 3832, i16 3896, i16 3912, i16 3928, i16 3944, i16 3968, i16 4008, i16 4040, i16 4056, i16 4106, i16 4138, i16 4170, i16 4202, i16 4234, i16 4266, i16 4296, i16 4312, i16 4344, i16 4408, i16 4424, i16 4442, i16 4472, i16 4488, i16 4504, i16 6148, i16 6198, i16 6264, i16 6280, i16 6360, i16 6429, i16 6505, i16 6529, i16 -4088, i16 -4068, i16 -4024, i16 -4002, i16 -3944, i16 -3926, i16 -3894, i16 -3864, i16 -3848, i16 -3832, i16 -3810, i16 -3752, i16 -3736, i16 -3720, i16 -3700, i16 -3656, i16 -3640, i16 -3622, i16 -3588, i16 -3538, i16 -3474, i16 -3414, i16 -3382, i16 -3352, i16 -3336, i16 -3318, i16 -3284, i16 -3234, i16 -3172, i16 -3126, i16 -3094, i16 -3058, i16 -3000, i16 -2982, i16 -2952, i16 -2932, i16 -2896, i16 -2888, i16 -2880, i16 -2872, i16 -2806, i16 -2770, i16 -2706, i16 -2646, i16 -2612, i16 -2562, i16 -2504, i16 -2486, i16 -2454, i16 -2418, i16 -2354, i16 -2294, i16 -2262, i16 -2226, i16 -2168, i16 -2146]
@__const.fts5_remove_diacritic.aChar = [126 x i8] c"\00aceinouyyacdeeghijklnorstuuwyzouaiou\F5\E1gko\EFjgn\E1aeiorusthae\EFo\EFy\00\00\00\00\00\00\00\00ab\E3dd\E5e\E5fghhi\E9kl\EClmn\EFpr\F2rs\F3tu\F5vwwxyzhtwya\E1\E1\E1e\E5\E5io\EF\EF\EFu\F5\F5y"
define i32 @fts5_remove_diacritic(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [126 x i16]
%7 = alloca [126 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%13 = bitcast [126 x i16]* %6 to i8*
%14 = bitcast [126 x i8]* %7 to i8*
%15 = load i32, i32* %4
%16 = shl i32 %15, 3
%17 = or i32 %16, 7
store i32 %17, i32* %8
store i32 0, i32* %9
store i32 125, i32* %10
store i32 0, i32* %11
br label %18
18: ; preds = %41, %2
%19 = load i32, i32* %10
%20 = load i32, i32* %11
%21 = icmp sge i32 %19, %20
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i32, i32* %10
%24 = load i32, i32* %11
%25 = add nsw i32 %23, %24
%26 = sdiv i32 %25, 2
store i32 %26, i32* %12
%27 = load i32, i32* %8
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [126 x i16], [126 x i16]* %6, i64 0, i64 %29
%31 = load i16, i16* %30
%32 = zext i16 %31 to i32
%33 = icmp uge i32 %27, %32
br i1 %33, label %34, label %38
34: ; preds = %22
%35 = load i32, i32* %12
store i32 %35, i32* %9
%36 = load i32, i32* %12
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
br label %41
38: ; preds = %22
%39 = load i32, i32* %12
%40 = sub nsw i32 %39, 1
store i32 %40, i32* %10
br label %41
41: ; preds = %38, %34
br label %18
42: ; preds = %18
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [126 x i16], [126 x i16]* %6, i64 0, i64 %45
%47 = load i16, i16* %46
%48 = zext i16 %47 to i32
%49 = icmp uge i32 %43, %48
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = load i32, i32* %5
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %64
54: ; preds = %42
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [126 x i8], [126 x i8]* %7, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = and i32 %59, 128
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %54
%63 = load i32, i32* %4
store i32 %63, i32* %3
br label %91
64: ; preds = %54, %42
%65 = load i32, i32* %4
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [126 x i16], [126 x i16]* %6, i64 0, i64 %67
%69 = load i16, i16* %68
%70 = zext i16 %69 to i32
%71 = ashr i32 %70, 3
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [126 x i16], [126 x i16]* %6, i64 0, i64 %73
%75 = load i16, i16* %74
%76 = zext i16 %75 to i32
%77 = and i32 %76, 7
%78 = add nsw i32 %71, %77
%79 = icmp sgt i32 %65, %78
br i1 %79, label %80, label %82
80: ; preds = %64
%81 = load i32, i32* %4
br label %89
82: ; preds = %64
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [126 x i8], [126 x i8]* %7, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = and i32 %87, 127
br label %89
89: ; preds = %82, %80
%90 = phi i32 [ %81, %80 ], [ %88, %82 ]
store i32 %90, i32* %3
br label %91
91: ; preds = %89, %62
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@__const.fts5_remove_diacritic.aDia = [126 x i16] [i16 0, i16 1797, i16 1848, i16 1859, i16 1891, i16 1928, i16 1940, i16 1995, i16 2024, i16 2040, i16 2060, i16 2110, i16 2168, i16 2206, i16 2264, i16 2286, i16 2344, i16 2383, i16 2472, i16 2488, i16 2516, i16 2596, i16 2668, i16 2732, i16 2782, i16 2842, i16 2894, i16 2954, i16 2984, i16 3000, i16 3028, i16 3336, i16 3456, i16 3696, i16 3712, i16 3728, i16 3744, i16 3766, i16 3832, i16 3896, i16 3912, i16 3928, i16 3944, i16 3968, i16 4008, i16 4040, i16 4056, i16 4106, i16 4138, i16 4170, i16 4202, i16 4234, i16 4266, i16 4296, i16 4312, i16 4344, i16 4408, i16 4424, i16 4442, i16 4472, i16 4488, i16 4504, i16 6148, i16 6198, i16 6264, i16 6280, i16 6360, i16 6429, i16 6505, i16 6529, i16 -4088, i16 -4068, i16 -4024, i16 -4002, i16 -3944, i16 -3926, i16 -3894, i16 -3864, i16 -3848, i16 -3832, i16 -3810, i16 -3752, i16 -3736, i16 -3720, i16 -3700, i16 -3656, i16 -3640, i16 -3622, i16 -3588, i16 -3538, i16 -3474, i16 -3414, i16 -3382, i16 -3352, i16 -3336, i16 -3318, i16 -3284, i16 -3234, i16 -3172, i16 -3126, i16 -3094, i16 -3058, i16 -3000, i16 -2982, i16 -2952, i16 -2932, i16 -2896, i16 -2888, i16 -2880, i16 -2872, i16 -2806, i16 -2770, i16 -2706, i16 -2646, i16 -2612, i16 -2562, i16 -2504, i16 -2486, i16 -2454, i16 -2418, i16 -2354, i16 -2294, i16 -2262, i16 -2226, i16 -2168, i16 -2146]
@__const.fts5_remove_diacritic.aChar = [126 x i8] c"\00aceinouyyacdeeghijklnorstuuwyzouaiou\F5\E1gko\EFjgn\E1aeiorusthae\EFo\EFy\00\00\00\00\00\00\00\00ab\E3dd\E5e\E5fghhi\E9kl\EClmn\EFpr\F2rs\F3tu\F5vwwxyzhtwya\E1\E1\E1e\E5\E5io\EF\EF\EFu\F5\F5y"
define i32 @fts5_remove_diacritic(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = or i32 %3, 7
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 0, %2 ], [ %20, %5 ]
%7 = phi i32 [ 125, %2 ], [ %19, %5 ]
%8 = phi i32 [ 0, %2 ], [ %18, %5 ]
%9 = add nsw i32 %6, %7
%10 = sdiv i32 %9, 2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [126 x i16], [126 x i16]* @__const.fts5_remove_diacritic.aDia, i64 0, i64 %11
%13 = load i16, i16* %12
%14 = zext i16 %13 to i32
%15 = icmp ult i32 %4, %14
%16 = add nsw i32 %10, 1
%17 = add nsw i32 %10, -1
%18 = select i1 %15, i32 %8, i32 %10
%19 = select i1 %15, i32 %17, i32 %7
%20 = select i1 %15, i32 %6, i32 %16
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %5
22: ; preds = %5
%23 = sext i32 %18 to i64
%24 = getelementptr inbounds [126 x i16], [126 x i16]* @__const.fts5_remove_diacritic.aDia, i64 0, i64 %23
%25 = load i16, i16* %24
%26 = zext i16 %25 to i32
%27 = icmp uge i32 %4, %26
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = icmp eq i32 %1, 0
br i1 %30, label %31, label %35
31: ; preds = %22
%32 = getelementptr inbounds [126 x i8], [126 x i8]* @__const.fts5_remove_diacritic.aChar, i64 0, i64 %23
%33 = load i8, i8* %32
%34 = icmp sgt i8 %33, -1
br i1 %34, label %35, label %45
35: ; preds = %31, %22
%36 = lshr i32 %26, 3
%37 = and i32 %26, 7
%38 = add nuw nsw i32 %36, %37
%39 = icmp slt i32 %38, %0
br i1 %39, label %45, label %40
40: ; preds = %35
%41 = getelementptr inbounds [126 x i8], [126 x i8]* @__const.fts5_remove_diacritic.aChar, i64 0, i64 %23
%42 = load i8, i8* %41
%43 = and i8 %42, 127
%44 = zext i8 %43 to i32
br label %45
45: ; preds = %40, %35, %31
%46 = phi i32 [ %0, %31 ], [ %44, %40 ], [ %0, %35 ]
ret i32 %46
}