// File: /workspace/github_c_makefile_star2_O2/nurse[P]nkf/nkf.c
// Function: mime_getc
static nkf_char
mime_getc(FILE *f)
{
    nkf_char c1, c2, c3, c4, cc;
    nkf_char t1, t2, t3, t4, mode, exit_mode;
    nkf_char lwsp_count;
    char *lwsp_buf;
    char *lwsp_buf_new;
    nkf_char lwsp_size = 128;

    if (mime_input_state.top != mime_input_state.last) {  /* Something is in FIFO */
	return  mime_input_buf(mime_input_state.top++);
    }
    if (mime_decode_mode==1 ||mime_decode_mode==FALSE) {
	mime_decode_mode=FALSE;
	unswitch_mime_getc();
	return (*i_getc)(f);
    }

    if (mimebuf_f == FIXED_MIME)
	exit_mode = mime_decode_mode;
    else
	exit_mode = FALSE;
    if (mime_decode_mode == 'Q') {
	if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
      restart_mime_q:
	if (c1=='_' && mimebuf_f != FIXED_MIME) return SP;
	if (c1<=SP || DEL<=c1) {
	    mime_decode_mode = exit_mode; /* prepare for quit */
	    return c1;
	}
	if (c1!='=' && (c1!='?' || mimebuf_f == FIXED_MIME)) {
	    return c1;
	}

	mime_decode_mode = exit_mode; /* prepare for quit */
	if ((c2 = (*i_mgetc)(f)) == EOF) return (EOF);
	if (c1=='?'&&c2=='=' && mimebuf_f != FIXED_MIME) {
	    /* end Q encoding */
	    input_mode = exit_mode;
	    lwsp_count = 0;
	    lwsp_buf = nkf_xmalloc((lwsp_size+5)*sizeof(char));
	    while ((c1=(*i_getc)(f))!=EOF) {
		switch (c1) {
		case LF:
		case CR:
		    if (c1==LF) {
			if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
			    i_ungetc(SP,f);
			    continue;
			} else {
			    i_ungetc(c1,f);
			}
			c1 = LF;
		    } else {
			if ((c1=(*i_getc)(f))!=EOF && c1 == LF) {
			    if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
				i_ungetc(SP,f);
				continue;
			    } else {
				i_ungetc(c1,f);
			    }
			    i_ungetc(LF,f);
			} else {
			    i_ungetc(c1,f);
			}
			c1 = CR;
		    }
		    break;
		case SP:
		case TAB:
		    lwsp_buf[lwsp_count] = (unsigned char)c1;
		    if (lwsp_count++>lwsp_size){
			lwsp_size <<= 1;
			lwsp_buf_new = nkf_xrealloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
			lwsp_buf = lwsp_buf_new;
		    }
		    continue;
		}
		break;
	    }
	    if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && lwsp_buf[lwsp_count-1] != TAB))) {
		i_ungetc(c1,f);
		for(lwsp_count--;lwsp_count>0;lwsp_count--)
		    i_ungetc(lwsp_buf[lwsp_count],f);
		c1 = lwsp_buf[0];
	    }
	    nkf_xfree(lwsp_buf);
	    return c1;
	}
	if (c1=='='&&c2<SP) { /* this is soft wrap */
	    while((c1 =  (*i_mgetc)(f)) <=SP) {
		if (c1 == EOF) return (EOF);
	    }
	    mime_decode_mode = 'Q'; /* still in MIME */
	    goto restart_mime_q;
	}
	if (c1=='?') {
	    mime_decode_mode = 'Q'; /* still in MIME */
	    (*i_mungetc)(c2,f);
	    return c1;
	}
	if ((c3 = (*i_mgetc)(f)) == EOF) return (EOF);
	if (c2<=SP) return c2;
	mime_decode_mode = 'Q'; /* still in MIME */
	return ((hex2bin(c2)<<4) + hex2bin(c3));
    }

    if (mime_decode_mode != 'B') {
	mime_decode_mode = FALSE;
	return (*i_mgetc)(f);
    }


    /* Base64 encoding */
    /*
       MIME allows line break in the middle of
       Base64, but we are very pessimistic in decoding
       in unbuf mode because MIME encoded code may broken by
       less or editor's control sequence (such as ESC-[-K in unbuffered
       mode. ignore incomplete MIME.
     */
    mode = mime_decode_mode;
    mime_decode_mode = exit_mode;  /* prepare for quit */

    while ((c1 = (*i_mgetc)(f))<=SP) {
	if (c1==EOF)
	    return (EOF);
    }
  mime_c2_retry:
    if ((c2 = (*i_mgetc)(f))<=SP) {
	if (c2==EOF)
	    return (EOF);
	if (mime_f != STRICT_MIME) goto mime_c2_retry;
	if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
	return c2;
    }
    if ((c1 == '?') && (c2 == '=')) {
	input_mode = ASCII;
	lwsp_count = 0;
	lwsp_buf = nkf_xmalloc((lwsp_size+5)*sizeof(char));
	while ((c1=(*i_getc)(f))!=EOF) {
	    switch (c1) {
	    case LF:
	    case CR:
		if (c1==LF) {
		    if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
			i_ungetc(SP,f);
			continue;
		    } else {
			i_ungetc(c1,f);
		    }
		    c1 = LF;
		} else {
		    if ((c1=(*i_getc)(f))!=EOF) {
			if (c1==SP) {
			    i_ungetc(SP,f);
			    continue;
			} else if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
			    i_ungetc(SP,f);
			    continue;
			} else {
			    i_ungetc(c1,f);
			}
			i_ungetc(LF,f);
		    } else {
			i_ungetc(c1,f);
		    }
		    c1 = CR;
		}
		break;
	    case SP:
	    case TAB:
		lwsp_buf[lwsp_count] = (unsigned char)c1;
		if (lwsp_count++>lwsp_size){
		    lwsp_size <<= 1;
		    lwsp_buf_new = nkf_xrealloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
		    lwsp_buf = lwsp_buf_new;
		}
		continue;
	    }
	    break;
	}
	if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && lwsp_buf[lwsp_count-1] != TAB))) {
	    i_ungetc(c1,f);
	    for(lwsp_count--;lwsp_count>0;lwsp_count--)
		i_ungetc(lwsp_buf[lwsp_count],f);
	    c1 = lwsp_buf[0];
	}
	nkf_xfree(lwsp_buf);
	return c1;
    }
  mime_c3_retry:
    if ((c3 = (*i_mgetc)(f))<=SP) {
	if (c3==EOF)
	    return (EOF);
	if (mime_f != STRICT_MIME) goto mime_c3_retry;
	if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
	return c3;
    }
  mime_c4_retry:
    if ((c4 = (*i_mgetc)(f))<=SP) {
	if (c4==EOF)
	    return (EOF);
	if (mime_f != STRICT_MIME) goto mime_c4_retry;
	if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
	return c4;
    }

    mime_decode_mode = mode; /* still in MIME sigh... */

    /* BASE 64 decoding */

    t1 = 0x3f & base64decode(c1);
    t2 = 0x3f & base64decode(c2);
    t3 = 0x3f & base64decode(c3);
    t4 = 0x3f & base64decode(c4);
    cc = ((t1 << 2) & 0x0fc) | ((t2 >> 4) & 0x03);
    if (c2 != '=') {
	mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
	cc = ((t2 << 4) & 0x0f0) | ((t3 >> 2) & 0x0f);
	if (c3 != '=') {
	    mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
	    cc = ((t3 << 6) & 0x0c0) | (t4 & 0x3f);
	    if (c4 != '=')
		mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
	}
    } else {
	return c1;
    }
    return  mime_input_buf(mime_input_state.top++);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x40ad5(%rip), %eax     # 0x549f8
cmpl 0x40ad3(%rip), %eax     # 0x549fc
jne 0x13f6e
movq %rdi, %rbx
movl 0x4063c(%rip), %eax     # 0x54570
cmpl $0x1, %eax
ja 0x13f98
andl $0x0, 0x40630(%rip)     # 0x54570
cmpl $0x8, 0x38349(%rip)     # 0x4c290
jne 0x14085
movq 0x383fc(%rip), %rax     # 0x4c350
movq %rax, 0x383e5(%rip)     # 0x4c340
movq 0x383f6(%rip), %rcx     # 0x4c358
movq %rcx, 0x383df(%rip)     # 0x4c348
jmp 0x14093
leal 0x1(%rax), %ecx
movl %ecx, 0x40a81(%rip)     # 0x549f8
leaq 0x4067a(%rip), %rcx     # 0x545f8
andl $0x3ff, %eax            # imm = 0x3FF
movzbl (%rax,%rcx), %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
cmpl $0x7, 0x405d2(%rip)     # 0x54574
cmovel %eax, %r12d
pushq $-0x1
popq %rbp
cmpl $0x42, %eax
je 0x140d6
cmpl $0x51, %eax
jne 0x14211
movq %rbx, %rdi
callq *0x3837c(%rip)          # 0x4c340
cmpl $-0x1, %eax
je 0x13f87
movl %eax, %r14d
pushq $0x20
popq %r13
cmpl $0x5f, %r14d
sete %cl
movl 0x40597(%rip), %eax     # 0x54574
cmpl $0x7, %eax
setne %dl
testb %dl, %cl
jne 0x14263
leal -0x7f(%r14), %ecx
cmpl $-0x5f, %ecx
jbe 0x142e3
cmpl $0x3d, %r14d
je 0x14011
cmpl $0x3f, %r14d
jne 0x142ea
cmpl $0x7, %eax
je 0x142ea
movl %r12d, 0x40558(%rip)    # 0x54570
movq %rbx, %rdi
callq *0x3831f(%rip)          # 0x4c340
cmpl $-0x1, %eax
je 0x13f87
movl %eax, %r15d
cmpl $0x3f, %r14d
jne 0x14046
cmpl $0x3d, %r15d
jne 0x14046
cmpl $0x7, 0x40534(%rip)     # 0x54574
jne 0x142f2
cmpl $0x3d, %r14d
jne 0x143c8
cmpl $0x1f, %r15d
jg 0x143c8
movq %rbx, %rdi
callq *0x382dd(%rip)          # 0x4c340
movl %eax, %r14d
cmpl $0x20, %eax
jg 0x14076
cmpl $-0x1, %r14d
jne 0x1405a
jmp 0x13f87
movl $0x51, 0x404f0(%rip)    # 0x54570
jmp 0x13fd0
movq 0x382b4(%rip), %rax     # 0x4c340
movq 0x382b5(%rip), %rcx     # 0x4c348
movq %rax, 0x3827e(%rip)     # 0x4c318
movq %rcx, 0x3827f(%rip)     # 0x4c320
movq 0x40960(%rip), %rsi     # 0x54a08
testq %rsi, %rsi
je 0x140bb
xorl %edi, %edi
callq 0x11962
movq 0x3825d(%rip), %rax     # 0x4c318
andq $0x0, 0x40945(%rip)     # 0x54a08
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movl %r12d, 0x40493(%rip)    # 0x54570
movq %rbx, %rdi
callq *0x3825a(%rip)          # 0x4c340
movl %eax, %r14d
cmpl $0x21, %eax
jge 0x14110
cmpl $-0x1, %r14d
jne 0x140dd
jmp 0x13f87
cmpl $-0x1, %r12d
je 0x13f87
cmpl $0x8, 0x38186(%rip)     # 0x4c290
je 0x142cb
movq %rbx, %rdi
callq *0x38227(%rip)          # 0x4c340
movl %eax, %r12d
cmpl $0x20, %eax
jle 0x140f9
movl %r14d, %eax
xorl $0x3f, %eax
movl %r12d, %ecx
xorl $0x3d, %ecx
orl %eax, %ecx
jne 0x1422f
andl $0x0, 0x404ac(%rip)     # 0x545e8
movl $0x85, %edi
callq 0x10d32
movq %rax, %r14
movl $0x80, %eax
xorl %r15d, %r15d
pushq $0x20
popq %rbp
movq %rax, (%rsp)
movslq %eax, %r13
movq %r15, %r12
movq %rbx, %rdi
callq *0x381b1(%rip)          # 0x4c318
movl %eax, %r15d
cmpl $0xa, %eax
je 0x141a4
cmpl $0xd, %r15d
jne 0x141c8
movq %rbx, %rdi
callq *0x3819a(%rip)          # 0x4c318
cmpl $0x20, %eax
je 0x141bb
cmpl $-0x1, %eax
je 0x14461
movq %rbx, %rdi
callq *0x38183(%rip)          # 0x4c318
cmpl $0x9, %eax
je 0x141bb
cmpl $0x20, %eax
je 0x141bb
jmp 0x14453
movq %rbx, %rdi
callq *0x3816b(%rip)          # 0x4c318
cmpl $0x20, %eax
je 0x141bb
cmpl $0x9, %eax
jne 0x14461
movl %ebp, %edi
movq %rbx, %rsi
callq *0x3815a(%rip)          # 0x4c320
jmp 0x1415e
cmpl $0x9, %r15d
je 0x141d8
cmpl $0x20, %r15d
jne 0x1446c
movb %r15b, (%r14,%r12)
leaq 0x1(%r12), %r15
cmpq %r13, %r12
jle 0x1415b
movq (%rsp), %rax
movl %eax, %r12d
addl %eax, %r12d
leal 0x5(,%rax,2), %eax
movslq %eax, %rsi
movq %r14, %rdi
callq 0x14cad
movq %rax, %r14
movl %r12d, %eax
jmp 0x14154
andl $0x0, 0x40358(%rip)     # 0x54570
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *0x38111(%rip)          # 0x4c340
movq %rbx, %rdi
callq *0x38108(%rip)          # 0x4c340
movl %eax, %r13d
cmpl $0x21, %eax
jge 0x14282
cmpl $-0x1, %r13d
je 0x13f87
cmpl $0x8, 0x3803f(%rip)     # 0x4c290
jne 0x1422f
cmpl $0x7, 0x4031a(%rip)     # 0x54574
je 0x14263
andl $0x0, 0x40385(%rip)     # 0x545e8
movl %r13d, %ebp
jmp 0x13f87
cmpl $-0x1, %r15d
je 0x13f87
cmpl $0x8, 0x38014(%rip)     # 0x4c290
je 0x1443b
movq %rbx, %rdi
callq *0x380b5(%rip)          # 0x4c340
movl %eax, %r15d
cmpl $0x20, %eax
jle 0x1426b
movl $0x42, 0x402d3(%rip)    # 0x54570
movl %r12d, %edi
callq 0x14cd6
movl %eax, %ebp
movl %r13d, %edi
callq 0x14cd6
movl %eax, %ebx
movl %r15d, %edi
callq 0x14cd6
cmpl $0x3d, %r12d
jne 0x144ca
movl %r14d, %ebp
jmp 0x13f87
cmpl $0x7, 0x402a2(%rip)     # 0x54574
je 0x142db
andl $0x0, 0x4030d(%rip)     # 0x545e8
movl %r12d, %ebp
jmp 0x13f87
movl %r12d, 0x40286(%rip)    # 0x54570
movl %r14d, %ebp
jmp 0x13f87
movl %r12d, 0x402ef(%rip)    # 0x545e8
movl $0x85, %edi
callq 0x10d32
movq %rax, %r14
movl $0x80, %r13d
xorl %r15d, %r15d
pushq $0x20
popq %rbp
movslq %r13d, %rax
movq %rax, (%rsp)
movq %r15, %r12
movq %rbx, %rdi
callq *0x37ff3(%rip)          # 0x4c318
movl %eax, %r15d
cmpl $0xa, %eax
je 0x1435d
cmpl $0xd, %r15d
jne 0x14381
movq %rbx, %rdi
callq *0x37fdc(%rip)          # 0x4c318
cmpl $0xa, %eax
jne 0x14576
movq %rbx, %rdi
callq *0x37fca(%rip)          # 0x4c318
cmpl $0x9, %eax
je 0x14374
cmpl $0x20, %eax
je 0x14374
jmp 0x14568
movq %rbx, %rdi
callq *0x37fb2(%rip)          # 0x4c318
cmpl $0x20, %eax
je 0x14374
cmpl $0x9, %eax
jne 0x14576
movl %ebp, %edi
movq %rbx, %rsi
callq *0x37fa1(%rip)          # 0x4c320
jmp 0x1431c
cmpl $0x9, %r15d
je 0x14391
cmpl $0x20, %r15d
jne 0x14581
movb %r15b, (%r14,%r12)
leaq 0x1(%r12), %r15
cmpq (%rsp), %r12
jle 0x14319
movl %r13d, %r12d
addl %r13d, %r12d
leal 0x5(,%r13,2), %eax
movslq %eax, %rsi
movq %r14, %rdi
callq 0x14cad
movq %rax, %r14
movl %r12d, %r13d
jmp 0x14312
cmpl $0x3f, %r14d
jne 0x143ec
movl $0x51, 0x40198(%rip)    # 0x54570
movl %r15d, %edi
movq %rbx, %rsi
callq *0x37f64(%rip)          # 0x4c348
pushq $0x3f
popq %rbp
jmp 0x13f87
movq %rbx, %rdi
callq *0x37f4b(%rip)          # 0x4c340
cmpl $-0x1, %eax
je 0x13f87
movl %r15d, %ebp
cmpl $0x21, %r15d
jl 0x13f87
movl $0x51, 0x4015b(%rip)    # 0x54570
leal -0x30(%r15), %ecx
cmpl $0xa, %ecx
jb 0x145f6
leal -0x41(%r15), %ecx
cmpl $0x5, %ecx
ja 0x145e5
addl $-0x37, %r15d
movl %r15d, %ecx
jmp 0x145f6
cmpl $0x7, 0x40132(%rip)     # 0x54574
je 0x1444b
andl $0x0, 0x4019d(%rip)     # 0x545e8
movl %r15d, %ebp
jmp 0x13f87
movl %eax, %edi
movq %rbx, %rsi
callq *0x37ec2(%rip)          # 0x4c320
pushq $0xa
popq %rax
movl %eax, %edi
movq %rbx, %rsi
callq *0x37eb4(%rip)          # 0x4c320
testl %r12d, %r12d
je 0x145d5
cmpl $0x3d, %r15d
jne 0x1449d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addl %r12d, %eax
movzbl (%r14,%rax), %eax
pushq $0x3d
popq %rbp
cmpl $0x9, %eax
je 0x145d8
cmpl $0x20, %eax
je 0x145d8
movl %r15d, %edi
movq %rbx, %rsi
callq *0x37e77(%rip)          # 0x4c320
movl %r12d, %r15d
cmpq $0x2, %r15
jl 0x145cf
movsbl -0x1(%r14,%r15), %edi
decq %r15
movq %rbx, %rsi
callq *0x37e58(%rip)          # 0x4c320
jmp 0x144ac
movl %eax, %r12d
movl %r14d, %edi
callq 0x14cd6
movl %ebp, %ecx
shrl $0x4, %ecx
andl $0x3, %ecx
leal (%rcx,%rax,4), %esi
movl 0x40516(%rip), %ecx     # 0x549fc
leaq 0x4010b(%rip), %rax     # 0x545f8
leal 0x1(%rcx), %edx
movl %edx, 0x40506(%rip)     # 0x549fc
movl %ecx, %edi
andl $0x3ff, %edi            # imm = 0x3FF
movb %sil, (%rdi,%rax)
cmpl $0x3d, %r13d
je 0x1454a
shll $0x4, %ebp
movl %ebx, %edi
shrl $0x2, %edi
andl $0xf, %edi
orl %ebp, %edi
leal 0x2(%rcx), %esi
movl %esi, 0x404de(%rip)     # 0x549fc
andl $0x3ff, %edx            # imm = 0x3FF
movb %dil, (%rdx,%rax)
cmpl $0x3d, %r15d
je 0x1454a
andl $0x3f, %r12d
shll $0x6, %ebx
orl %r12d, %ebx
addl $0x3, %ecx
movl %ecx, 0x404bb(%rip)     # 0x549fc
andl $0x3ff, %esi            # imm = 0x3FF
movb %bl, (%rsi,%rax)
movl 0x404a8(%rip), %ecx     # 0x549f8
leal 0x1(%rcx), %edx
movl %edx, 0x4049f(%rip)     # 0x549f8
andl $0x3ff, %ecx            # imm = 0x3FF
movzbl (%rcx,%rax), %ebp
jmp 0x13f87
movl %eax, %edi
movq %rbx, %rsi
callq *0x37dad(%rip)          # 0x4c320
pushq $0xa
popq %rax
movl %eax, %edi
movq %rbx, %rsi
callq *0x37d9f(%rip)          # 0x4c320
testl %r12d, %r12d
je 0x145d5
cmpl $0x3d, %r15d
jne 0x145a6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addl %r12d, %eax
movzbl (%r14,%rax), %eax
pushq $0x3d
popq %rbp
cmpl $0x9, %eax
je 0x145d8
cmpl $0x20, %eax
je 0x145d8
movl %r15d, %edi
movq %rbx, %rsi
callq *0x37d6e(%rip)          # 0x4c320
movl %r12d, %r15d
cmpq $0x2, %r15
jl 0x145cf
movsbl -0x1(%r14,%r15), %edi
decq %r15
movq %rbx, %rsi
callq *0x37d53(%rip)          # 0x4c320
jmp 0x145b5
movsbl (%r14), %ebp
jmp 0x145d8
movl %r15d, %ebp
movq %r14, %rdi
callq 0xc040
jmp 0x13f87
leal -0x61(%r15), %edx
addl $-0x57, %r15d
xorl %ecx, %ecx
cmpl $0x6, %edx
cmovbl %r15d, %ecx
shll $0x4, %ecx
leal -0x30(%rax), %ebp
cmpl $0xa, %ebp
jb 0x1461e
leal -0x41(%rax), %edx
cmpl $0x5, %edx
ja 0x14610
addl $-0x37, %eax
movl %eax, %ebp
jmp 0x1461e
leal -0x61(%rax), %edx
addl $-0x57, %eax
xorl %ebp, %ebp
cmpl $0x6, %edx
cmovbl %eax, %ebp
addl %ecx, %ebp
jmp 0x13f87