// File: /workspace/github_c_makefile_star2_O1/nurse[P]nkf/nkf.c
// Function: s2e_conv
static nkf_char
s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
{
#if defined(SHIFTJIS_CP932) || defined(X0212_ENABLE)
    nkf_char val;
#endif
    static const char shift_jisx0213_s1a3_table[5][2] ={ { 1, 8}, { 3, 4}, { 5,12}, {13,14}, {15, 0} };
    if (0xFC < c1) return 1;
#ifdef SHIFTJIS_CP932
    if (!cp932inv_f && !x0213_f && is_ibmext_in_sjis(c2)){
	val = shiftjis_cp932[c2 - CP932_TABLE_BEGIN][c1 - 0x40];
	if (val){
	    c2 = val >> 8;
	    c1 = val & 0xff;
	}
    }
    if (cp932inv_f
	&& CP932INV_TABLE_BEGIN <= c2 && c2 <= CP932INV_TABLE_END){
	val = cp932inv[c2 - CP932INV_TABLE_BEGIN][c1 - 0x40];
	if (val){
	    c2 = val >> 8;
	    c1 = val & 0xff;
	}
    }
#endif /* SHIFTJIS_CP932 */
#ifdef X0212_ENABLE
    if (!x0213_f && is_ibmext_in_sjis(c2)){
	val = shiftjis_x0212[c2 - 0xfa][c1 - 0x40];
	if (val){
	    if (val > 0x7FFF){
		c2 = PREFIX_EUCG3 | ((val >> 8) & 0x7f);
		c1 = val & 0xff;
	    }else{
		c2 = val >> 8;
		c1 = val & 0xff;
	    }
	    if (p2) *p2 = c2;
	    if (p1) *p1 = c1;
	    return 0;
	}
    }
#endif
    if(c2 >= 0x80){
	if(x0213_f && c2 >= 0xF0){
	    if(c2 <= 0xF3 || (c2 == 0xF4 && c1 < 0x9F)){ /* k=1, 3<=k<=5, k=8, 12<=k<=15 */
		c2 = PREFIX_EUCG3 | 0x20 | shift_jisx0213_s1a3_table[c2 - 0xF0][0x9E < c1];
	    }else{ /* 78<=k<=94 */
		c2 = PREFIX_EUCG3 | (c2 * 2 - 0x17B);
		if (0x9E < c1) c2++;
	    }
	}else{
#define         SJ0162  0x00e1          /* 01 - 62 ku offset */
#define         SJ6394  0x0161          /* 63 - 94 ku offset */
	    c2 = c2 + c2 - ((c2 <= 0x9F) ? SJ0162 : SJ6394);
	    if (0x9E < c1) c2++;
	}
	if (c1 < 0x9F)
	    c1 = c1 - ((c1 > DEL) ? SP : 0x1F);
	else {
	    c1 = c1 - 0x7E;
	}
    }

#ifdef X0212_ENABLE
    c2 = x0212_unshift(c2);
#endif
    if (p2) *p2 = c2;
    if (p1) *p1 = c1;
    return 0;
}

// Assembly:
movl $0x1, %eax
cmpl $0xfc, %esi
jg 0x11290
movl 0x3c205(%rip), %r8d     # 0x4d2c0
testl %r8d, %r8d
setne %r9b
movb 0x3c2f4(%rip), %al      # 0x4d3bc
leal -0xfd(%rdi), %r10d
cmpl $-0x3, %r10d
setb %r10b
orb %al, %r10b
orb %r9b, %r10b
testb $0x1, %r10b
jne 0x11110
leal -0xfa(%rdi), %r9d
movslq %esi, %r10
imulq $0x17a, %r9, %r9        # imm = 0x17A
addq 0x3bee5(%rip), %r9      # 0x4cfe0
movzwl -0x80(%r9,%r10,2), %r9d
testl %r9d, %r9d
je 0x11110
movl %r9d, %edi
shrl $0x8, %edi
movzbl %r9b, %esi
testl %r8d, %r8d
je 0x1114b
leal -0xed(%rdi), %r8d
cmpl $0x1, %r8d
ja 0x1114b
movl %r8d, %r8d
movslq %esi, %r9
imulq $0x17a, %r8, %r8        # imm = 0x17A
addq 0x3be8a(%rip), %r8      # 0x4cfc0
movzwl -0x80(%r8,%r9,2), %r8d
testl %r8d, %r8d
je 0x1114b
movl %r8d, %edi
shrl $0x8, %edi
movzbl %r8b, %esi
leal -0xfd(%rdi), %r8d
cmpl $-0x3, %r8d
setb %r8b
orb %al, %r8b
testb $0x1, %r8b
jne 0x111b7
leal -0xfa(%rdi), %r8d
movslq %esi, %r9
imulq $0x17a, %r8, %r8        # imm = 0x17A
addq 0x3be55(%rip), %r8      # 0x4cfd0
movzwl -0x80(%r8,%r9,2), %r8d
testl %r8d, %r8d
je 0x111b7
testq %rdx, %rdx
je 0x111a5
movl %r8d, %eax
shrl $0x8, %eax
movl %eax, %esi
andl $0x7f, %esi
orl $0x8f00, %esi           # imm = 0x8F00
testw %r8w, %r8w
cmovnsl %eax, %esi
movl %esi, (%rdx)
testq %rcx, %rcx
je 0x1128e
movzbl %r8b, %esi
jmp 0x1128c
cmpl $0x80, %edi
jl 0x1125f
cmpl $0xf0, %edi
setl %r8b
notb %al
orb %r8b, %al
testb $0x1, %al
jne 0x1121e
cmpl $0xf4, %edi
jl 0x111f6
cmpl $0x9e, %esi
jg 0x11291
cmpl $0xf4, %edi
jne 0x11291
addl $0xffffff10, %edi       # imm = 0xFFFFFF10
xorl %eax, %eax
cmpl $0x9f, %esi
setge %al
leaq 0x610a(%rip), %r8       # 0x17318
leaq (%r8,%rdi,2), %rdi
movsbl (%rax,%rdi), %edi
orl $0x8f20, %edi           # imm = 0x8F20
jmp 0x11245
xorl %eax, %eax
cmpl $0xa0, %edi
setl %al
shll $0x7, %eax
xorl %r8d, %r8d
cmpl $0x9f, %esi
setge %r8b
leal (%r8,%rdi,2), %edi
addl %eax, %edi
addl $0xfffffe9f, %edi       # imm = 0xFFFFFE9F
cmpl $0x9e, %esi
jg 0x1125c
xorl %eax, %eax
cmpl $0x7f, %esi
setg %al
xorl $-0x1f, %eax
addl %eax, %esi
jmp 0x1125f
addl $-0x7e, %esi
leal -0x7f(%rdi), %eax
cmpl $0x9, %eax
ja 0x1126c
addl $-0xa, %edi
jmp 0x11280
leal -0x89(%rdi), %eax
cmpl $0x9, %eax
ja 0x11280
addl $-0x14, %edi
orl $0x8f80, %edi           # imm = 0x8F80
testq %rdx, %rdx
je 0x11287
movl %edi, (%rdx)
testq %rcx, %rcx
je 0x1128e
movl %esi, (%rcx)
xorl %eax, %eax
retq
leal -0x17b(,%rdi,2), %eax
orl $0x8f00, %eax           # imm = 0x8F00
xorl %edi, %edi
cmpl $0x9f, %esi
setge %dil
addl %eax, %edi
jmp 0x11245