unsigned char unicode_to_cp1251(unsigned short val) {
  static char tab0[256] = {
      0,    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
      0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
      0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
      0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
      0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
      0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
      0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
      0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
      0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
      0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0,    0,    0,    0,
      0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
      0,    0,    0,    0,    0,    0,    0,    0,    0x98, 0,    0,    0,
      0,    0,    0,    0,    0xa0, 0,    0,    0,    0xa4, 0,    0xa6, 0xa7,
      0,    0xa9, 0,    0xab, 0xac, 0xad, 0xae, 0,    0xb0, 0xb1, 0,    0,
      0,    0xb5, 0xb6, 0xb7, 0,    0,    0,    0xbb, 0,    0,    0,    0,
      0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
      0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    'x',
      0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
      0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
      0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
      0,    0,    0,    0,
  };
  switch (val >> 8) {
  case 0x00:
    return tab0[val];
  case 0x04:
    switch ((unsigned char)val) {
    case 0x01:
      return 0xa8;
    case 0x02:
      return 0x80;
    case 0x03:
      return 0x81;
    case 0x04:
      return 0xaa;
    case 0x05:
      return 0xbd;
    case 0x06:
      return 0xb2;
    case 0x07:
      return 0xaf;
    case 0x08:
      return 0xa3;
    case 0x09:
      return 0x8a;
    case 0x0a:
      return 0x8c;
    case 0x0b:
      return 0x8e;
    case 0x0c:
      return 0x8d;
    case 0x0e:
      return 0xa1;
    case 0x0f:
      return 0x8f;
    case 0x10:
      return 0xc0;
    case 0x11:
      return 0xc1;
    case 0x12:
      return 0xc2;
    case 0x13:
      return 0xc3;
    case 0x14:
      return 0xc4;
    case 0x15:
      return 0xc5;
    case 0x16:
      return 0xc6;
    case 0x17:
      return 0xc7;
    case 0x18:
      return 0xc8;
    case 0x19:
      return 0xc9;
    case 0x1a:
      return 0xca;
    case 0x1b:
      return 0xcb;
    case 0x1c:
      return 0xcc;
    case 0x1d:
      return 0xcd;
    case 0x1e:
      return 0xce;
    case 0x1f:
      return 0xcf;
    case 0x20:
      return 0xd0;
    case 0x21:
      return 0xd1;
    case 0x22:
      return 0xd2;
    case 0x23:
      return 0xd3;
    case 0x24:
      return 0xd4;
    case 0x25:
      return 0xd5;
    case 0x26:
      return 0xd6;
    case 0x27:
      return 0xd7;
    case 0x28:
      return 0xd8;
    case 0x29:
      return 0xd9;
    case 0x2a:
      return 0xda;
    case 0x2b:
      return 0xdb;
    case 0x2c:
      return 0xdc;
    case 0x2d:
      return 0xdd;
    case 0x2e:
      return 0xde;
    case 0x2f:
      return 0xdf;
    case 0x30:
      return 0xe0;
    case 0x31:
      return 0xe1;
    case 0x32:
      return 0xe2;
    case 0x33:
      return 0xe3;
    case 0x34:
      return 0xe4;
    case 0x35:
      return 0xe5;
    case 0x36:
      return 0xe6;
    case 0x37:
      return 0xe7;
    case 0x38:
      return 0xe8;
    case 0x39:
      return 0xe9;
    case 0x3a:
      return 0xea;
    case 0x3b:
      return 0xeb;
    case 0x3c:
      return 0xec;
    case 0x3d:
      return 0xed;
    case 0x3e:
      return 0xee;
    case 0x3f:
      return 0xef;
    case 0x40:
      return 0xf0;
    case 0x41:
      return 0xf1;
    case 0x42:
      return 0xf2;
    case 0x43:
      return 0xf3;
    case 0x44:
      return 0xf4;
    case 0x45:
      return 0xf5;
    case 0x46:
      return 0xf6;
    case 0x47:
      return 0xf7;
    case 0x48:
      return 0xf8;
    case 0x49:
      return 0xf9;
    case 0x4a:
      return 0xfa;
    case 0x4b:
      return 0xfb;
    case 0x4c:
      return 0xfc;
    case 0x4d:
      return 0xfd;
    case 0x4e:
      return 0xfe;
    case 0x4f:
      return 0xff;
    case 0x51:
      return 0xb8;
    case 0x52:
      return 0x90;
    case 0x53:
      return 0x83;
    case 0x54:
      return 0xba;
    case 0x55:
      return 0xbe;
    case 0x56:
      return 0xb3;
    case 0x57:
      return 0xbf;
    case 0x58:
      return 0xbc;
    case 0x59:
      return 0x9a;
    case 0x5a:
      return 0x9c;
    case 0x5b:
      return 0x9e;
    case 0x5c:
      return 0x9d;
    case 0x5e:
      return 0xa2;
    case 0x5f:
      return 0x9f;
    case 0x90:
      return 0xa5;
    case 0x91:
      return 0xb4;
    }
    break;
  case 0x20:
    switch ((unsigned char)val) {
    case 0x13:
      return 0x96;
    case 0x14:
      return 0x97;
    case 0x15:
      return '-';
    case 0x18:
      return 0x91;
    case 0x19:
      return 0x92;
    case 0x1a:
      return 0x82;
    case 0x1c:
      return 0x93;
    case 0x1d:
      return 0x94;
    case 0x1e:
      return 0x84;
    case 0x20:
      return 0x86;
    case 0x21:
      return 0x87;
    case 0x22:
      return 0x95;
    case 0x26:
      return 0x85;
    case 0x28:
      return 0x0a;
    case 0x30:
      return 0x89;
    case 0x32:
      return '\'';
    case 0x39:
      return 0x8b;
    case 0x3a:
      return 0x9b;
    case 0xac:
      return 0x88;
    }
    break;
  case 0x21:
    switch ((unsigned char)val) {
    case 0x16:
      return 0xb9;
    case 0x22:
      return 0x99;
    case 0x2f:
      return 'e';
    case 0x91:
      return '@';
    }
    break;
  case 0x22:
    switch ((unsigned char)val) {
    case 0x27:
      return '^';
    case 0x28:
      return 'v';
    case 0x60:
      return '#';
    }
    break;
  case 0x25:
    switch ((unsigned char)val) {
    case 0xca:
      return '$';
    }
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<unicode_to_cp1251>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x4(%rbp)
movzwl -0x4(%rbp),%eax
shr    $0x8,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x25,%eax
ja     1690 <unicode_to_cp1251+0x590>
mov    -0x10(%rbp),%rax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzwl -0x4(%rbp),%eax
mov    %eax,%ecx
lea    0x2eee(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movzbl -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x90,%eax
ja     14c7 <unicode_to_cp1251+0x3c7>
mov    -0x18(%rbp),%rax
lea    0x1190(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0xa8,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x80,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x81,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xaa,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xbd,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xb2,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xaf,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xa3,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x8a,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x8c,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x8e,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x8d,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xa1,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x8f,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc0,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc1,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc2,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc3,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc4,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc5,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc6,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc7,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc8,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xc9,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xca,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xcb,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xcc,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xcd,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xce,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xcf,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd0,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd1,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd2,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd3,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd4,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd5,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd6,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd7,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd8,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xd9,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xda,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xdb,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xdc,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xdd,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xde,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xdf,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe0,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe1,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe2,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe3,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe4,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe5,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe6,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe7,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe8,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xe9,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xea,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xeb,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xec,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xed,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xee,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xef,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf0,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf1,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf2,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf3,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf4,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf5,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf6,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf7,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf8,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xf9,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xfa,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xfb,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xfc,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xfd,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xfe,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xff,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xb8,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x90,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x83,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xba,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xbe,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xb3,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xbf,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xbc,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x9a,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x9c,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x9e,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x9d,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xa2,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x9f,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xa5,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xb4,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
jmp    1690 <unicode_to_cp1251+0x590>
movzbl -0x4(%rbp),%eax
add    $0xffffffed,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x99,%eax
ja     15a3 <unicode_to_cp1251+0x4a3>
mov    -0x20(%rbp),%rax
lea    0xba9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x96,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x97,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x2d,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x91,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x92,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x82,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x93,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x94,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x84,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x86,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x87,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x95,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x85,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0xa,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x89,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x27,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x8b,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x9b,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x88,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
jmp    1690 <unicode_to_cp1251+0x590>
movzbl -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x16,%eax
je     15f2 <unicode_to_cp1251+0x4f2>
jmp    15bd <unicode_to_cp1251+0x4bd>
mov    -0x24(%rbp),%eax
sub    $0x22,%eax
je     15fb <unicode_to_cp1251+0x4fb>
jmp    15ce <unicode_to_cp1251+0x4ce>
mov    -0x24(%rbp),%eax
sub    $0x2f,%eax
je     1604 <unicode_to_cp1251+0x504>
jmp    15df <unicode_to_cp1251+0x4df>
mov    -0x24(%rbp),%eax
sub    $0x91,%eax
je     160d <unicode_to_cp1251+0x50d>
jmp    1616 <unicode_to_cp1251+0x516>
movb   $0xb9,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x99,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x65,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x40,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
jmp    1690 <unicode_to_cp1251+0x590>
movzbl -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x27,%eax
je     1652 <unicode_to_cp1251+0x552>
jmp    1630 <unicode_to_cp1251+0x530>
mov    -0x28(%rbp),%eax
sub    $0x28,%eax
je     165b <unicode_to_cp1251+0x55b>
jmp    1641 <unicode_to_cp1251+0x541>
mov    -0x28(%rbp),%eax
sub    $0x60,%eax
je     1664 <unicode_to_cp1251+0x564>
jmp    166d <unicode_to_cp1251+0x56d>
movb   $0x5e,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x76,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
movb   $0x23,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
jmp    1690 <unicode_to_cp1251+0x590>
mov    -0x4(%rbp),%al
sub    $0xca,%al
jne    168b <unicode_to_cp1251+0x58b>
jmp    1682 <unicode_to_cp1251+0x582>
movb   $0x24,-0x1(%rbp)
jmp    1694 <unicode_to_cp1251+0x594>
jmp    1690 <unicode_to_cp1251+0x590>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<unicode_to_cp1251>:
mov    %edi,%eax
shr    $0x8,%eax
cmp    $0x25,%al
ja     11a9 <unicode_to_cp1251+0xa9>
lea    0xeec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzwl %di,%eax
lea    0x11b9(%rip),%rcx
jmp    113e <unicode_to_cp1251+0x3e>
add    $0x70,%dil
cmp    $0xd0,%dil
jae    11a9 <unicode_to_cp1251+0xa9>
movzbl %dil,%eax
lea    0x12a2(%rip),%rcx
mov    (%rax,%rcx,1),%al
jmp    1199 <unicode_to_cp1251+0x99>
add    $0x54,%dil
cmp    $0x8e,%dil
ja     11a9 <unicode_to_cp1251+0xa9>
mov    $0x96,%al
movzbl %dil,%ecx
lea    0xf3e(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x88,%al
ret
cmp    $0x21,%dil
jg     119a <unicode_to_cp1251+0x9a>
cmp    $0x91,%dil
je     11b2 <unicode_to_cp1251+0xb2>
mov    $0xb9,%al
cmp    $0x16,%dil
je     1199 <unicode_to_cp1251+0x99>
jmp    11a9 <unicode_to_cp1251+0xa9>
cmp    $0x27,%dil
je     11ac <unicode_to_cp1251+0xac>
cmp    $0x60,%dil
je     11af <unicode_to_cp1251+0xaf>
cmp    $0x28,%dil
jne    11a9 <unicode_to_cp1251+0xa9>
mov    $0x76,%al
ret
mov    $0x24,%al
cmp    $0xca,%dil
jne    11a9 <unicode_to_cp1251+0xa9>
ret
cmp    $0x2f,%dil
je     11b5 <unicode_to_cp1251+0xb5>
cmp    $0x22,%dil
jne    11a9 <unicode_to_cp1251+0xa9>
mov    $0x99,%al
ret
xor    %eax,%eax
ret
mov    $0x5e,%al
ret
mov    $0x23,%al
ret
mov    $0x40,%al
ret
mov    $0x65,%al
ret
mov    $0x97,%al
ret
mov    $0x2d,%al
ret
mov    $0x91,%al
ret
mov    $0x92,%al
ret
mov    $0x82,%al
ret
mov    $0x93,%al
ret
mov    $0x94,%al
ret
mov    $0x84,%al
ret
mov    $0x86,%al
ret
mov    $0x87,%al
ret
mov    $0x95,%al
ret
mov    $0x85,%al
ret
mov    $0xa,%al
ret
mov    $0x89,%al
ret
mov    $0x27,%al
ret
mov    $0x8b,%al
ret
mov    $0x9b,%al
ret

LLVM IR (-O0):
@unicode_to_cp1251.tab0 = internal global <{ [216 x i8], [40 x i8] }> <{ [216 x i8] c"\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\7F\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\98\00\00\00\00\00\00\00\A0\00\00\00\A4\00\A6\A7\00\A9\00\AB\AC\AD\AE\00\B0\B1\00\00\00\B5\B6\B7\00\00\00\BB\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00x", [40 x i8] zeroinitializer }>
define zeroext i8 @unicode_to_cp1251(i16 zeroext %0) {
%2 = alloca i8
%3 = alloca i16
store i16 %0, i16* %3
%4 = load i16, i16* %3
%5 = zext i16 %4 to i32
%6 = ashr i32 %5, 8
switch i32 %6, label %158 [
i32 0, label %7
i32 4, label %12
i32 32, label %111
i32 33, label %135
i32 34, label %144
i32 37, label %152
]
7: ; preds = %1
%8 = load i16, i16* %3
%9 = zext i16 %8 to i64
%10 = getelementptr inbounds [256 x i8], [256 x i8]* bitcast (<{ [216 x i8], [40 x i8] }>* @unicode_to_cp1251.tab0 to [256 x i8]*), i64 0, i64 %9
%11 = load i8, i8* %10
store i8 %11, i8* %2
br label %159
12: ; preds = %1
%13 = load i16, i16* %3
%14 = trunc i16 %13 to i8
%15 = zext i8 %14 to i32
switch i32 %15, label %110 [
i32 1, label %16
i32 2, label %17
i32 3, label %18
i32 4, label %19
i32 5, label %20
i32 6, label %21
i32 7, label %22
i32 8, label %23
i32 9, label %24
i32 10, label %25
i32 11, label %26
i32 12, label %27
i32 14, label %28
i32 15, label %29
i32 16, label %30
i32 17, label %31
i32 18, label %32
i32 19, label %33
i32 20, label %34
i32 21, label %35
i32 22, label %36
i32 23, label %37
i32 24, label %38
i32 25, label %39
i32 26, label %40
i32 27, label %41
i32 28, label %42
i32 29, label %43
i32 30, label %44
i32 31, label %45
i32 32, label %46
i32 33, label %47
i32 34, label %48
i32 35, label %49
i32 36, label %50
i32 37, label %51
i32 38, label %52
i32 39, label %53
i32 40, label %54
i32 41, label %55
i32 42, label %56
i32 43, label %57
i32 44, label %58
i32 45, label %59
i32 46, label %60
i32 47, label %61
i32 48, label %62
i32 49, label %63
i32 50, label %64
i32 51, label %65
i32 52, label %66
i32 53, label %67
i32 54, label %68
i32 55, label %69
i32 56, label %70
i32 57, label %71
i32 58, label %72
i32 59, label %73
i32 60, label %74
i32 61, label %75
i32 62, label %76
i32 63, label %77
i32 64, label %78
i32 65, label %79
i32 66, label %80
i32 67, label %81
i32 68, label %82
i32 69, label %83
i32 70, label %84
i32 71, label %85
i32 72, label %86
i32 73, label %87
i32 74, label %88
i32 75, label %89
i32 76, label %90
i32 77, label %91
i32 78, label %92
i32 79, label %93
i32 81, label %94
i32 82, label %95
i32 83, label %96
i32 84, label %97
i32 85, label %98
i32 86, label %99
i32 87, label %100
i32 88, label %101
i32 89, label %102
i32 90, label %103
i32 91, label %104
i32 92, label %105
i32 94, label %106
i32 95, label %107
i32 144, label %108
i32 145, label %109
]
16: ; preds = %12
store i8 -88, i8* %2
br label %159
17: ; preds = %12
store i8 -128, i8* %2
br label %159
18: ; preds = %12
store i8 -127, i8* %2
br label %159
19: ; preds = %12
store i8 -86, i8* %2
br label %159
20: ; preds = %12
store i8 -67, i8* %2
br label %159
21: ; preds = %12
store i8 -78, i8* %2
br label %159
22: ; preds = %12
store i8 -81, i8* %2
br label %159
23: ; preds = %12
store i8 -93, i8* %2
br label %159
24: ; preds = %12
store i8 -118, i8* %2
br label %159
25: ; preds = %12
store i8 -116, i8* %2
br label %159
26: ; preds = %12
store i8 -114, i8* %2
br label %159
27: ; preds = %12
store i8 -115, i8* %2
br label %159
28: ; preds = %12
store i8 -95, i8* %2
br label %159
29: ; preds = %12
store i8 -113, i8* %2
br label %159
30: ; preds = %12
store i8 -64, i8* %2
br label %159
31: ; preds = %12
store i8 -63, i8* %2
br label %159
32: ; preds = %12
store i8 -62, i8* %2
br label %159
33: ; preds = %12
store i8 -61, i8* %2
br label %159
34: ; preds = %12
store i8 -60, i8* %2
br label %159
35: ; preds = %12
store i8 -59, i8* %2
br label %159
36: ; preds = %12
store i8 -58, i8* %2
br label %159
37: ; preds = %12
store i8 -57, i8* %2
br label %159
38: ; preds = %12
store i8 -56, i8* %2
br label %159
39: ; preds = %12
store i8 -55, i8* %2
br label %159
40: ; preds = %12
store i8 -54, i8* %2
br label %159
41: ; preds = %12
store i8 -53, i8* %2
br label %159
42: ; preds = %12
store i8 -52, i8* %2
br label %159
43: ; preds = %12
store i8 -51, i8* %2
br label %159
44: ; preds = %12
store i8 -50, i8* %2
br label %159
45: ; preds = %12
store i8 -49, i8* %2
br label %159
46: ; preds = %12
store i8 -48, i8* %2
br label %159
47: ; preds = %12
store i8 -47, i8* %2
br label %159
48: ; preds = %12
store i8 -46, i8* %2
br label %159
49: ; preds = %12
store i8 -45, i8* %2
br label %159
50: ; preds = %12
store i8 -44, i8* %2
br label %159
51: ; preds = %12
store i8 -43, i8* %2
br label %159
52: ; preds = %12
store i8 -42, i8* %2
br label %159
53: ; preds = %12
store i8 -41, i8* %2
br label %159
54: ; preds = %12
store i8 -40, i8* %2
br label %159
55: ; preds = %12
store i8 -39, i8* %2
br label %159
56: ; preds = %12
store i8 -38, i8* %2
br label %159
57: ; preds = %12
store i8 -37, i8* %2
br label %159
58: ; preds = %12
store i8 -36, i8* %2
br label %159
59: ; preds = %12
store i8 -35, i8* %2
br label %159
60: ; preds = %12
store i8 -34, i8* %2
br label %159
61: ; preds = %12
store i8 -33, i8* %2
br label %159
62: ; preds = %12
store i8 -32, i8* %2
br label %159
63: ; preds = %12
store i8 -31, i8* %2
br label %159
64: ; preds = %12
store i8 -30, i8* %2
br label %159
65: ; preds = %12
store i8 -29, i8* %2
br label %159
66: ; preds = %12
store i8 -28, i8* %2
br label %159
67: ; preds = %12
store i8 -27, i8* %2
br label %159
68: ; preds = %12
store i8 -26, i8* %2
br label %159
69: ; preds = %12
store i8 -25, i8* %2
br label %159
70: ; preds = %12
store i8 -24, i8* %2
br label %159
71: ; preds = %12
store i8 -23, i8* %2
br label %159
72: ; preds = %12
store i8 -22, i8* %2
br label %159
73: ; preds = %12
store i8 -21, i8* %2
br label %159
74: ; preds = %12
store i8 -20, i8* %2
br label %159
75: ; preds = %12
store i8 -19, i8* %2
br label %159
76: ; preds = %12
store i8 -18, i8* %2
br label %159
77: ; preds = %12
store i8 -17, i8* %2
br label %159
78: ; preds = %12
store i8 -16, i8* %2
br label %159
79: ; preds = %12
store i8 -15, i8* %2
br label %159
80: ; preds = %12
store i8 -14, i8* %2
br label %159
81: ; preds = %12
store i8 -13, i8* %2
br label %159
82: ; preds = %12
store i8 -12, i8* %2
br label %159
83: ; preds = %12
store i8 -11, i8* %2
br label %159
84: ; preds = %12
store i8 -10, i8* %2
br label %159
85: ; preds = %12
store i8 -9, i8* %2
br label %159
86: ; preds = %12
store i8 -8, i8* %2
br label %159
87: ; preds = %12
store i8 -7, i8* %2
br label %159
88: ; preds = %12
store i8 -6, i8* %2
br label %159
89: ; preds = %12
store i8 -5, i8* %2
br label %159
90: ; preds = %12
store i8 -4, i8* %2
br label %159
91: ; preds = %12
store i8 -3, i8* %2
br label %159
92: ; preds = %12
store i8 -2, i8* %2
br label %159
93: ; preds = %12
store i8 -1, i8* %2
br label %159
94: ; preds = %12
store i8 -72, i8* %2
br label %159
95: ; preds = %12
store i8 -112, i8* %2
br label %159
96: ; preds = %12
store i8 -125, i8* %2
br label %159
97: ; preds = %12
store i8 -70, i8* %2
br label %159
98: ; preds = %12
store i8 -66, i8* %2
br label %159
99: ; preds = %12
store i8 -77, i8* %2
br label %159
100: ; preds = %12
store i8 -65, i8* %2
br label %159
101: ; preds = %12
store i8 -68, i8* %2
br label %159
102: ; preds = %12
store i8 -102, i8* %2
br label %159
103: ; preds = %12
store i8 -100, i8* %2
br label %159
104: ; preds = %12
store i8 -98, i8* %2
br label %159
105: ; preds = %12
store i8 -99, i8* %2
br label %159
106: ; preds = %12
store i8 -94, i8* %2
br label %159
107: ; preds = %12
store i8 -97, i8* %2
br label %159
108: ; preds = %12
store i8 -91, i8* %2
br label %159
109: ; preds = %12
store i8 -76, i8* %2
br label %159
110: ; preds = %12
br label %158
111: ; preds = %1
%112 = load i16, i16* %3
%113 = trunc i16 %112 to i8
%114 = zext i8 %113 to i32
switch i32 %114, label %134 [
i32 19, label %115
i32 20, label %116
i32 21, label %117
i32 24, label %118
i32 25, label %119
i32 26, label %120
i32 28, label %121
i32 29, label %122
i32 30, label %123
i32 32, label %124
i32 33, label %125
i32 34, label %126
i32 38, label %127
i32 40, label %128
i32 48, label %129
i32 50, label %130
i32 57, label %131
i32 58, label %132
i32 172, label %133
]
115: ; preds = %111
store i8 -106, i8* %2
br label %159
116: ; preds = %111
store i8 -105, i8* %2
br label %159
117: ; preds = %111
store i8 45, i8* %2
br label %159
118: ; preds = %111
store i8 -111, i8* %2
br label %159
119: ; preds = %111
store i8 -110, i8* %2
br label %159
120: ; preds = %111
store i8 -126, i8* %2
br label %159
121: ; preds = %111
store i8 -109, i8* %2
br label %159
122: ; preds = %111
store i8 -108, i8* %2
br label %159
123: ; preds = %111
store i8 -124, i8* %2
br label %159
124: ; preds = %111
store i8 -122, i8* %2
br label %159
125: ; preds = %111
store i8 -121, i8* %2
br label %159
126: ; preds = %111
store i8 -107, i8* %2
br label %159
127: ; preds = %111
store i8 -123, i8* %2
br label %159
128: ; preds = %111
store i8 10, i8* %2
br label %159
129: ; preds = %111
store i8 -119, i8* %2
br label %159
130: ; preds = %111
store i8 39, i8* %2
br label %159
131: ; preds = %111
store i8 -117, i8* %2
br label %159
132: ; preds = %111
store i8 -101, i8* %2
br label %159
133: ; preds = %111
store i8 -120, i8* %2
br label %159
134: ; preds = %111
br label %158
135: ; preds = %1
%136 = load i16, i16* %3
%137 = trunc i16 %136 to i8
%138 = zext i8 %137 to i32
switch i32 %138, label %143 [
i32 22, label %139
i32 34, label %140
i32 47, label %141
i32 145, label %142
]
139: ; preds = %135
store i8 -71, i8* %2
br label %159
140: ; preds = %135
store i8 -103, i8* %2
br label %159
141: ; preds = %135
store i8 101, i8* %2
br label %159
142: ; preds = %135
store i8 64, i8* %2
br label %159
143: ; preds = %135
br label %158
144: ; preds = %1
%145 = load i16, i16* %3
%146 = trunc i16 %145 to i8
%147 = zext i8 %146 to i32
switch i32 %147, label %151 [
i32 39, label %148
i32 40, label %149
i32 96, label %150
]
148: ; preds = %144
store i8 94, i8* %2
br label %159
149: ; preds = %144
store i8 118, i8* %2
br label %159
150: ; preds = %144
store i8 35, i8* %2
br label %159
151: ; preds = %144
br label %158
152: ; preds = %1
%153 = load i16, i16* %3
%154 = trunc i16 %153 to i8
%155 = zext i8 %154 to i32
switch i32 %155, label %157 [
i32 202, label %156
]
156: ; preds = %152
store i8 36, i8* %2
br label %159
157: ; preds = %152
br label %158
158: ; preds = %1, %157, %151, %143, %134, %110
store i8 0, i8* %2
br label %159
159: ; preds = %158, %156, %150, %149, %148, %142, %141, %140, %139, %133, %132, %131, %130, %129, %128, %127, %126, %125, %124, %123, %122, %121, %120, %119, %118, %117, %116, %115, %109, %108, %107, %106, %105, %104, %103, %102, %101, %100, %99, %98, %97, %96, %95, %94, %93, %92, %91, %90, %89, %88, %87, %86, %85, %84, %83, %82, %81, %80, %79, %78, %77, %76, %75, %74, %73, %72, %71, %70, %69, %68, %67, %66, %65, %64, %63, %62, %61, %60, %59, %58, %57, %56, %55, %54, %53, %52, %51, %50, %49, %48, %47, %46, %45, %44, %43, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %7
%160 = load i8, i8* %2
ret i8 %160
}

LLVM IR (-O2):
@unicode_to_cp1251.tab0 = internal unnamed_addr constant <{ [216 x i8], [40 x i8] }> <{ [216 x i8] c"\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\7F\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\98\00\00\00\00\00\00\00\A0\00\00\00\A4\00\A6\A7\00\A9\00\AB\AC\AD\AE\00\B0\B1\00\00\00\B5\B6\B7\00\00\00\BB\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00x", [40 x i8] zeroinitializer }>
@switch.table.unicode_to_cp1251 = [208 x i8] c"\A5\B4\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\A8\80\81\AA\BD\B2\AF\A3\8A\8C\8E\8D\00\A1\8F\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF\00\B8\90\83\BA\BE\B3\BF\BC\9A\9C\9E\9D\00\A2\9F"
define zeroext i8 @unicode_to_cp1251(i16 zeroext %0) {
%2 = lshr i16 %0, 8
%3 = trunc i16 %2 to i8
switch i8 %3, label %44 [
i8 0, label %4
i8 4, label %8
i8 32, label %12
i8 33, label %32
i8 34, label %37
i8 37, label %41
]
4: ; preds = %1
%5 = zext i16 %0 to i64
%6 = getelementptr inbounds [256 x i8], [256 x i8]* bitcast (<{ [216 x i8], [40 x i8] }>* @unicode_to_cp1251.tab0 to [256 x i8]*), i64 0, i64 %5
%7 = load i8, i8* %6
br label %49
8: ; preds = %1
%9 = trunc i16 %0 to i8
%10 = add i8 %9, 112
%11 = icmp ult i8 %10, -48
br i1 %11, label %45, label %44
12: ; preds = %1
%13 = trunc i16 %0 to i8
switch i8 %13, label %44 [
i8 19, label %49
i8 20, label %14
i8 21, label %15
i8 24, label %16
i8 25, label %17
i8 26, label %18
i8 28, label %19
i8 29, label %20
i8 30, label %21
i8 32, label %22
i8 33, label %23
i8 34, label %24
i8 38, label %25
i8 40, label %26
i8 48, label %27
i8 50, label %28
i8 57, label %29
i8 58, label %30
i8 -84, label %31
]
14: ; preds = %12
br label %49
15: ; preds = %12
br label %49
16: ; preds = %12
br label %49
17: ; preds = %12
br label %49
18: ; preds = %12
br label %49
19: ; preds = %12
br label %49
20: ; preds = %12
br label %49
21: ; preds = %12
br label %49
22: ; preds = %12
br label %49
23: ; preds = %12
br label %49
24: ; preds = %12
br label %49
25: ; preds = %12
br label %49
26: ; preds = %12
br label %49
27: ; preds = %12
br label %49
28: ; preds = %12
br label %49
29: ; preds = %12
br label %49
30: ; preds = %12
br label %49
31: ; preds = %12
br label %49
32: ; preds = %1
%33 = trunc i16 %0 to i8
switch i8 %33, label %44 [
i8 22, label %49
i8 34, label %34
i8 47, label %35
i8 -111, label %36
]
34: ; preds = %32
br label %49
35: ; preds = %32
br label %49
36: ; preds = %32
br label %49
37: ; preds = %1
%38 = trunc i16 %0 to i8
switch i8 %38, label %44 [
i8 39, label %49
i8 40, label %39
i8 96, label %40
]
39: ; preds = %37
br label %49
40: ; preds = %37
br label %49
41: ; preds = %1
%42 = and i16 %0, 255
%43 = icmp eq i16 %42, 202
br i1 %43, label %49, label %44
44: ; preds = %8, %41, %37, %32, %12, %1
br label %49
45: ; preds = %8
%46 = zext i8 %10 to i64
%47 = getelementptr inbounds [208 x i8], [208 x i8]* @switch.table.unicode_to_cp1251, i64 0, i64 %46
%48 = load i8, i8* %47
br label %49
49: ; preds = %45, %41, %37, %32, %12, %44, %40, %39, %36, %35, %34, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %4
%50 = phi i8 [ 0, %44 ], [ 35, %40 ], [ 118, %39 ], [ 64, %36 ], [ 101, %35 ], [ -103, %34 ], [ -120, %31 ], [ -101, %30 ], [ -117, %29 ], [ 39, %28 ], [ -119, %27 ], [ 10, %26 ], [ -123, %25 ], [ -107, %24 ], [ -121, %23 ], [ -122, %22 ], [ -124, %21 ], [ -108, %20 ], [ -109, %19 ], [ -126, %18 ], [ -110, %17 ], [ -111, %16 ], [ 45, %15 ], [ -105, %14 ], [ %7, %4 ], [ -106, %12 ], [ -71, %32 ], [ 94, %37 ], [ 36, %41 ], [ %48, %45 ]
ret i8 %50
}