// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq 0x385e8(%rip), %rbp     # 0x4c380
movq 0x385e9(%rip), %r15     # 0x4c388
movq 0x40782(%rip), %rax     # 0x54528
movq 0x20(%rax), %r14
callq *%rbp
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 0x13de2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x18(%rsp)
movq %r14, %rdi
movl %eax, %esi
callq 0x1237a
movl $0x3ad, %ecx            # imm = 0x3AD
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
addl %ecx, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %rax, 0x20(%rsp)
cltq
imulq $0xc, %rax, %r13
addq 0x38194(%rip), %r13     # 0x4bfb0
movq 0x8(%rsp), %rax
cmpl %eax, 0x10(%rsp)
jg 0x13ee4
xorl %r12d, %r12d
cmpq $0x9, %r12
je 0x13e77
movzbl 0x3(%r13,%r12), %r15d
testl %r15d, %r15d
je 0x13e72
cmpq %r12, 0x8(%r14)
jg 0x13e5d
movq %rbx, %rdi
callq *%rbp
cmpl $-0x1, %eax
je 0x13eda
movq %r14, %rdi
movl %eax, %esi
callq 0x1237a
movq %r14, %rdi
movl %r12d, %esi
callq 0x14c7c
cmpl %r15d, %eax
jne 0x13eae
incq %r12
jmp 0x13e2e
testq %r12, %r12
je 0x13e1c
andq $0x0, 0x8(%r14)
xorl %r15d, %r15d
movq 0x10(%rsp), %r12
cmpq $0x3, %r15
je 0x13ea1
movzbl (%r13,%r15), %esi
testl %esi, %esi
je 0x13ea1
movq %r14, %rdi
callq 0x1237a
incq %r15
jmp 0x13e84
cmpl 0x8(%rsp), %r12d
jle 0x13e1c
jmp 0x13ee4
movq %r14, %rdi
movl %r12d, %esi
callq 0x14c7c
movq 0x20(%rsp), %rdx
leal 0x1(%rdx), %ecx
decl %edx
cmpl %r15d, %eax
movq 0x10(%rsp), %rax
cmovgl %ecx, %eax
cmovgl 0x8(%rsp), %edx
movl %edx, %ecx
jmp 0x13df8
xorl %ecx, %ecx
pushq $0x1
popq %rax
jmp 0x13df8
movq 0x18(%rsp), %r12
movq 0x8(%r14), %r15
movq %r14, %rdi
callq 0x12340
cmpq $0x2, %r15
jl 0x13dd3
movl %eax, %edi
movq %rbx, %rsi
callq *%r12
jmp 0x13ee9