// File: /workspace/github_c_makefile_star2_O1/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, %esi
shrl $0x8, %esi
xorl %ebp, %ebp
cmpl $0x100, %edx            # imm = 0x100
cmovll %edx, %esi
movl %ebx, (%rsp)
cmovll %ebp, %ecx
cmpl %eax, %edi
jbe 0xce98
movl %esi, %r15d
jmp 0xd00d
movl $0x0, %r15d
testl %r14d, %r14d
je 0xd00d
movl %r14d, %edx
andl $0xc0, %edx
xorl %eax, %eax
cmpl $0x80, %edx
je 0xd0b7
movslq %r14d, %rdx
leaq 0xa468(%rip), %rdi      # 0x17330
movzbl -0xc0(%rdx,%rdi), %edi
leal -0x1e(%rdi), %edx
cmpl $0xc, %edx
ja 0xcf0e
leaq 0xa131(%rip), %rdi      # 0x17010
movslq (%rdi,%rdx,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
testl %esi, %esi
je 0xcf99
movl $0xc0, %edx
movl %ebx, %edi
andl %edx, %edi
movl $0x80, %r8d
xorl %r8d, %edi
andl %esi, %edx
xorl %r8d, %edx
orl %edi, %edx
jmp 0xcf8f
cmpl $0x15, %edi
jne 0xd0b7
leal -0xc0(%rbx), %edx
movl %esi, %r15d
cmpl $-0x40, %edx
jae 0xd00d
jmp 0xd0b7
testl %esi, %esi
je 0xcf99
movl %ebx, %edx
andl $-0x20, %edx
xorl $0xa0, %edx
movl %esi, %edi
andl $0xc0, %edi
xorl $0x80, %edi
orl %edx, %edi
jmp 0xcf8f
testl %esi, %esi
je 0xd0c2
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0b7
movl %ebx, %edx
andl $-0x10, %edx
jmp 0xcfea
testl %esi, %esi
je 0xcf99
movl %ebx, %edx
andl $-0x20, %edx
movl $0x80, %edi
xorl %edi, %edx
movl %esi, %r8d
andl $0xc0, %r8d
xorl %edi, %r8d
orl %edx, %r8d
movl %esi, %r15d
je 0xd00d
jmp 0xd0b7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xd0b7
testl %esi, %esi
je 0xd0c2
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0b7
leal -0x90(%rbx), %edx
cmpl $0x2f, %edx
jbe 0xcff6
jmp 0xd0b7
testl %esi, %esi
je 0xd0c2
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0b7
movl %ebx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0xd0b7
movl %esi, %edx
andl $0xc0, %edx
movl %esi, %r15d
cmpl $0x80, %edx
jne 0xd0b7
leal 0x1(%r14), %eax
cmpl $0x2, %eax
jb 0xd0a4
movl %r14d, %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0xd048
movl %r14d, %edi
movl %ebx, %esi
movl %r15d, %edx
callq 0x11303
orl $0x1000000, %eax        # imm = 0x1000000
movl %eax, (%rsp)
movl $0x0, 0x4(%rsp)
jmp 0xd0a4
cmpb $0x1, 0x4036d(%rip)     # 0x4d3bc
jne 0xd08d
movl %r14d, %edi
movl %ebx, %esi
movl %r15d, %edx
callq 0x11303
movl %eax, %ecx
movl $0x2, %edx
leaq 0x14ef4(%rip), %rax     # 0x21f60
movzwl (%rax,%rdx), %esi
cmpl %esi, %ecx
je 0xd084
leaq 0x6(%rdx), %rdi
cmpq $0x92, %rdx
movq %rdi, %rdx
jne 0xd06c
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
cmpl %esi, %ecx
je 0xd0b7
leaq 0x4(%rsp), %rcx
movq %rsp, %r8
movl %r14d, %edi
movl %ebx, %esi
movl %r15d, %edx
callq 0x11376
movl %eax, %ebp
testl %ebp, %ebp
jne 0xd0b5
movl 0x4(%rsp), %edi
movl (%rsp), %esi
callq *0x40203(%rip)          # 0x4d2b8
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0xd0b7