// File: /workspace/github_c_makefile_star2_O1/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
movl %esi, %ebx
movl %edi, %ebp
cmpl $0xd, %esi
setne %cl
movb 0x41a44(%rip), %sil     # 0x55574
orb %sil, %cl
xorl %eax, %eax
testb $0x1, %cl
je 0x13dbd
movl %ebx, %edx
xorl $0xa, %edx
movl 0x41aab(%rip), %ecx     # 0x555f4
movl %ecx, %edi
xorl $0xd, %edi
orl %edx, %edi
sete %dl
andb %sil, %dl
cmpb $0x1, %dl
jne 0x13b6a
movl $0xa, 0x41a8f(%rip)     # 0x555f4
jmp 0x13dbd
cmpl $0x8, %ebx
jne 0x13b8f
movl 0x41a7b(%rip), %ecx     # 0x555f0
movl $0x1, %eax
testl %ecx, %ecx
jle 0x13dbd
decl %ecx
movl %ecx, 0x41a66(%rip)     # 0x555f0
jmp 0x13dbd
cmpl $-0x1, %ebp
sete %dil
movl 0x41a54(%rip), %edx     # 0x555f0
testl %edx, %edx
setne %r8b
testb %r8b, %dil
je 0x13bb1
movl $0xa, %eax
jmp 0x13dbd
cmpl $0xa, %ebx
setne %dil
orb %sil, %dil
testb $0x1, %dil
je 0x13be4
cmpl $0xd, %ebx
jne 0x13bce
testb $0x1, %sil
jne 0x13bea
jmp 0x13c31
cmpl $0xa, %ebx
sete %dil
cmpl $0xd, %ecx
setne %r8b
andb %dil, %r8b
testb %sil, %r8b
je 0x13c31
testb $0x1, %sil
je 0x13c04
movl %ebx, 0x41a04(%rip)     # 0x555f4
movl $0x0, 0x419f6(%rip)     # 0x555f0
movl $0xd, %eax
jmp 0x13dbd
cmpl %ebx, %ecx
setne %sil
cmpl $0xa, %ecx
setne %dil
testb %dil, %sil
jne 0x13c4f
xorl %eax, %eax
testl %edx, %edx
setne %al
movl $0x0, 0x419c9(%rip)     # 0x555f0
leal (%rax,%rax,8), %eax
incl %eax
jmp 0x13dbd
cmpl $0xc, %ebx
jne 0x13c8d
movl $0xa, 0x419b4(%rip)     # 0x555f4
movl $0x0, 0x419a6(%rip)     # 0x555f0
jmp 0x13ba7
testb %cl, %cl
js 0x13cf4
cmpl $0x20, %ecx
je 0x13dbd
movl %edx, %eax
incl %eax
xorl %ecx, %ecx
cmpl 0x41910(%rip), %edx     # 0x5557c
movl %ebx, 0x41982(%rip)     # 0x555f4
cmovll %eax, %ecx
movl %ecx, 0x41975(%rip)     # 0x555f0
movl $0x20, %ecx
movl $0xd, %eax
cmovll %ecx, %eax
jmp 0x13dbd
testl %ebp, %ebp
je 0x13cff
movl %ebp, %esi
xorl $0x21, %esi
movl %ebx, %edi
xorl $0x21, %edi
orl %esi, %edi
je 0x13d09
movl %ebx, %eax
orl $0x80, %eax
xorl %esi, %esi
testl %ebp, %ebp
cmovel %ebx, %eax
setne %sil
incl %esi
cmpl $0x1013, %ebp           # imm = 0x1013
movl %eax, 0x41935(%rip)     # 0x555f4
movl $0x1, %eax
movl %esi, %edi
cmovel %eax, %edi
addl %edi, %edx
movl %edx, 0x4191f(%rip)     # 0x555f0
movl 0x418a5(%rip), %edi     # 0x5557c
cmpl %edi, %edx
jle 0x13dbd
addl 0x39603(%rip), %edi     # 0x4d2e8
cmpl %edi, %edx
jle 0x13d46
movl %esi, 0x41901(%rip)     # 0x555f0
jmp 0x13ba7
movl %ebx, 0x418fa(%rip)     # 0x555f4
jmp 0x13dbd
cmpl $0x9, %ebx
je 0x13d09
cmpl $0x20, %ebx
jne 0x13c91
cmpl $0x20, %ecx
je 0x13dbd
movl $0x20, 0x418d8(%rip)    # 0x555f4
movl %edx, %eax
incl %eax
movl %eax, 0x418ca(%rip)     # 0x555f0
movl $0x20, %eax
cmpl 0x4184b(%rip), %edx     # 0x5557c
jl 0x13dbd
movl $0x20, 0x418b3(%rip)    # 0x555f4
jmp 0x13bf0
cmpl $0x1013, %ebp           # imm = 0x1013
jne 0x13d75
leal -0x21(%rbx), %ecx
cmpl $0x3e, %ecx
ja 0x13d66
movabsq $0x600000000000800d, %rdx # imm = 0x600000000000800D
btq %rcx, %rdx
jb 0x13dbd
movl $0x1, 0x41880(%rip)     # 0x555f0
jmp 0x13ba7
testl %ebp, %ebp
je 0x13da5
cmpl $0x21, %ebp
jne 0x13d96
leal -0x22(%rbx), %ecx
cmpl $0x35, %ecx
ja 0x13d96
movabsq $0x200200000007ef, %rdx # imm = 0x200200000007EF
btq %rcx, %rdx
jb 0x13dbd
movl $0x2, 0x41850(%rip)     # 0x555f0
jmp 0x13ba7
leal -0x21(%rbx), %edx
cmpl $0x3c, %edx
ja 0x13e24
movabsq $0x1000000046006901, %rsi # imm = 0x1000000046006901
btq %rdx, %rsi
jae 0x13e24
cmpl $0x9, %eax
jle 0x13ddf
cmpl $0x20, %eax
je 0x13de8
cmpl $0xd, %eax
je 0x13e0b
cmpl $0xa, %eax
jne 0x13df8
movq 0x39520(%rip), %rdi     # 0x4d2f8
callq 0x1547a
jmp 0x13df8
testl %eax, %eax
je 0x13e1d
cmpl $0x9, %eax
jne 0x13df8
movq 0x39509(%rip), %rax     # 0x4d2f8
xorl %edi, %edi
movl $0x20, %esi
jmp 0x13e03
movq 0x394f9(%rip), %rax     # 0x4d2f8
movl %ebp, %edi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rax
movq 0x394e6(%rip), %rdi     # 0x4d2f8
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1547a
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpl $0x7d, %ebx
je 0x13dbd
movl %ecx, %edx
andl $-0x21, %edx
addl $-0x41, %edx
cmpl $0x1a, %edx
setb %dl
leal -0x30(%rcx), %esi
cmpl $0xa, %esi
setb %sil
orb %dl, %sil
je 0x13d66
cmpl $0xa, %ecx
je 0x13d66
cmpl $0x20, %ecx
je 0x13d66
testb %cl, %cl
js 0x13d66
jmp 0x13dbd