// File: /workspace/github_c_makefile_star2_O3/nurse[P]nkf/nkf.c
// Function: w_iconv
static nkf_char
w_iconv(nkf_char c1, nkf_char c2, nkf_char c3)
{
    nkf_char ret = 0, c4 = 0;
    static const char w_iconv_utf8_1st_byte[] =
    { /* 0xC0 - 0xFF */
	20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
	21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
	30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33,
	40, 41, 41, 41, 42, 43, 43, 43, 50, 50, 50, 50, 60, 60, 70, 70};

    if (c3 > 0xFF) {
	c4 = c3 & 0xFF;
	c3 >>= 8;
    }

    if (c1 < 0 || 0xff < c1) {
    }else if (c1 == 0) { /* 0 : 1 byte*/
	c3 = 0;
    } else if ((c1 & 0xC0) == 0x80) { /* 0x80-0xbf : trail byte */
	return 0;
    } else{
	switch (w_iconv_utf8_1st_byte[c1 - 0xC0]) {
	case 21:
	    if (c2 < 0x80 || 0xBF < c2) return 0;
	    break;
	case 30:
	    if (c3 == 0) return -1;
	    if (c2 < 0xA0 || 0xBF < c2 || (c3 & 0xC0) != 0x80)
		return 0;
	    break;
	case 31:
	case 33:
	    if (c3 == 0) return -1;
	    if ((c2 & 0xC0) != 0x80 || (c3 & 0xC0) != 0x80)
		return 0;
	    break;
	case 32:
	    if (c3 == 0) return -1;
	    if (c2 < 0x80 || 0x9F < c2 || (c3 & 0xC0) != 0x80)
		return 0;
	    break;
	case 40:
	    if (c3 == 0) return -2;
	    if (c2 < 0x90 || 0xBF < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
		return 0;
	    break;
	case 41:
	    if (c3 == 0) return -2;
	    if (c2 < 0x80 || 0xBF < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
		return 0;
	    break;
	case 42:
	    if (c3 == 0) return -2;
	    if (c2 < 0x80 || 0x8F < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
		return 0;
	    break;
	default:
	    return 0;
	    break;
	}
    }
    if (c1 == 0 || c1 == EOF){
    } else if ((c1 & 0xf8) == 0xf0) { /* 4 bytes */
	c2 = nkf_char_unicode_new(nkf_utf8_to_unicode(c1, c2, c3, c4));
	c1 = 0;
    } else {
	if (x0213_f && x0213_wait_combining_p(nkf_utf8_to_unicode(c1, c2, c3, c4)))
	    return -3;
	ret = w2e_conv(c1, c2, c3, &c1, &c2);
    }
    if (ret == 0){
	(*oconv)(c1, c2);
    }
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %r14d
movl %edi, 0x4(%rsp)
movl $0xff, %eax
movl %edx, %ecx
andl %eax, %ecx
movl %edx, %ebp
shrl $0x8, %ebp
xorl %r15d, %r15d
cmpl $0x100, %edx            # imm = 0x100
cmovll %edx, %ebp
movl %esi, (%rsp)
cmovll %r15d, %ecx
cmpl %eax, %edi
jbe 0xcee6
leal 0x1(%r14), %eax
cmpl $0x2, %eax
jae 0xd054
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0xd0da
testl %r14d, %r14d
je 0xd0da
movl %r14d, %edx
andl $0xc0, %edx
xorl %eax, %eax
cmpl $0x80, %edx
je 0xd0e7
movslq %r14d, %rdx
leaq 0xa430(%rip), %rsi      # 0x17340
movzbl -0xc0(%rdx,%rsi), %esi
leal -0x1e(%rsi), %edx
cmpl $0xc, %edx
ja 0xcf59
leaq 0xa0e9(%rip), %rsi      # 0x17010
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
testl %ebp, %ebp
je 0xcfe3
movl $0xc0, %edx
movl %ebx, %esi
andl %edx, %esi
movl $0x80, %edi
xorl %edi, %esi
andl %ebp, %edx
xorl %edi, %edx
orl %esi, %edx
je 0xd054
jmp 0xd0e7
cmpl $0x15, %esi
jne 0xd0e7
leal -0xc0(%rbx), %edx
cmpl $-0x40, %edx
jae 0xd054
jmp 0xd0e7
testl %ebp, %ebp
je 0xcfe3
movl %ebx, %edx
andl $-0x20, %edx
xorl $0xa0, %edx
movl %ebp, %esi
andl $0xc0, %esi
xorl $0x80, %esi
orl %edx, %esi
je 0xd054
jmp 0xd0e7
testl %ebp, %ebp
je 0xd0f9
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0e7
movl %ebx, %edx
andl $-0x10, %edx
jmp 0xd034
testl %ebp, %ebp
je 0xcfe3
movl %ebx, %edx
andl $-0x20, %edx
movl $0x80, %esi
xorl %esi, %edx
movl %ebp, %edi
andl $0xc0, %edi
xorl %esi, %edi
orl %edx, %edi
je 0xd054
jmp 0xd0e7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xd0e7
testl %ebp, %ebp
je 0xd0f9
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0e7
leal -0x90(%rbx), %edx
cmpl $0x2f, %edx
jbe 0xd040
jmp 0xd0e7
testl %ebp, %ebp
je 0xd0f9
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0e7
movl %ebx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0e7
movl %ebp, %edx
andl $0xc0, %edx
cmpl $0x80, %edx
jne 0xd0e7
movl %r14d, %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0xd084
movl %r14d, %edi
movl %ebx, %esi
movl %ebp, %edx
callq 0x112e4
movl %eax, %ebx
orl $0x1000000, %ebx        # imm = 0x1000000
movl %ebx, (%rsp)
movl $0x0, 0x4(%rsp)
jmp 0xd0da
cmpb $0x1, 0x40331(%rip)     # 0x4d3bc
jne 0xd0ba
movl %r14d, %edi
movl %ebx, %esi
movl %ebp, %edx
callq 0x112e4
movl $0x2, %ecx
leaq 0x14ecb(%rip), %rdx     # 0x21f70
movzwl (%rdx,%rcx), %esi
cmpl %esi, %eax
je 0xd0f2
addq $0x6, %rcx
cmpq $0x98, %rcx
jne 0xd0a5
leaq 0x4(%rsp), %rcx
movq %rsp, %r8
movl %r14d, %edi
movl %ebx, %esi
movl %ebp, %edx
callq 0x11357
testl %eax, %eax
jne 0xd0e7
movl 0x4(%rsp), %r15d
movl (%rsp), %ebx
movl %r15d, %edi
movl %ebx, %esi
callq *0x401d3(%rip)          # 0x4d2b8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jmp 0xd0e7
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0xd0e7