// File: /workspace/github_c_makefile_star2_O0/neosploit[P]compiler/libfort/lib/fort.c
// Function: utf8catcodepoint
void *utf8catcodepoint(void *utf8_restrict str, utf8_int32_t chr, size_t n)
{
    char *s = (char *)str;

    if (0 == ((utf8_int32_t)0xffffff80 & chr)) {
        // 1-byte/7-bit ascii
        // (0b0xxxxxxx)
        if (n < 1) {
            return utf8_null;
        }
        s[0] = (char)chr;
        s += 1;
    } else if (0 == ((utf8_int32_t)0xfffff800 & chr)) {
        // 2-byte/11-bit utf8 code point
        // (0b110xxxxx 0b10xxxxxx)
        if (n < 2) {
            return utf8_null;
        }
        s[0] = 0xc0 | (char)(chr >> 6);
        s[1] = 0x80 | (char)(chr & 0x3f);
        s += 2;
    } else if (0 == ((utf8_int32_t)0xffff0000 & chr)) {
        // 3-byte/16-bit utf8 code point
        // (0b1110xxxx 0b10xxxxxx 0b10xxxxxx)
        if (n < 3) {
            return utf8_null;
        }
        s[0] = 0xe0 | (char)(chr >> 12);
        s[1] = 0x80 | (char)((chr >> 6) & 0x3f);
        s[2] = 0x80 | (char)(chr & 0x3f);
        s += 3;
    } else { // if (0 == ((int)0xffe00000 & chr)) {
        // 4-byte/21-bit utf8 code point
        // (0b11110xxx 0b10xxxxxx 0b10xxxxxx 0b10xxxxxx)
        if (n < 4) {
            return utf8_null;
        }
        s[0] = 0xf0 | (char)(chr >> 18);
        s[1] = 0x80 | (char)((chr >> 12) & 0x3f);
        s[2] = 0x80 | (char)((chr >> 6) & 0x3f);
        s[3] = 0x80 | (char)(chr & 0x3f);
        s += 4;
    }

    return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %ecx
andl $0xffffff80, %ecx       # imm = 0xFFFFFF80
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x12536
cmpq $0x1, -0x20(%rbp)
jae 0x1251a
movq $0x0, -0x8(%rbp)
jmp 0x12699
movl -0x14(%rbp), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x12691
movl -0x14(%rbp), %ecx
andl $0xfffff800, %ecx       # imm = 0xFFFFF800
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x12597
cmpq $0x2, -0x20(%rbp)
jae 0x12559
movq $0x0, -0x8(%rbp)
jmp 0x12699
movl -0x14(%rbp), %eax
sarl $0x6, %eax
movsbl %al, %eax
orl $0xc0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movl -0x14(%rbp), %eax
andl $0x3f, %eax
movsbl %al, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
jmp 0x1268f
movl -0x14(%rbp), %ecx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1260f
cmpq $0x3, -0x20(%rbp)
jae 0x125ba
movq $0x0, -0x8(%rbp)
jmp 0x12699
movl -0x14(%rbp), %eax
sarl $0xc, %eax
movsbl %al, %eax
orl $0xe0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movl -0x14(%rbp), %eax
sarl $0x6, %eax
andl $0x3f, %eax
movsbl %al, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x14(%rbp), %eax
andl $0x3f, %eax
movsbl %al, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x28(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x28(%rbp)
jmp 0x1268d
cmpq $0x4, -0x20(%rbp)
jae 0x12620
movq $0x0, -0x8(%rbp)
jmp 0x12699
movl -0x14(%rbp), %eax
sarl $0x12, %eax
movsbl %al, %eax
orl $0xf0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movl -0x14(%rbp), %eax
sarl $0xc, %eax
andl $0x3f, %eax
movsbl %al, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x14(%rbp), %eax
sarl $0x6, %eax
andl $0x3f, %eax
movsbl %al, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x14(%rbp), %eax
andl $0x3f, %eax
movsbl %al, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0x1268f
jmp 0x12691
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nop