// File: /workspace/github_c_makefile_star2_O0/ccxvii[P]mujs/./utf.c
// Function: jsU_chartorune
int
chartorune(Rune *rune, const char *str)
{
	int c, c1, c2, c3;
	int l;

	/* overlong null character */
	if((uchar)str[0] == 0xc0 && (uchar)str[1] == 0x80) {
		*rune = 0;
		return 2;
	}

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

	/*
	 * two character sequence
	 *	0080-07FF => T2 Tx
	 */
	c1 = *(uchar*)(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 = *(uchar*)(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 = *(uchar*)(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
cmpl $0xc0, %eax
jne 0x19d5f
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x80, %eax
jne 0x19d5f
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0x19ed6
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x80, -0x1c(%rbp)
jge 0x19d87
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x19ed6
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 0x19da9
jmp 0x19ec5
cmpl $0xe0, -0x1c(%rbp)
jge 0x19df1
cmpl $0xc0, -0x1c(%rbp)
jge 0x19dc0
jmp 0x19ec5
movl -0x1c(%rbp), %eax
shll $0x6, %eax
orl -0x20(%rbp), %eax
andl $0x7ff, %eax            # imm = 0x7FF
movl %eax, -0x2c(%rbp)
cmpl $0x7f, -0x2c(%rbp)
jg 0x19ddc
jmp 0x19ec5
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0x19ed6
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 0x19e13
jmp 0x19ec5
cmpl $0xf0, -0x1c(%rbp)
jge 0x19e56
movl -0x1c(%rbp), %eax
shll $0x6, %eax
orl -0x20(%rbp), %eax
shll $0x6, %eax
orl -0x24(%rbp), %eax
andl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0x2c(%rbp)
cmpl $0x7ff, -0x2c(%rbp)     # imm = 0x7FF
jg 0x19e41
jmp 0x19ec5
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x3, -0x4(%rbp)
jmp 0x19ed6
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 0x19e75
jmp 0x19ec5
cmpl $0xf8, -0x1c(%rbp)
jge 0x19ec3
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
movl %eax, -0x2c(%rbp)
cmpl $0xffff, -0x2c(%rbp)    # imm = 0xFFFF
jg 0x19ea6
jmp 0x19ec5
cmpl $0x10ffff, -0x2c(%rbp)  # imm = 0x10FFFF
jle 0x19eb1
jmp 0x19ec5
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x4, -0x4(%rbp)
jmp 0x19ed6
jmp 0x19ec5
movq -0x10(%rbp), %rax
movl $0xfffd, (%rax)         # imm = 0xFFFD
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)