// File: /workspace/github_c_makefile_star2_O3/nurse[P]nkf/nkf.c
// Function: fold_conv
static void
fold_conv(nkf_char c2, nkf_char c1)
{
    nkf_char prev0;
    nkf_char fold_state;

    if (c1== CR && !fold_preserve_f) {
	fold_state=0;  /* ignore cr */
    }else if (c1== LF&&f_prev==CR && fold_preserve_f) {
	f_prev = LF;
	fold_state=0;  /* ignore cr */
    } else if (c1== BS) {
	if (f_line>0) f_line--;
	fold_state =  1;
    } else if (c2==EOF && f_line != 0) {    /* close open last line */
	fold_state = LF;
    } else if ((c1==LF && !fold_preserve_f)
	       || ((c1==CR||(c1==LF&&f_prev!=CR))
		   && fold_preserve_f)) {
	/* new line */
	if (fold_preserve_f) {
	    f_prev = c1;
	    f_line = 0;
	    fold_state =  CR;
	} else if ((f_prev == c1)
		   || (f_prev == LF)
		  ) {        /* duplicate newline */
	    if (f_line) {
		f_line = 0;
		fold_state =  LF;    /* output two newline */
	    } else {
		f_line = 0;
		fold_state =  1;
	    }
	} else  {
	    if (f_prev&0x80) {     /* Japanese? */
		f_prev = c1;
		fold_state =  0;       /* ignore given single newline */
	    } else if (f_prev==SP) {
		fold_state =  0;
	    } else {
		f_prev = c1;
		if (++f_line<=fold_len)
		    fold_state =  SP;
		else {
		    f_line = 0;
		    fold_state =  CR;        /* fold and output nothing */
		}
	    }
	}
    } else if (c1=='\f') {
	f_prev = LF;
	f_line = 0;
	fold_state =  LF;            /* output newline and clear */
    } else if ((c2==0 && nkf_isblank(c1)) || (c2 == '!' && c1 == '!')) {
	/* X0208 kankaku or ascii space */
	if (f_prev == SP) {
	    fold_state = 0;         /* remove duplicate spaces */
	} else {
	    f_prev = SP;
	    if (++f_line<=fold_len)
		fold_state = SP;         /* output ASCII space only */
	    else {
		f_prev = SP; f_line = 0;
		fold_state = CR;        /* fold and output nothing */
	    }
	}
    } else {
	prev0 = f_prev; /* we still need this one... , but almost done */
	f_prev = c1;
	if (c2 || c2 == JIS_X_0201_1976_K)
	    f_prev |= 0x80;  /* this is Japanese */
	f_line += c2 == JIS_X_0201_1976_K ? 1: char_size(c2,c1);
	if (f_line<=fold_len) {   /* normal case */
	    fold_state = 1;
	} else {
	    if (f_line>fold_len+fold_margin) { /* too many kinsoku suspension */
		f_line = char_size(c2,c1);
		fold_state =  LF;       /* We can't wait, do fold now */
	    } else if (c2 == JIS_X_0201_1976_K) {
		/* simple kinsoku rules  return 1 means no folding  */
		if (c1==(0xde&0x7f)) fold_state = 1; /* $B!+(B*/
		else if (c1==(0xdf&0x7f)) fold_state = 1; /* $B!,(B*/
		else if (c1==(0xa4&0x7f)) fold_state = 1; /* $B!#(B*/
		else if (c1==(0xa3&0x7f)) fold_state = 1; /* $B!$(B*/
		else if (c1==(0xa1&0x7f)) fold_state = 1; /* $B!W(B*/
		else if (c1==(0xb0&0x7f)) fold_state = 1; /* - */
		else if (SP<=c1 && c1<=(0xdf&0x7f)) {      /* X0201 */
		    f_line = 1;
		    fold_state = LF;/* add one new f_line before this character */
		} else {
		    f_line = 1;
		    fold_state = LF;/* add one new f_line before this character */
		}
	    } else if (c2==0) {
		/* kinsoku point in ASCII */
		if (  c1==')'||    /* { [ ( */
		    c1==']'||
		    c1=='}'||
		    c1=='.'||
		    c1==','||
		    c1=='!'||
		    c1=='?'||
		    c1=='/'||
		    c1==':'||
		    c1==';') {
		    fold_state = 1;
		    /* just after special */
		} else if (!is_alnum(prev0)) {
		    f_line = char_size(c2,c1);
		    fold_state = LF;
		} else if ((prev0==SP) ||   /* ignored new f_line */
			   (prev0==LF)||        /* ignored new f_line */
			   (prev0&0x80)) {        /* X0208 - ASCII */
		    f_line = char_size(c2,c1);
		    fold_state = LF;/* add one new f_line before this character */
		} else {
		    fold_state = 1;  /* default no fold in ASCII */
		}
	    } else {
		if (c2=='!') {
		    if (c1=='"')  fold_state = 1; /* $B!"(B */
		    else if (c1=='#')  fold_state = 1; /* $B!#(B */
		    else if (c1=='W')  fold_state = 1; /* $B!W(B */
		    else if (c1=='K')  fold_state = 1; /* $B!K(B */
		    else if (c1=='$')  fold_state = 1; /* $B!$(B */
		    else if (c1=='%')  fold_state = 1; /* $B!%(B */
		    else if (c1=='\'') fold_state = 1; /* $B!\(B */
		    else if (c1=='(')  fold_state = 1; /* $B!((B */
		    else if (c1==')')  fold_state = 1; /* $B!)(B */
		    else if (c1=='*')  fold_state = 1; /* $B!*(B */
		    else if (c1=='+')  fold_state = 1; /* $B!+(B */
		    else if (c1==',')  fold_state = 1; /* $B!,(B */
		    /* default no fold in kinsoku */
		    else {
			fold_state = LF;
			f_line = char_size(c2,c1);
			/* add one new f_line before this character */
		    }
		} else {
		    f_line = char_size(c2,c1);
		    fold_state = LF;
		    /* add one new f_line before this character */
		}
	    }
	}
    }
    /* terminator process */
    switch(fold_state) {
    case LF:
	oconv_newline(o_fconv);
	(*o_fconv)(c2,c1);
	break;
    case 0:
	return;
    case CR:
	oconv_newline(o_fconv);
	break;
    case TAB:
    case SP:
	(*o_fconv)(0,SP);
	break;
    default:
	(*o_fconv)(c2,c1);
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
cmpl $0xd, %esi
setne %al
movb 0x41911(%rip), %dl      # 0x55574
orb %dl, %al
testb $0x1, %al
je 0x13c91
movl %esi, %ebx
movl %esi, %ecx
xorl $0xa, %ecx
movl 0x4197e(%rip), %eax     # 0x555f4
movl %eax, %esi
xorl $0xd, %esi
orl %ecx, %esi
sete %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x13c96
movl $0xa, 0x41963(%rip)     # 0x555f4
popq %rbx
popq %r14
popq %rbp
retq
movl %edi, %ebp
cmpl $0x8, %ebx
jne 0x13cc0
movl 0x4194d(%rip), %eax     # 0x555f0
testl %eax, %eax
jle 0x13caf
decl %eax
movl %eax, 0x41941(%rip)     # 0x555f0
movq 0x39642(%rip), %rax     # 0x4d2f8
movl %ebp, %edi
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmpq *%rax
cmpl $-0x1, %ebp
sete %sil
movl 0x41923(%rip), %ecx     # 0x555f0
testl %ecx, %ecx
setne %dil
testb %dil, %sil
je 0x13d29
movq 0x39619(%rip), %rcx     # 0x4d2f8
movl 0x418af(%rip), %eax     # 0x55594
testl %eax, %eax
movl $0xa, %esi
cmovnel %eax, %esi
cmpl $0xa, %esi
je 0x13d15
cmpl $0xd, %esi
je 0x13d15
cmpl $0xd0a, %esi            # imm = 0xD0A
jne 0x13d20
xorl %edi, %edi
movl $0xd, %esi
movq %rcx, %r14
callq *%rcx
movq %r14, %rcx
movl $0xa, %esi
xorl %edi, %edi
callq *%rcx
movq 0x395d8(%rip), %rcx     # 0x4d2f8
movl %ebp, %edi
movl %ebx, %esi
jmp 0x13dba
cmpl $0xa, %ebx
setne %sil
orb %dl, %sil
testb $0x1, %sil
je 0x13d62
cmpl $0xd, %ebx
jne 0x13d48
testb $0x1, %dl
jne 0x13d67
jmp 0x13e26
cmpl $0xa, %ebx
sete %sil
cmpl $0xd, %eax
setne %dil
andb %sil, %dil
testb %dl, %dil
je 0x13e10
testb $0x1, %dl
je 0x13dc0
movl %ebx, 0x41887(%rip)     # 0x555f4
movl $0x0, 0x41879(%rip)     # 0x555f0
movq 0x3957a(%rip), %rcx     # 0x4d2f8
movl 0x41810(%rip), %eax     # 0x55594
testl %eax, %eax
movl $0xa, %esi
cmovnel %eax, %esi
cmpl $0xa, %esi
je 0x13db8
cmpl $0xd, %esi
je 0x13db8
cmpl $0xd0a, %esi            # imm = 0xD0A
jne 0x13c91
xorl %edi, %edi
movl $0xd, %esi
movq %rcx, %rbx
callq *%rcx
movq %rbx, %rcx
movl $0xa, %esi
xorl %edi, %edi
popq %rbx
popq %r14
popq %rbp
jmpq *%rcx
cmpl %ebx, %eax
setne %dl
cmpl $0xa, %eax
setne %sil
testb %sil, %dl
jne 0x13de0
xorl %edx, %edx
testl %ecx, %ecx
jne 0x13ee2
jmp 0x13caf
testb %al, %al
js 0x13e49
cmpl $0x20, %eax
je 0x13c91
movl %ebx, 0x41801(%rip)     # 0x555f4
movl %ecx, %eax
incl %eax
xorl %edx, %edx
cmpl 0x4177d(%rip), %ecx     # 0x5557c
cmovll %eax, %edx
movl %edx, 0x417e8(%rip)     # 0x555f0
jge 0x13d77
jmp 0x13e87
cmpl $0xc, %ebx
jne 0x13e26
movl $0xa, 0x417d5(%rip)     # 0x555f4
xorl %edx, %edx
jmp 0x13ee2
testl %ebp, %ebp
je 0x13e54
cmpl $0x21, %ebp
sete %sil
movl %ebp, %edi
xorl $0x21, %edi
movl %ebx, %r8d
xorl $0x21, %r8d
movl $0x2, %edx
orl %edi, %r8d
je 0x13e5e
jmp 0x13ea1
movl %ebx, 0x417a5(%rip)     # 0x555f4
jmp 0x13c91
cmpl $0x9, %ebx
je 0x13e5e
cmpl $0x20, %ebx
jne 0x13e9a
cmpl $0x20, %eax
je 0x13c91
movl $0x20, 0x41783(%rip)    # 0x555f4
movl %ecx, %eax
incl %eax
movl %eax, 0x41775(%rip)     # 0x555f0
cmpl 0x416fb(%rip), %ecx     # 0x5557c
jge 0x13d6d
movq 0x3946a(%rip), %rax     # 0x4d2f8
xorl %edi, %edi
movl $0x20, %esi
jmp 0x13cba
movl $0x1, %edx
xorl %esi, %esi
movl %ebx, %edi
orl $0x80, %edi
testl %ebp, %ebp
cmovel %ebx, %edi
cmpl $0x1013, %ebp           # imm = 0x1013
movl %edi, 0x4173a(%rip)     # 0x555f4
movl $0x1, %edi
cmovnel %edx, %edi
addl %ecx, %edi
movl %edi, 0x41726(%rip)     # 0x555f0
movl 0x416ac(%rip), %ecx     # 0x5557c
cmpl %ecx, %edi
jle 0x13caf
addl 0x3940a(%rip), %ecx     # 0x4d2e8
cmpl %ecx, %edi
jle 0x13eed
movl %edx, 0x41708(%rip)     # 0x555f0
jmp 0x13cd8
cmpl $0x1013, %ebp           # imm = 0x1013
jne 0x13f0e
movl $0x1, %edx
leal -0x21(%rbx), %eax
cmpl $0x3e, %eax
ja 0x13ee2
movabsq $0x600000000000800d, %rcx # imm = 0x600000000000800D
jmp 0x13f2e
testl %ebp, %ebp
je 0x13f3a
movl $0x2, %edx
testb %sil, %sil
je 0x13ee2
leal -0x22(%rbx), %eax
cmpl $0x35, %eax
ja 0x13ee2
movabsq $0x200200000007ef, %rcx # imm = 0x200200000007EF
btq %rax, %rcx
jb 0x13caf
jmp 0x13ee2
leal -0x21(%rbx), %ecx
cmpl $0x3c, %ecx
ja 0x13f56
movabsq $0x1000000046006901, %rdx # imm = 0x1000000046006901
btq %rcx, %rdx
jb 0x13caf
cmpl $0x7d, %ebx
je 0x13caf
movl %eax, %ecx
andl $-0x21, %ecx
addl $-0x41, %ecx
cmpl $0x1a, %ecx
setb %cl
addl $-0x30, %eax
cmpl $0xa, %eax
setb %al
orb %cl, %al
movl $0x1, %edx
jne 0x13caf
jmp 0x13ee2