// File: /workspace/github_c_makefile_star2_O0/phase[P]o/libregexp/utf.c
// Function: chartorune
int
chartorune(Rune *rune, char *str)
{
	int c, c1, c2, c3;
	long l;

	/*
	 * one character sequence
	 *	00000-0007F => T1
	 */
	c = *(unsigned char*)str;
	if(c < Tx) {
		*rune = c;
		return 1;
	}

	/*
	 * two character sequence
	 *	0080-07FF => T2 Tx
	 */
	c1 = *(unsigned char*)(str+1) ^ Tx;
	if(c1 & Testx)
		goto bad;
	if(c < T3) {
		if(c < T2)
			goto bad;
		l = ((c << Bitx) | c1) & Rune2;
		if(l <= Rune1)
			goto bad;
		*rune = l;
		return 2;
	}

	/*
	 * three character sequence
	 *	0800-FFFF => T3 Tx Tx
	 */
	c2 = *(unsigned char*)(str+2) ^ Tx;
	if(c2 & Testx)
		goto bad;
	if(c < T4) {
		l = ((((c << Bitx) | c1) << Bitx) | c2) & Rune3;
		if(l <= Rune2)
			goto bad;
		*rune = l;
		return 3;
	}

	/*
	 * four character sequence
	 *	10000-10FFFF => T4 Tx Tx Tx
	 */
	if(UTFmax >= 4) {
		c3 = *(unsigned char*)(str+3) ^ Tx;
		if(c3 & Testx)
			goto bad;
		if(c < T5) {
			l = ((((((c << Bitx) | c1) << Bitx) | c2) << Bitx) | c3) & Rune4;
			if(l <= Rune3)
				goto bad;
			if(l > Runemax)
				goto bad;
			*rune = l;
			return 4;
		}
	}

	/*
	 * bad decoding
	 */
bad:
	*rune = Bad;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x80, -0x1c(%rbp)
jge 0xa924
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0xaa89
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
xorl $0x80, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
je 0xa946
jmp 0xaa78
cmpl $0xe0, -0x1c(%rbp)
jge 0xa995
cmpl $0xc0, -0x1c(%rbp)
jge 0xa95d
jmp 0xaa78
movl -0x1c(%rbp), %eax
shll $0x6, %eax
orl -0x20(%rbp), %eax
andl $0x7ff, %eax            # imm = 0x7FF
cltq
movq %rax, -0x30(%rbp)
cmpq $0x7f, -0x30(%rbp)
jg 0xa97d
jmp 0xaa78
movq -0x30(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0xaa89
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
xorl $0x80, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
je 0xa9b7
jmp 0xaa78
cmpl $0xf0, -0x1c(%rbp)
jge 0xaa01
movl -0x1c(%rbp), %eax
shll $0x6, %eax
orl -0x20(%rbp), %eax
shll $0x6, %eax
orl -0x24(%rbp), %eax
andl $0xffff, %eax           # imm = 0xFFFF
cltq
movq %rax, -0x30(%rbp)
cmpq $0x7ff, -0x30(%rbp)     # imm = 0x7FF
jg 0xa9e9
jmp 0xaa78
movq -0x30(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x3, -0x4(%rbp)
jmp 0xaa89
movq -0x18(%rbp), %rax
movzbl 0x3(%rax), %eax
xorl $0x80, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
je 0xaa20
jmp 0xaa78
cmpl $0xf8, -0x1c(%rbp)
jge 0xaa76
movl -0x1c(%rbp), %eax
shll $0x6, %eax
orl -0x20(%rbp), %eax
shll $0x6, %eax
orl -0x24(%rbp), %eax
shll $0x6, %eax
orl -0x28(%rbp), %eax
andl $0x1fffff, %eax         # imm = 0x1FFFFF
cltq
movq %rax, -0x30(%rbp)
cmpq $0xffff, -0x30(%rbp)    # imm = 0xFFFF
jg 0xaa55
jmp 0xaa78
cmpq $0x10ffff, -0x30(%rbp)  # imm = 0x10FFFF
jle 0xaa61
jmp 0xaa78
movq -0x30(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x4, -0x4(%rbp)
jmp 0xaa89
jmp 0xaa78
movq -0x10(%rbp), %rax
movl $0xfffd, (%rax)         # imm = 0xFFFD
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop