// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
cmpl $0xd, %esi
setne %al
movb 0x41012(%rip), %dl      # 0x54564
orb %dl, %al
testb $0x1, %al
je 0x13580
movl %esi, %ebx
movl %esi, %ecx
xorl $0xa, %ecx
movl 0x4107f(%rip), %eax     # 0x545e4
movl %eax, %esi
xorl $0xd, %esi
orl %ecx, %esi
sete %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x13587
movl $0xa, 0x41064(%rip)     # 0x545e4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movl %edi, %ebp
cmpl $0x8, %ebx
jne 0x135a2
movl 0x4104c(%rip), %eax     # 0x545e0
testl %eax, %eax
jle 0x135c6
decl %eax
movl %eax, 0x41040(%rip)     # 0x545e0
jmp 0x135c6
cmpl $-0x1, %ebp
sete %sil
movl 0x41031(%rip), %ecx     # 0x545e0
testl %ecx, %ecx
setne %dil
testb %dil, %sil
je 0x135d9
movq 0x38d27(%rip), %rdi     # 0x4c2e8
callq 0x14b33
movq 0x38d1b(%rip), %rax     # 0x4c2e8
movl %ebp, %edi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rax
cmpl $0xa, %ebx
setne %sil
orb %dl, %sil
testb $0x1, %sil
je 0x1360e
cmpl $0xd, %ebx
jne 0x135f8
testb $0x1, %dl
jne 0x13613
jmp 0x13694
cmpl $0xa, %ebx
sete %sil
cmpl $0xd, %eax
setne %dil
andb %sil, %dil
testb %dl, %dil
je 0x1367e
testb $0x1, %dl
je 0x13632
movl %ebx, 0x40fcb(%rip)     # 0x545e4
andl $0x0, 0x40fc0(%rip)     # 0x545e0
movq 0x38cc1(%rip), %rdi     # 0x4c2e8
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x14b33
cmpl %ebx, %eax
setne %dl
cmpl $0xa, %eax
setne %sil
testb %sil, %dl
jne 0x13652
xorl %edx, %edx
testl %ecx, %ecx
jne 0x13751
jmp 0x135c6
testb %al, %al
js 0x136b2
cmpl $0x20, %eax
je 0x13580
movl %ebx, 0x40f7f(%rip)     # 0x545e4
movl %ecx, %eax
incl %eax
xorl %edx, %edx
cmpl 0x40efb(%rip), %ecx     # 0x5456c
cmovll %eax, %edx
movl %edx, 0x40f66(%rip)     # 0x545e0
jge 0x13620
jmp 0x136f0
cmpl $0xc, %ebx
jne 0x13694
movl $0xa, 0x40f57(%rip)     # 0x545e4
xorl %edx, %edx
jmp 0x13751
testl %ebp, %ebp
je 0x136bd
cmpl $0x21, %ebp
sete %dil
movl %ebp, %edx
xorl $0x21, %edx
movl %ebx, %esi
xorl $0x21, %esi
orl %edx, %esi
je 0x136c7
pushq $0x2
popq %rdx
jmp 0x13706
movl %ebx, 0x40f2c(%rip)     # 0x545e4
jmp 0x13580
cmpl $0x9, %ebx
je 0x136c7
cmpl $0x20, %ebx
jne 0x13701
cmpl $0x20, %eax
je 0x13580
movl $0x20, 0x40f0a(%rip)    # 0x545e4
movl %ecx, %eax
incl %eax
movl %eax, 0x40efc(%rip)     # 0x545e0
cmpl 0x40e82(%rip), %ecx     # 0x5456c
jge 0x13619
movq 0x38bf1(%rip), %rax     # 0x4c2e8
pushq $0x20
popq %rsi
xorl %edi, %edi
jmp 0x135d1
pushq $0x1
popq %rdx
xorl %edi, %edi
pushq $0x1
popq %rsi
movl %ebx, %r8d
orl $0x80, %r8d
testl %ebp, %ebp
cmovel %ebx, %r8d
cmpl $0x1013, %ebp           # imm = 0x1013
movl %r8d, 0x40ebe(%rip)     # 0x545e4
movl %edx, %r8d
cmovel %esi, %r8d
addl %ecx, %r8d
movl %r8d, 0x40ea9(%rip)     # 0x545e0
movl 0x40e2f(%rip), %ecx     # 0x5456c
cmpl %ecx, %r8d
jle 0x135c6
addl 0x38b8c(%rip), %ecx     # 0x4c2d8
cmpl %ecx, %r8d
jle 0x1375c
movl %edx, 0x40e89(%rip)     # 0x545e0
jmp 0x135ba
cmpl $0x1013, %ebp           # imm = 0x1013
jne 0x13788
leal -0x21(%rbx), %eax
cmpl $0x3e, %eax
ja 0x137fd
movabsq $0x600000000000800d, %rcx # imm = 0x600000000000800D
btq %rax, %rcx
movl %esi, %edx
jb 0x135c6
jmp 0x13751
testl %ebp, %ebp
je 0x137b2
pushq $0x2
popq %rdx
testb %dil, %dil
je 0x13751
leal -0x22(%rbx), %eax
cmpl $0x35, %eax
ja 0x13751
movabsq $0x200200000007ef, %rcx # imm = 0x200200000007EF
btq %rax, %rcx
jb 0x135c6
jmp 0x13751
leal -0x21(%rbx), %ecx
cmpl $0x3c, %ecx
ja 0x137ce
movabsq $0x1000000046006901, %rdx # imm = 0x1000000046006901
btq %rcx, %rdx
jb 0x135c6
cmpl $0x7d, %ebx
je 0x135c6
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 %esi, %edx
jne 0x135c6
jmp 0x13751
movl %esi, %edx
jmp 0x13751