// File: /workspace/github_c_makefile_star2_O0/mloar[P]charset/iso2022.c
// Function: docs_ctext
static void docs_ctext(long int input_chr,
		       charset_state *state,
		       void (*emit)(void *ctx, long int output),
		       void *emitctx)
{
    /*
     * s0[27:26] = first entry in ctext_encodings that matches
     * s0[25:22] = number of characters successfully matched, 0xf if all
     * s0[21:8] count the number of octets left in the segment
     * s0[7:0] are for sub-charset use
     */
    int n = (state->s0 >> 22) & 0xf, i = (state->s0 >> 26) & 3, oi = i, j;
    int length = (state->s0 >> 8) & 0x3fff;

    /*
     * Note that we do not bother checking the octets-per-character
     * byte against the selected charset when reading. It's
     * extremely unlikely that this code will ever have to deal
     * with two charset identifiers with the same name and
     * different octets-per-character values! If it ever happens,
     * we'll have to edit this file anyway so we can modify the
     * code then...
     */

    if (!length) {
	/* Haven't read length yet */
	if ((state->s0 & 0xff) == 0)
	    /* ... or even the first byte */
	    state->s0 |= input_chr;
	else {
	    length = (state->s0 & 0x7f) * 0x80 + (input_chr & 0x7f);
	    if (length == 0)
		state->s0 = 0;
	    else
		state->s0 = (state->s0 & 0xf0000000) | (length << 8);
	}
	return;
    }

    j = i;
    if (n == 0xe) {
	/* Skipping unknown encoding.  Look out for STX. */
	if (input_chr == 2)
	    state->s0 = (state->s0 & 0xf0000000) | (i << 26) | (0xf << 22);
    } else if (n != 0xf) {
	while ((unsigned)j < lenof(ctext_encodings) &&
	       !memcmp(ctext_encodings[j].name,
		       ctext_encodings[oi].name, n)) {
	    if (ctext_encodings[j].name[n] < input_chr)
		i = ++j;
	    else
		break;
	}
	if ((unsigned)i >= lenof(ctext_encodings) ||
	    memcmp(ctext_encodings[i].name,
		   ctext_encodings[oi].name, n) ||
	    ctext_encodings[i].name[n] != input_chr) {
	    /* Doom!  We haven't heard of this encoding */
	    i = lenof(ctext_encodings);
	    n = 0xe;
	} else {
	    /*
	     * Otherwise, we have found an additional character in our
	     * encoding name. See if we have reached the _end_ of our
	     * name.
	     */
	    n++;
	    if (!ctext_encodings[i].name[n])
		n = 0xf;
	}
	/*
	 * Failing _that_, we simply update our encoding-name-
	 * tracking state.
	 */
	assert(i < 4 && n < 16);
	state->s0 = (state->s0 & 0xf0000000) | (i << 26) | (n << 22);
    } else {
	if ((unsigned)i >= lenof(ctext_encodings))
	    emit(emitctx, ERROR);
	else {
	    charset_state substate;
	    charset_spec const *subcs = ctext_encodings[i].subcs;
	    substate.s1 = 0;
	    substate.s0 = state->s0 & 0xff;
	    subcs->read(subcs, input_chr, &substate, emit, emitctx);
	    state->s0 = (state->s0 & ~0xff) | (substate.s0 & 0xff);
	}
    }
    if (!--length)
	state->s0 = 0;
    else
	state->s0 = (state->s0 &~0x003fff00) | (length << 8);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
shrq $0x16, %rax
andq $0xf, %rax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
shrq $0x1a, %rax
andq $0x3, %rax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
shrq $0x8, %rax
andq $0x3fff, %rax           # imm = 0x3FFF
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x91e9
movq -0x10(%rbp), %rax
movq (%rax), %rax
andq $0xff, %rax
cmpq $0x0, %rax
jne 0x918f
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x91e4
movq -0x10(%rbp), %rax
movq (%rax), %rax
andq $0x7f, %rax
shlq $0x7, %rax
movq -0x8(%rbp), %rcx
andq $0x7f, %rcx
addq %rcx, %rax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x91bf
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
jmp 0x91e2
movq -0x10(%rbp), %rax
movabsq $0xf0000000, %rcx       # imm = 0xF0000000
andq (%rax), %rcx
movl -0x34(%rbp), %eax
shll $0x8, %eax
cltq
orq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x91e4
jmp 0x9499
movl -0x28(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpl $0xe, -0x24(%rbp)
jne 0x922b
cmpq $0x2, -0x8(%rbp)
jne 0x9226
movq -0x10(%rbp), %rax
movabsq $0xf0000000, %rcx       # imm = 0xF0000000
andq (%rax), %rcx
movl -0x28(%rbp), %eax
shll $0x1a, %eax
cltq
orq %rax, %rcx
orq $0x3c00000, %rcx        # imm = 0x3C00000
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x945e
cmpl $0xf, -0x24(%rbp)
je 0x93cd
jmp 0x9237
movl -0x30(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq $0x3, %rcx
movb %al, -0x51(%rbp)
jae 0x9285
movslq -0x30(%rbp), %rcx
leaq 0xa066e(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movslq -0x2c(%rbp), %rcx
leaq 0xa0659(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movslq -0x24(%rbp), %rdx
callq 0x6060
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x928e
jmp 0x92c7
movslq -0x30(%rbp), %rcx
leaq 0xa0627(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsbq (%rax,%rcx), %rax
cmpq -0x8(%rbp), %rax
jge 0x92c0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl %eax, -0x28(%rbp)
jmp 0x92c2
jmp 0x92c7
jmp 0x9237
movl -0x28(%rbp), %eax
cmpq $0x3, %rax
jae 0x932c
movslq -0x28(%rbp), %rcx
leaq 0xa05e5(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movslq -0x2c(%rbp), %rcx
leaq 0xa05d0(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movslq -0x24(%rbp), %rdx
callq 0x6060
cmpl $0x0, %eax
jne 0x932c
movslq -0x28(%rbp), %rcx
leaq 0xa05ad(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsbq (%rax,%rcx), %rax
cmpq -0x8(%rbp), %rax
je 0x933c
movl $0x3, -0x28(%rbp)
movl $0xe, -0x24(%rbp)
jmp 0x936d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movslq -0x28(%rbp), %rcx
leaq 0xa0570(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0x936b
movl $0xf, -0x24(%rbp)
jmp 0x936d
cmpl $0x4, -0x28(%rbp)
jge 0x937b
cmpl $0x10, -0x24(%rbp)
jge 0x937b
jmp 0x939a
leaq 0x55748(%rip), %rdi     # 0x5eaca
leaq 0x55678(%rip), %rsi     # 0x5ea01
movl $0x1ea, %edx            # imm = 0x1EA
leaq 0x55745(%rip), %rcx     # 0x5eada
callq 0x6050
movq -0x10(%rbp), %rax
movabsq $0xf0000000, %rcx       # imm = 0xF0000000
andq (%rax), %rcx
movl -0x28(%rbp), %eax
shll $0x1a, %eax
cltq
orq %rax, %rcx
movl -0x24(%rbp), %eax
shll $0x16, %eax
cltq
orq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x945c
movl -0x28(%rbp), %eax
cmpq $0x3, %rax
jb 0x93e7
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq *%rax
jmp 0x945a
movslq -0x28(%rbp), %rcx
leaq 0xa04ce(%rip), %rax     # 0xa98c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
andq $0xff, %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x50(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq -0x48(%rbp), %rdx
callq *%rax
movq -0x10(%rbp), %rax
movq (%rax), %rcx
andq $-0x100, %rcx
movq -0x48(%rbp), %rax
andq $0xff, %rax
orq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x945c
jmp 0x945e
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, %eax
jne 0x9479
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
jmp 0x9499
movq -0x10(%rbp), %rax
movq (%rax), %rcx
andq $-0x3fff01, %rcx        # imm = 0xFFC000FF
movl -0x34(%rbp), %eax
shll $0x8, %eax
cltq
orq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
addq $0x60, %rsp
popq %rbp
retq
nop