// File: /workspace/github_c_makefile_star2_O1/nurse[P]nkf/nkf.c
// Function: nfc_getc
static nkf_char
nfc_getc(FILE *f)
{
    nkf_char (*g)(FILE *f) = i_nfc_getc;
    nkf_char (*u)(nkf_char c ,FILE *f) = i_nfc_ungetc;
    nkf_buf_t *buf = nkf_state->nfc_buf;
    const unsigned char *array;
    int lower=0, upper=NORMALIZATION_TABLE_LENGTH-1;
    nkf_char c = (*g)(f);

    if (c == EOF || c > 0xFF || (c & 0xc0) == 0x80) return c;

    nkf_buf_push(buf, c);
    do {
	while (lower <= upper) {
	    int mid = (lower+upper) / 2;
	    int len;
	    array = normalization_table[mid].nfd;
	    for (len=0; len < NORMALIZATION_TABLE_NFD_LENGTH && array[len]; len++) {
		if (len >= nkf_buf_length(buf)) {
		    c = (*g)(f);
		    if (c == EOF) {
			len = 0;
			lower = 1, upper = 0;
			break;
		    }
		    nkf_buf_push(buf, c);
		}
		if (array[len] != nkf_buf_at(buf, len)) {
		    if (array[len] < nkf_buf_at(buf, len)) lower = mid + 1;
		    else  upper = mid - 1;
		    len = 0;
		    break;
		}
	    }
	    if (len > 0) {
		int i;
		array = normalization_table[mid].nfc;
		nkf_buf_clear(buf);
		for (i=0; i < NORMALIZATION_TABLE_NFC_LENGTH && array[i]; i++)
		    nkf_buf_push(buf, array[i]);
		break;
	    }
	}
    } while (lower <= upper);

    while (nkf_buf_length(buf) > 1) (*u)(nkf_buf_pop(buf), f);
    c = nkf_buf_pop(buf);

    return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r12
movq 0x38f1c(%rip), %rcx     # 0x4d390
movq 0x38f1d(%rip), %rbx     # 0x4d398
movq 0x410b6(%rip), %rax     # 0x55538
movq 0x20(%rax), %r14
movq %rcx, 0x20(%rsp)
callq *%rcx
cmpl $-0x1, %eax
sete %cl
cmpl $0x100, %eax            # imm = 0x100
setge %dl
movl %eax, %esi
andl $0xc0, %esi
cmpl $0x80, %esi
sete %sil
orb %cl, %dl
orb %sil, %dl
je 0x144c3
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x18(%rsp)
movq 0x8(%r14), %rcx
cmpq %rcx, (%r14)
jle 0x14645
movq 0x10(%r14), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x8(%r14)
movl %eax, (%rdx,%rcx,4)
movl $0x3ad, %r15d           # imm = 0x3AD
xorl %r9d, %r9d
cmpl %r15d, %r9d
jg 0x14604
movq %r9, 0x10(%rsp)
movq %r15, 0x8(%rsp)
leal (%r15,%r9), %eax
movl %eax, %r15d
shrl $0x1f, %r15d
addl %eax, %r15d
sarl %r15d
movslq %r15d, %rax
leaq (%rax,%rax,2), %r13
shlq $0x2, %r13
addq 0x38a7d(%rip), %r13     # 0x4cfa0
xorl %ebp, %ebp
movzbl 0x3(%r13,%rbp), %ebx
testl %ebx, %ebx
je 0x14580
cmpq %rbp, 0x8(%r14)
jg 0x1455d
movq %r12, %rdi
callq *0x20(%rsp)
cmpl $-0x1, %eax
je 0x145a8
movq 0x8(%r14), %rcx
cmpq %rcx, (%r14)
jle 0x14645
movq 0x10(%r14), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x8(%r14)
movl %eax, (%rdx,%rcx,4)
cmpq %rbp, 0x8(%r14)
jl 0x1464f
movq 0x10(%r14), %rax
movl (%rax,%rbp,4), %eax
cmpl %ebx, %eax
jne 0x1458c
incq %rbp
cmpq $0x9, %rbp
jne 0x14525
movl $0x1, %ebp
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %r15
jmp 0x145b3
leal 0x1(%r15), %ecx
decl %r15d
cmpl %ebx, %eax
movq 0x10(%rsp), %r9
cmovgl %ecx, %r9d
cmovgl 0x8(%rsp), %r15d
xorl %eax, %eax
jmp 0x145b8
xorl %r15d, %r15d
movl $0x1, %r9d
xorl %ebp, %ebp
testl %ebp, %ebp
setne %al
testb %al, %al
je 0x144ed
movq $0x0, 0x8(%r14)
movq $-0x3, %rcx
movzbl 0x3(%r13,%rcx), %edx
testl %edx, %edx
je 0x145f6
movq 0x8(%r14), %rsi
cmpq %rsi, (%r14)
jle 0x14645
movq 0x10(%r14), %rdi
leaq 0x1(%rsi), %r8
movq %r8, 0x8(%r14)
movl %edx, (%rdi,%rsi,4)
incq %rcx
jne 0x145cf
cmpl %r15d, %r9d
setg %cl
orb %cl, %al
je 0x144f6
cmpl %r15d, %r9d
jle 0x144ed
cmpq $0x2, 0x8(%r14)
movq 0x18(%rsp), %rbx
jl 0x1462f
movq %r14, %rdi
callq 0x126a5
movl %eax, %edi
movq %r12, %rsi
callq *%rbx
cmpq $0x1, 0x8(%r14)
jg 0x14619
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x126a5
movl $0x1, %edi
callq 0xc240
leaq 0x40f1(%rip), %rdi      # 0x18747
leaq 0x401f(%rip), %rsi      # 0x1867c
leaq 0x40f5(%rip), %rcx      # 0x18759
movl $0x361, %edx            # imm = 0x361
callq 0xc0f0