// File: besm6[P]pascal-re/pascompl.cc
// Function: unicode_to_koi8(int)
static unsigned char
unicode_to_koi8(int val)
{
    static std::map<int, unsigned char> uni2koi8;
    if (uni2koi8.empty()) {
        static wchar_t cyr[] = L"юабцдефгхийклмнопярстужвьызшэщчъ"
                               L"ЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ";
        for (int i = 0; cyr[i]; ++i)
            uni2koi8[cyr[i]] = (unsigned char)(i + 0300);
        uni2koi8[L'×'] = 6;
        uni2koi8[L'#'] = uni2koi8[L'≠'] = 030;
        uni2koi8[L'≤'] = 016;
        uni2koi8[L'≥'] = 017;
        uni2koi8[L'≡'] = 027;
        uni2koi8[L'÷'] = 032;
        uni2koi8[L'∨'] = 036;
        uni2koi8[L'~'] = 037;
    }
    if (uni2koi8.count(val))
        return uni2koi8[val];
    else if (val < 0177)
        return (unsigned char)val;
    else return ' ';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
cmpb $0x0, 0xbb296(%rip)     # 0xd8b28
jne 0x1d8d7
leaq 0xbb28d(%rip), %rdi     # 0xd8b28
callq 0x4500
cmpl $0x0, %eax
je 0x1d8d7
leaq 0xbb24c(%rip), %rdi     # 0xd8af8
callq 0x24610
leaq 0x6d78(%rip), %rdi      # 0x24630
leaq 0xbb239(%rip), %rsi     # 0xd8af8
leaq 0x21a02(%rip), %rdx     # 0x3f2c8
callq 0x4260
leaq 0xbb256(%rip), %rdi     # 0xd8b28
callq 0x4180
leaq 0xbb21a(%rip), %rdi     # 0xd8af8
callq 0x24650
testb $0x1, %al
jne 0x1d8ec
jmp 0x1da2a
movl $0x0, -0xc(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x22442(%rip), %rax     # 0x3fd40
cmpl $0x0, (%rax,%rcx,4)
je 0x1d940
movl -0xc(%rbp), %eax
addl $0xc0, %eax
movb %al, -0x35(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x22426(%rip), %rax     # 0x3fd40
movl (%rax,%rcx,4), %eax
movl %eax, -0x10(%rbp)
leaq 0xbb1d1(%rip), %rdi     # 0xd8af8
leaq -0x10(%rbp), %rsi
callq 0x24670
movb -0x35(%rbp), %cl
movb %cl, (%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1d8f3
movl $0xd7, -0x14(%rbp)
leaq 0xbb1aa(%rip), %rdi     # 0xd8af8
leaq -0x14(%rbp), %rsi
callq 0x24670
movb $0x6, (%rax)
movl $0x2260, -0x18(%rbp)    # imm = 0x2260
leaq 0xbb190(%rip), %rdi     # 0xd8af8
leaq -0x18(%rbp), %rsi
callq 0x24670
movb $0x18, (%rax)
movl $0x23, -0x1c(%rbp)
leaq 0xbb176(%rip), %rdi     # 0xd8af8
leaq -0x1c(%rbp), %rsi
callq 0x24670
movb $0x18, (%rax)
movl $0x2264, -0x20(%rbp)    # imm = 0x2264
leaq 0xbb15c(%rip), %rdi     # 0xd8af8
leaq -0x20(%rbp), %rsi
callq 0x24670
movb $0xe, (%rax)
movl $0x2265, -0x24(%rbp)    # imm = 0x2265
leaq 0xbb142(%rip), %rdi     # 0xd8af8
leaq -0x24(%rbp), %rsi
callq 0x24670
movb $0xf, (%rax)
movl $0x2261, -0x28(%rbp)    # imm = 0x2261
leaq 0xbb128(%rip), %rdi     # 0xd8af8
leaq -0x28(%rbp), %rsi
callq 0x24670
movb $0x17, (%rax)
movl $0xf7, -0x2c(%rbp)
leaq 0xbb10e(%rip), %rdi     # 0xd8af8
leaq -0x2c(%rbp), %rsi
callq 0x24670
movb $0x1a, (%rax)
movl $0x2228, -0x30(%rbp)    # imm = 0x2228
leaq 0xbb0f4(%rip), %rdi     # 0xd8af8
leaq -0x30(%rbp), %rsi
callq 0x24670
movb $0x1e, (%rax)
movl $0x7e, -0x34(%rbp)
leaq 0xbb0da(%rip), %rdi     # 0xd8af8
leaq -0x34(%rbp), %rsi
callq 0x24670
movb $0x1f, (%rax)
leaq 0xbb0c7(%rip), %rdi     # 0xd8af8
leaq -0x8(%rbp), %rsi
callq 0x24750
cmpq $0x0, %rax
je 0x1da57
leaq 0xbb0b1(%rip), %rdi     # 0xd8af8
leaq -0x8(%rbp), %rsi
callq 0x247b0
movb (%rax), %al
movb %al, -0x1(%rbp)
jmp 0x1da69
cmpl $0x7f, -0x8(%rbp)
jge 0x1da65
movl -0x8(%rbp), %eax
movb %al, -0x1(%rbp)
jmp 0x1da69
movb $0x20, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)