// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/lib/utf8_decode.c
// Function: utf8_decode_next
int utf8_decode_next() {
    int c;  /* the first byte of the character */
    int c1; /* the first continuation character */
    int c2; /* the second continuation character */
    int c3; /* the third continuation character */
    int r;  /* the result */

    if (the_index >= the_length) {
        return the_index == the_length ? UTF8_END : UTF8_ERROR;
    }
    the_byte = the_index;
    the_char += 1;
    c = get();
/*
    Zero continuation (0 to 127)
*/
    if ((c & 0x80) == 0) {
        return c;
    }
/*
    One continuation (128 to 2047)
*/
    if ((c & 0xE0) == 0xC0) {
        c1 = cont();
        if (c1 >= 0) {
            r = ((c & 0x1F) << 6) | c1;
            if (r >= 128) {
                return r;
            }
        }

/*
    Two continuations (2048 to 55295 and 57344 to 65535)
*/
    } else if ((c & 0xF0) == 0xE0) {
        c1 = cont();
        c2 = cont();
        if ((c1 | c2) >= 0) {
            r = ((c & 0x0F) << 12) | (c1 << 6) | c2;
            if (r >= 2048 && (r < 55296 || r > 57343)) {
                return r;
            }
        }

/*
    Three continuations (65536 to 1114111)
*/
    } else if ((c & 0xF8) == 0xF0) {
        c1 = cont();
        c2 = cont();
        c3 = cont();
        if ((c1 | c2 | c3) >= 0) {
            r = ((c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3;
            if (r >= 65536 && r <= 1114111) {
                return r;
            }
        }
    }
    return UTF8_ERROR;
}

// Assembly:
movl 0xca6c(%rip), %r8d      # 0x10200
movl 0xca76(%rip), %esi      # 0x10210
cmpl %esi, %r8d
jge 0x381d
pushq %rbp
movq %rsp, %rbp
movslq %r8d, %rcx
movl %r8d, 0xca6b(%rip)      # 0x10218
incl 0xca61(%rip)            # 0x10214
movq 0xca4e(%rip), %rdx      # 0x10208
movzbl (%rdx,%rcx), %eax
incq %rcx
movl %ecx, 0xca39(%rip)      # 0x10200
testb %al, %al
jns 0x39cb
movl %eax, %edi
andl $-0x20, %edi
cmpl $0xc0, %edi
jne 0x3827
cmpl %esi, %ecx
jge 0x39c6
movzbl (%rdx,%rcx), %ecx
addl $0x2, %r8d
movl %r8d, 0xca0d(%rip)      # 0x10200
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0x80, %edx
jne 0x39c6
andl $0x1f, %eax
shll $0x6, %eax
cmpl $0x7f, %eax
jbe 0x39c6
andl $0x3f, %ecx
orl %ecx, %eax
jmp 0x39cb
sete %al
movzbl %al, %eax
orl $-0x2, %eax
retq
movl %eax, %edi
andl $-0x10, %edi
cmpl $0xe0, %edi
jne 0x38e2
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpl %esi, %ecx
jge 0x3859
movzbl (%rdx,%rcx), %edi
addl $0x2, %r8d
movl %r8d, 0xc9aa(%rip)      # 0x10200
movl %r8d, %ecx
movl %edi, %r8d
andl $0xc0, %r8d
andl $0x3f, %edi
cmpl $0x80, %r8d
movl $0xfffffffe, %r8d       # imm = 0xFFFFFFFE
cmovnel %r8d, %edi
cmpl %esi, %ecx
jge 0x388b
movslq %ecx, %rsi
movzbl (%rdx,%rsi), %r9d
incl %ecx
movl %ecx, 0xc975(%rip)      # 0x10200
movl %r9d, %ecx
andl $0xc0, %ecx
andl $0x3f, %r9d
cmpl $0x80, %ecx
cmovel %r9d, %r8d
movl %r8d, %ecx
orl %edi, %ecx
js 0x39c6
shll $0xc, %eax
movzwl %ax, %eax
shll $0x6, %edi
orl %r8d, %edi
orl %eax, %edi
cmpl $0x800, %edi            # imm = 0x800
setge %cl
movl %edi, %eax
addl $0xffff2000, %eax       # imm = 0xFFFF2000
cmpl $0xfffff800, %eax       # imm = 0xFFFFF800
setb %dl
movl %edi, %eax
testb %dl, %cl
je 0x39c6
jmp 0x39cb
movl %eax, %edi
andl $-0x8, %edi
cmpl $0xf0, %edi
jne 0x39c6
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpl %esi, %ecx
jge 0x3914
movzbl (%rdx,%rcx), %edi
addl $0x2, %r8d
movl %r8d, 0xc8ef(%rip)      # 0x10200
movl %r8d, %ecx
movl %edi, %r8d
andl $0xc0, %r8d
andl $0x3f, %edi
cmpl $0x80, %r8d
movl $0xfffffffe, %r8d       # imm = 0xFFFFFFFE
cmovnel %r8d, %edi
cmpl %esi, %ecx
jge 0x3946
movslq %ecx, %r9
movzbl (%rdx,%r9), %r9d
incl %ecx
movl %ecx, 0xc8ba(%rip)      # 0x10200
movl %r9d, %r10d
andl $0xc0, %r10d
andl $0x3f, %r9d
cmpl $0x80, %r10d
cmovel %r9d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
cmpl %esi, %ecx
jge 0x3979
movslq %ecx, %rsi
movzbl (%rdx,%rsi), %r9d
incl %ecx
movl %ecx, 0xc887(%rip)      # 0x10200
movl %r9d, %ecx
andl $0xc0, %ecx
andl $0x3f, %r9d
cmpl $0x80, %ecx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmovel %r9d, %ecx
movl %r8d, %edx
orl %edi, %edx
orl %ecx, %edx
js 0x39c6
andl $0x7, %eax
shll $0x12, %eax
shll $0xc, %edi
shll $0x6, %r8d
orl %edi, %r8d
orl %ecx, %r8d
orl %eax, %r8d
leal -0x10000(%r8), %ecx
movl %r8d, %eax
cmpl $0x100000, %ecx         # imm = 0x100000
jb 0x39cb
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
popq %rbp
retq
nopl (%rax)