// File: /workspace/github_c_makefile_star2_O1/mloar[P]charset/utf8.c
// Function: write_utf8
int write_utf8(charset_spec const *charset, long int input_chr,
	       charset_state *state,
	       void (*emit)(void *ctx, long int output),
	       void *emitctx)
{
    UNUSEDARG(charset);
    UNUSEDARG(state);

    if (input_chr == -1)
	return TRUE;		       /* stateless; no cleanup required */

    /*
     * Refuse to output any illegal code points.
     */
    if (input_chr == 0xFFFE || input_chr == 0xFFFF ||
	(input_chr >= 0xD800 && input_chr < 0xE000)) {
	return FALSE;
    } else if (input_chr < 0x80) {     /* one-byte character */
	emit(emitctx, input_chr);
	return TRUE;
    } else if (input_chr < 0x800) {    /* two-byte character */
	emit(emitctx, 0xC0 | (0x1F & (input_chr >>  6)));
	emit(emitctx, 0x80 | (0x3F & (input_chr      )));
	return TRUE;
    } else if (input_chr < 0x10000) {  /* three-byte character */
	emit(emitctx, 0xE0 | (0x0F & (input_chr >> 12)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >>  6)));
	emit(emitctx, 0x80 | (0x3F & (input_chr      )));
	return TRUE;
    } else if (input_chr < 0x200000) { /* four-byte character */
	emit(emitctx, 0xF0 | (0x07 & (input_chr >> 18)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >> 12)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >>  6)));
	emit(emitctx, 0x80 | (0x3F & (input_chr      )));
	return TRUE;
    } else if (input_chr < 0x4000000) {/* five-byte character */
	emit(emitctx, 0xF8 | (0x03 & (input_chr >> 24)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >> 18)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >> 12)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >>  6)));
	emit(emitctx, 0x80 | (0x3F & (input_chr      )));
	return TRUE;
    } else {			       /* six-byte character */
	emit(emitctx, 0xFC | (0x01 & (input_chr >> 30)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >> 24)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >> 18)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >> 12)));
	emit(emitctx, 0x80 | (0x3F & (input_chr >>  6)));
	emit(emitctx, 0x80 | (0x3F & (input_chr      )));
	return TRUE;
    }
}

// Assembly:
movl $0x1, %eax
cmpq $-0x1, %rsi
je 0xa15b
pushq %r15
pushq %r14
pushq %rbx
movq %rcx, %rbx
movq %rsi, %r15
movq %rsi, %rax
andq $-0x2, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
sete %cl
movq %rsi, %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0xd800, %rax           # imm = 0xD800
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0xa156
movq %r8, %r14
cmpq $0x80, %r15
jl 0xa149
cmpq $0x800, %r15            # imm = 0x800
jge 0xa082
movl $0xc0, %eax
movl $0x1f, %esi
jmp 0xa12e
cmpq $0x10000, %r15          # imm = 0x10000
jge 0xa097
movl $0xe0, %eax
movl $0xf, %esi
jmp 0xa114
cmpq $0x200000, %r15         # imm = 0x200000
jge 0xa0ac
movl $0xf0, %eax
movl $0x7, %esi
jmp 0xa0fa
cmpq $0x4000000, %r15        # imm = 0x4000000
jge 0xa0c1
movl $0xf8, %eax
movl $0x3, %esi
jmp 0xa0e0
movl %r15d, %esi
shrl $0x1e, %esi
andl $0x1, %esi
orq $0xfc, %rsi
movq %r14, %rdi
callq *%rbx
movl $0x80, %eax
movl $0x3f, %esi
movl %r15d, %ecx
shrl $0x18, %ecx
andl %ecx, %esi
orq %rax, %rsi
movq %r14, %rdi
callq *%rbx
movl $0x80, %eax
movl $0x3f, %esi
movl %r15d, %ecx
shrl $0x12, %ecx
andl %ecx, %esi
orq %rax, %rsi
movq %r14, %rdi
callq *%rbx
movl $0x80, %eax
movl $0x3f, %esi
movl %r15d, %ecx
shrl $0xc, %ecx
andl %ecx, %esi
orq %rax, %rsi
movq %r14, %rdi
callq *%rbx
movl $0x80, %eax
movl $0x3f, %esi
movl %r15d, %ecx
shrl $0x6, %ecx
andl %ecx, %esi
orq %rax, %rsi
movq %r14, %rdi
callq *%rbx
andl $0x3f, %r15d
orq $0x80, %r15
movq %r14, %rdi
movq %r15, %rsi
callq *%rbx
movl $0x1, %eax
popq %rbx
popq %r14
popq %r15
retq