// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/./bitstream/common.h
// Function: bitstream_xml_escape_chars
static inline size_t bitstream_xml_escape_chars(const char *str, char *out)
{
    size_t len = 1;

    while (*str) {
        uint32_t codepoint = 0xFFFD;
        const char *p = str;
        int size = 1;

        unsigned char c = *str++;
        if (c < 0x80) {
            codepoint = c;
            switch (c) {
                case '<': p = "&lt;"; size = 4; break;
                case '>': p = "&gt;"; size = 4; break;
                case '"': p = "&quot;"; size = 6; break;
                case '\'': p = "&apos;"; size = 6; break;
                case '&': p = "&amp;"; size = 5; break;
            }
        } else if ((c & 0xE0) == 0xC0) {
            if ((str[0] & 0xC0) == 0x80) {
                codepoint = ((c & 0x1F) << 6) |
                    (str[0] & 0x3F);
                size = 2;
                str += 1;
            }
        } else if ((c & 0xF0) == 0xE0) {
            if ((str[0] & 0xC0) == 0x80 &&
                (str[1] & 0xC0) == 0x80) {
                codepoint = ((c & 0x0F) << 12) |
                    ((str[0] & 0x3F) << 6) |
                    (str[1] & 0x3F);
                size = 3;
                str += 2;
            }
        } else if ((c & 0xF8) == 0xF0) {
            if ((str[0] & 0xC0) == 0x80 &&
                (str[1] & 0xC0) == 0x80 &&
                (str[2] & 0xC0) == 0x80) {
                codepoint = ((c & 0x07) << 18) |
                    ((str[0] & 0x3F) << 12) |
                    ((str[1] & 0x3F) << 6) |
                    (str[2] & 0x3F);
                size = 4;
                str += 3;
            }
        }

        // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
        if (codepoint == 0xFFFD ||
            !(codepoint == 0x9 ||
              codepoint == 0xA ||
              codepoint == 0xD ||
              (codepoint >= 0x20 && codepoint <= 0xD7FF) ||
              (codepoint >= 0xE000 && codepoint <= 0xFFFD) ||
              (codepoint >= 0x10000 && codepoint <= 0x10FFFF))) {
            p = "\uFFFD";
            size = 3;
        }

        if (out) {
            memcpy(out, p, size);
            out += size;
        }
        len += size;
    }

    if (out)
        *out = '\0';
    return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x1, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1705b
movl $0xfffd, -0x1c(%rbp)    # imm = 0xFFFD
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb (%rax), %al
movb %al, -0x2d(%rbp)
movzbl -0x2d(%rbp), %eax
cmpl $0x80, %eax
jge 0x16e52
movzbl -0x2d(%rbp), %eax
movl %eax, -0x1c(%rbp)
movzbl -0x2d(%rbp), %eax
addl $-0x22, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x1c, %eax
ja 0x16e4d
movq -0x38(%rbp), %rax
leaq 0xc722(%rip), %rcx      # 0x23504
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xfe8d(%rip), %rax      # 0x26c7f
movq %rax, -0x28(%rbp)
movl $0x4, -0x2c(%rbp)
jmp 0x16e4d
leaq 0xfe7e(%rip), %rax      # 0x26c84
movq %rax, -0x28(%rbp)
movl $0x4, -0x2c(%rbp)
jmp 0x16e4d
leaq 0xfe6f(%rip), %rax      # 0x26c89
movq %rax, -0x28(%rbp)
movl $0x6, -0x2c(%rbp)
jmp 0x16e4d
leaq 0xfe62(%rip), %rax      # 0x26c90
movq %rax, -0x28(%rbp)
movl $0x6, -0x2c(%rbp)
jmp 0x16e4d
leaq 0xfe55(%rip), %rax      # 0x26c97
movq %rax, -0x28(%rbp)
movl $0x5, -0x2c(%rbp)
jmp 0x16fc1
movzbl -0x2d(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x16ea6
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x16ea1
movzbl -0x2d(%rbp), %eax
andl $0x1f, %eax
shll $0x6, %eax
movq -0x8(%rbp), %rcx
movsbl (%rcx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl $0x2, -0x2c(%rbp)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x16fbf
movzbl -0x2d(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x16f1e
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x16f19
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x16f19
movzbl -0x2d(%rbp), %eax
andl $0xf, %eax
shll $0xc, %eax
movq -0x8(%rbp), %rcx
movsbl (%rcx), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl $0x3, -0x2c(%rbp)
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
jmp 0x16fbd
movzbl -0x2d(%rbp), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0x16fbb
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x16fb9
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x16fb9
movq -0x8(%rbp), %rax
movsbl 0x2(%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x16fb9
movzbl -0x2d(%rbp), %eax
andl $0x7, %eax
shll $0x12, %eax
movq -0x8(%rbp), %rcx
movsbl (%rcx), %ecx
andl $0x3f, %ecx
shll $0xc, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movq -0x8(%rbp), %rcx
movsbl 0x2(%rcx), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl $0x4, -0x2c(%rbp)
movq -0x8(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x8(%rbp)
jmp 0x16fbb
jmp 0x16fbd
jmp 0x16fbf
jmp 0x16fc1
cmpl $0xfffd, -0x1c(%rbp)    # imm = 0xFFFD
je 0x1700f
cmpl $0x9, -0x1c(%rbp)
je 0x17021
cmpl $0xa, -0x1c(%rbp)
je 0x17021
cmpl $0xd, -0x1c(%rbp)
je 0x17021
cmpl $0x20, -0x1c(%rbp)
jb 0x16feb
cmpl $0xd7ff, -0x1c(%rbp)    # imm = 0xD7FF
jbe 0x17021
cmpl $0xe000, -0x1c(%rbp)    # imm = 0xE000
jb 0x16ffd
cmpl $0xfffd, -0x1c(%rbp)    # imm = 0xFFFD
jbe 0x17021
cmpl $0x10000, -0x1c(%rbp)   # imm = 0x10000
jb 0x1700f
cmpl $0x10ffff, -0x1c(%rbp)  # imm = 0x10FFFF
jbe 0x17021
leaq 0xfc87(%rip), %rax      # 0x26c9d
movq %rax, -0x28(%rbp)
movl $0x3, -0x2c(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1704a
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x2c(%rbp), %rdx
callq 0x2140
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movslq -0x2c(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x16d78
cmpq $0x0, -0x10(%rbp)
je 0x17069
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)