unsigned short koi2wc(char c) {
  static char koi2wc_table[64] = {
      0x4e, 0x30, 0x31, 0x46, 0x34, 0x35, 0x44, 0x33, 0x45, 0x38, 0x39,
      0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x4f, 0x40, 0x41, 0x42, 0x43,
      0x36, 0x32, 0x4c, 0x4b, 0x37, 0x48, 0x4d, 0x49, 0x47, 0x4a, 0x2e,
      0x10, 0x11, 0x26, 0x14, 0x15, 0x24, 0x13, 0x25, 0x18, 0x19, 0x1a,
      0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x2f, 0x20, 0x21, 0x22, 0x23, 0x16,
      0x12, 0x2c, 0x2b, 0x17, 0x28, 0x2d, 0x29, 0x27, 0x2a};
  unsigned char uc = c;
  if (uc >= 192)
    return koi2wc_table[(unsigned char)c - 192] + 0x400;
  else if (uc == '#' + 128)
    return 0x0451;
  else if (uc == '3' + 128)
    return 0x0401;
  else if (uc == '4' + 128)
    return 0x0404;
  else if (uc == '$' + 128)
    return 0x0454;
  else if (uc == '6' + 128)
    return 0x0406;
  else if (uc == '&' + 128)
    return 0x0456;
  else if (uc == '7' + 128)
    return 0x0407;
  else if (uc == '\'' + 128)
    return 0x0457;
  else if (uc == '>' + 128)
    return 0x040e;
  else if (uc == '.' + 128)
    return 0x045e;
  else if (uc == '/' + 128)
    return 0x042a;
  else
    return (unsigned short)(unsigned char)c;
}


x86 assembly (clang, -O0):
<koi2wc>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x3(%rbp)
mov    -0x3(%rbp),%al
mov    %al,-0x4(%rbp)
movzbl -0x4(%rbp),%eax
cmp    $0xc0,%eax
jl     1144 <koi2wc+0x44>
movzbl -0x3(%rbp),%eax
sub    $0xc0,%eax
movslq %eax,%rcx
lea    0x2efe(%rip),%rax
movsbl (%rax,%rcx,1),%eax
add    $0x400,%eax
mov    %ax,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xa3,%eax
jne    115e <koi2wc+0x5e>
movw   $0x451,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xb3,%eax
jne    1178 <koi2wc+0x78>
movw   $0x401,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xb4,%eax
jne    1192 <koi2wc+0x92>
movw   $0x404,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xa4,%eax
jne    11ac <koi2wc+0xac>
movw   $0x454,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xb6,%eax
jne    11c6 <koi2wc+0xc6>
movw   $0x406,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xa6,%eax
jne    11e0 <koi2wc+0xe0>
movw   $0x456,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xb7,%eax
jne    11fa <koi2wc+0xfa>
movw   $0x407,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xa7,%eax
jne    1214 <koi2wc+0x114>
movw   $0x457,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xbe,%eax
jne    122e <koi2wc+0x12e>
movw   $0x40e,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xae,%eax
jne    1248 <koi2wc+0x148>
movw   $0x45e,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x4(%rbp),%eax
cmp    $0xaf,%eax
jne    1262 <koi2wc+0x162>
movw   $0x42a,-0x2(%rbp)
jmp    126a <koi2wc+0x16a>
movzbl -0x3(%rbp),%eax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<koi2wc>:
cmp    $0xc0,%dil
jb     1120 <koi2wc+0x20>
movzbl %dil,%eax
add    $0xffffff40,%eax
lea    0xf5a(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0x400,%eax
ret
lea    0x5d(%rdi),%ecx
cmp    $0x1b,%cl
ja     1144 <koi2wc+0x44>
mov    $0x451,%ax
movzbl %cl,%ecx
lea    0xeca(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x454,%ax
ret
movzbl %dil,%eax
ret
mov    $0x456,%ax
ret
mov    $0x457,%ax
ret
mov    $0x45e,%ax
ret
mov    $0x42a,%ax
ret
mov    $0x401,%ax
ret
mov    $0x404,%ax
ret
mov    $0x406,%ax
ret
mov    $0x407,%ax
ret
mov    $0x40e,%ax
ret

LLVM IR (-O0):
@koi2wc.koi2wc_table = internal global [64 x i8] c"N01F45D3E89:;<=>?O@ABC62LK7HMIGJ.\10\11&\14\15$\13%\18\19\1A\1B\1C\1D\1E\1F/ !\22#\16\12,+\17(-)'*"
define zeroext i16 @koi2wc(i8 signext %0) {
%2 = alloca i16
%3 = alloca i8
%4 = alloca i8
store i8 %0, i8* %3
%5 = load i8, i8* %3
store i8 %5, i8* %4
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
%8 = icmp sge i32 %7, 192
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = sub nsw i32 %11, 192
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [64 x i8], [64 x i8]* @koi2wc.koi2wc_table, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = add nsw i32 %16, 1024
%18 = trunc i32 %17 to i16
store i16 %18, i16* %2
br label %77
19: ; preds = %1
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = icmp eq i32 %21, 163
br i1 %22, label %23, label %24
23: ; preds = %19
store i16 1105, i16* %2
br label %77
24: ; preds = %19
%25 = load i8, i8* %4
%26 = zext i8 %25 to i32
%27 = icmp eq i32 %26, 179
br i1 %27, label %28, label %29
28: ; preds = %24
store i16 1025, i16* %2
br label %77
29: ; preds = %24
%30 = load i8, i8* %4
%31 = zext i8 %30 to i32
%32 = icmp eq i32 %31, 180
br i1 %32, label %33, label %34
33: ; preds = %29
store i16 1028, i16* %2
br label %77
34: ; preds = %29
%35 = load i8, i8* %4
%36 = zext i8 %35 to i32
%37 = icmp eq i32 %36, 164
br i1 %37, label %38, label %39
38: ; preds = %34
store i16 1108, i16* %2
br label %77
39: ; preds = %34
%40 = load i8, i8* %4
%41 = zext i8 %40 to i32
%42 = icmp eq i32 %41, 182
br i1 %42, label %43, label %44
43: ; preds = %39
store i16 1030, i16* %2
br label %77
44: ; preds = %39
%45 = load i8, i8* %4
%46 = zext i8 %45 to i32
%47 = icmp eq i32 %46, 166
br i1 %47, label %48, label %49
48: ; preds = %44
store i16 1110, i16* %2
br label %77
49: ; preds = %44
%50 = load i8, i8* %4
%51 = zext i8 %50 to i32
%52 = icmp eq i32 %51, 183
br i1 %52, label %53, label %54
53: ; preds = %49
store i16 1031, i16* %2
br label %77
54: ; preds = %49
%55 = load i8, i8* %4
%56 = zext i8 %55 to i32
%57 = icmp eq i32 %56, 167
br i1 %57, label %58, label %59
58: ; preds = %54
store i16 1111, i16* %2
br label %77
59: ; preds = %54
%60 = load i8, i8* %4
%61 = zext i8 %60 to i32
%62 = icmp eq i32 %61, 190
br i1 %62, label %63, label %64
63: ; preds = %59
store i16 1038, i16* %2
br label %77
64: ; preds = %59
%65 = load i8, i8* %4
%66 = zext i8 %65 to i32
%67 = icmp eq i32 %66, 174
br i1 %67, label %68, label %69
68: ; preds = %64
store i16 1118, i16* %2
br label %77
69: ; preds = %64
%70 = load i8, i8* %4
%71 = zext i8 %70 to i32
%72 = icmp eq i32 %71, 175
br i1 %72, label %73, label %74
73: ; preds = %69
store i16 1066, i16* %2
br label %77
74: ; preds = %69
%75 = load i8, i8* %3
%76 = zext i8 %75 to i16
store i16 %76, i16* %2
br label %77
77: ; preds = %74, %73, %68, %63, %58, %53, %48, %43, %38, %33, %28, %23, %9
%78 = load i16, i16* %2
ret i16 %78
}

LLVM IR (-O2):
@koi2wc.koi2wc_table = internal unnamed_addr constant [64 x i8] c"N01F45D3E89:;<=>?O@ABC62LK7HMIGJ.\10\11&\14\15$\13%\18\19\1A\1B\1C\1D\1E\1F/ !\22#\16\12,+\17(-)'*"
define zeroext i16 @koi2wc(i8 signext %0) {
%2 = icmp ugt i8 %0, -65
br i1 %2, label %3, label %11
3: ; preds = %1
%4 = zext i8 %0 to i64
%5 = add nuw nsw i64 %4, 4294967104
%6 = and i64 %5, 4294967295
%7 = getelementptr inbounds [64 x i8], [64 x i8]* @koi2wc.koi2wc_table, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = sext i8 %8 to i16
%10 = add nsw i16 %9, 1024
br label %24
11: ; preds = %1
switch i8 %0, label %22 [
i8 -93, label %24
i8 -77, label %12
i8 -76, label %13
i8 -92, label %14
i8 -74, label %15
i8 -90, label %16
i8 -73, label %17
i8 -89, label %18
i8 -66, label %19
i8 -82, label %20
i8 -81, label %21
]
12: ; preds = %11
br label %24
13: ; preds = %11
br label %24
14: ; preds = %11
br label %24
15: ; preds = %11
br label %24
16: ; preds = %11
br label %24
17: ; preds = %11
br label %24
18: ; preds = %11
br label %24
19: ; preds = %11
br label %24
20: ; preds = %11
br label %24
21: ; preds = %11
br label %24
22: ; preds = %11
%23 = zext i8 %0 to i16
br label %24
24: ; preds = %11, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %3
%25 = phi i16 [ %10, %3 ], [ 1025, %12 ], [ 1028, %13 ], [ 1108, %14 ], [ 1030, %15 ], [ 1110, %16 ], [ 1031, %17 ], [ 1111, %18 ], [ 1038, %19 ], [ 1118, %20 ], [ 1066, %21 ], [ %23, %22 ], [ 1105, %11 ]
ret i16 %25
}