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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int rus_char_to_koi8_byte(int);
int rus_char_to_win1251_byte(int);
void send_char(int c, FILE *output_stream, int output_encoding) {
  assert(c >= 0);
  if (((0x410 <= (c) && (c) <= 0x44f) || (c) == 0x401 || (c) == 0x451)) {
    switch (output_encoding) {
    case 1:
      putc(0xC0 | (c >> 6), output_stream);
      c = 0x80 | (0x3F & c);
      break;
    case 2:
      c -= 0x400 - 0xa0;
      break;
    case 3:
      c = rus_char_to_koi8_byte(c);
      break;
    case 4:
      c = rus_char_to_win1251_byte(c);
      break;
    }
  }
  putc(0xFF & c, output_stream);
}


x86 assembly (clang, -O0):
<send_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x410,%eax
cmp    -0x4(%rbp),%eax
jg     117e <send_char+0x3e>
cmpl   $0x44f,-0x4(%rbp)
jle    1198 <send_char+0x58>
cmpl   $0x401,-0x4(%rbp)
je     1198 <send_char+0x58>
cmpl   $0x451,-0x4(%rbp)
jne    1219 <send_char+0xd9>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1214 <send_char+0xd4>
mov    -0x20(%rbp),%rax
lea    0xe48(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
sar    $0x6,%edi
or     $0xc0,%edi
mov    -0x10(%rbp),%rsi
call   1040 <putc@plt>
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <send_char+0xd4>
mov    -0x4(%rbp),%eax
sub    $0x360,%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <send_char+0xd4>
mov    -0x4(%rbp),%edi
call   1060 <rus_char_to_koi8_byte@plt>
mov    %eax,-0x4(%rbp)
jmp    1214 <send_char+0xd4>
mov    -0x4(%rbp),%edi
call   1030 <rus_char_to_win1251_byte@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <send_char+0xd9>
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1040 <putc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_char>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edi,%r15d
not    %edi
shr    $0x1f,%edi
call   1050 <assert@plt>
lea    -0x410(%r15),%eax
cmp    $0x40,%eax
jb     1175 <send_char+0x35>
cmp    $0x451,%r15d
je     1175 <send_char+0x35>
cmp    $0x401,%r15d
jne    11cc <send_char+0x8c>
add    $0xffffffff,%ebx
cmp    $0x3,%ebx
ja     11cc <send_char+0x8c>
lea    0xe7c(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %r15d,%edi
shr    $0x6,%edi
or     $0xc0,%edi
mov    %r14,%rsi
call   1040 <putc@plt>
and    $0x3f,%r15d
or     $0x80,%r15d
jmp    11cc <send_char+0x8c>
add    $0xfffffca0,%r15d
jmp    11cc <send_char+0x8c>
mov    %r15d,%edi
call   1060 <rus_char_to_koi8_byte@plt>
jmp    11c9 <send_char+0x89>
mov    %r15d,%edi
call   1030 <rus_char_to_win1251_byte@plt>
mov    %eax,%r15d
movzbl %r15b,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <putc@plt>

LLVM IR (-O0):
define void @send_char(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i32, i32* %4
%12 = icmp sle i32 1040, %11
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 1103
br i1 %15, label %22, label %16
16: ; preds = %13, %3
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1025
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 1105
br i1 %21, label %22, label %43
22: ; preds = %19, %16, %13
%23 = load i32, i32* %6
switch i32 %23, label %42 [
i32 1, label %24
i32 2, label %33
i32 3, label %36
i32 4, label %39
]
24: ; preds = %22
%25 = load i32, i32* %4
%26 = ashr i32 %25, 6
%27 = or i32 192, %26
%28 = load i32*, i32** %5
%29 = call i32 @putc(i32 %27, i32* %28)
%30 = load i32, i32* %4
%31 = and i32 63, %30
%32 = or i32 128, %31
store i32 %32, i32* %4
br label %42
33: ; preds = %22
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 864
store i32 %35, i32* %4
br label %42
36: ; preds = %22
%37 = load i32, i32* %4
%38 = call i32 @rus_char_to_koi8_byte(i32 %37)
store i32 %38, i32* %4
br label %42
39: ; preds = %22
%40 = load i32, i32* %4
%41 = call i32 @rus_char_to_win1251_byte(i32 %40)
store i32 %41, i32* %4
br label %42
42: ; preds = %22, %39, %36, %33, %24
br label %43
43: ; preds = %42, %19
%44 = load i32, i32* %4
%45 = and i32 255, %44
%46 = load i32*, i32** %5
%47 = call i32 @putc(i32 %45, i32* %46)
ret void
}

LLVM IR (-O2):
define void @send_char(i32 %0, i32* nocapture %1, i32 %2) {
%4 = xor i32 %0, -1
%5 = lshr i32 %4, 31
%6 = tail call i32 @assert(i32 %5)
%7 = add i32 %0, -1040
%8 = icmp ult i32 %7, 64
br i1 %8, label %10, label %9
9: ; preds = %3
switch i32 %0, label %23 [
i32 1105, label %10
i32 1025, label %10
]
10: ; preds = %9, %9, %3
switch i32 %2, label %23 [
i32 1, label %11
i32 2, label %17
i32 3, label %19
i32 4, label %21
]
11: ; preds = %10
%12 = lshr i32 %0, 6
%13 = or i32 %12, 192
%14 = tail call i32 @putc(i32 %13, i32* %1)
%15 = and i32 %0, 63
%16 = or i32 %15, 128
br label %23
17: ; preds = %10
%18 = add nsw i32 %0, -864
br label %23
19: ; preds = %10
%20 = tail call i32 @rus_char_to_koi8_byte(i32 %0)
br label %23
21: ; preds = %10
%22 = tail call i32 @rus_char_to_win1251_byte(i32 %0)
br label %23
23: ; preds = %9, %11, %17, %19, %21, %10
%24 = phi i32 [ %0, %10 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %11 ], [ %0, %9 ]
%25 = and i32 %24, 255
%26 = tail call i32 @putc(i32 %25, i32* %1)
ret void
}