// File: /workspace/github_cpp_makefile_star2_O2/rhoot[P]sp/tests/../include/sp.hpp
// Function: sp::format_string(sp::IWriter&, sp::FormatFlags const&, sp::StringView const&)
inline bool format_string(IWriter& writer, const sp::FormatFlags& flags, const StringView& str)
    {
        // determine the amount of characters to write
        auto nchars = str.length;

        if (flags.precision >= 0) {
            nchars = std::min(flags.precision, nchars);
        }

        // determine width
        const int32_t width = std::max(flags.width, nchars);

        // determine alignment
        int32_t leadSpace = 0;
        int32_t tailSpace = 0;

        switch (flags.align) {
        case '^':
            leadSpace = (width / 2) - ((nchars + 1) / 2); // nchars rounded up
            tailSpace = ((width + 1) / 2) - (nchars / 2); // width rounded up
            leadSpace += (width & 1) & (nchars & 1); // if both are odd, we need to add one for correction
            tailSpace -= (width & 1) & (nchars & 1); // if both are odd, we need to remove one for correction
            break;
        case '>':
            leadSpace = width - nchars;
            break;
        case '<':
        default:
            tailSpace = width - nchars;
            break;
        }

        // apply leading padding
        const char fill = flags.fill ? flags.fill : ' ';

        while (leadSpace--) {
            write_char(writer, fill);
        }

        // write string
        writer.write(nchars, str.ptr);

        // apply tailing padding
        while (tailSpace--) {
            write_char(writer, fill);
        }

        return true;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x8(%rdx), %eax
movl 0x4(%rsi), %ecx
movl 0x8(%rsi), %edi
cmpl %edi, %eax
movl %edi, %r10d
cmovll %eax, %r10d
testl %edi, %edi
cmovsl %eax, %r10d
cmpl %r10d, %ecx
cmovlel %r10d, %ecx
movzbl 0x1(%rsi), %eax
cmpl $0x3e, %eax
movq %rdx, -0x40(%rbp)
movq %r10, -0x38(%rbp)
je 0xfe71
cmpl $0x5e, %eax
jne 0xfe7c
pushq $0x2
popq %r8
movl %ecx, %eax
cltd
idivl %r8d
movl %eax, %edi
leal 0x1(%r10), %eax
pushq $-0x2
popq %r9
cltd
idivl %r9d
movl %eax, %r13d
leal 0x1(%rcx), %eax
cltd
idivl %r8d
movl %eax, %r8d
movl %r10d, %eax
cltd
idivl %r9d
movl %eax, %r12d
andl %r10d, %ecx
andl $0x1, %ecx
addl %ecx, %r13d
addl %edi, %r13d
subl %ecx, %r12d
addl %r8d, %r12d
jmp 0xfe85
subl %r10d, %ecx
xorl %r12d, %r12d
movl %ecx, %r13d
jmp 0xfe85
subl %r10d, %ecx
xorl %r13d, %r13d
movl %ecx, %r12d
movl (%rsi), %eax
testb %al, %al
pushq $0x20
popq %r14
cmovnel %eax, %r14d
leaq -0x29(%rbp), %r15
subl $0x1, %r13d
jb 0xfeaf
movb %r14b, -0x29(%rbp)
movq (%rbx), %rax
movq %rbx, %rdi
pushq $0x1
popq %rsi
movq %r15, %rdx
callq *(%rax)
jmp 0xfe95
movslq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rax
movq (%rax), %rdx
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
pushq $0x1
popq %r13
leaq -0x2a(%rbp), %r15
subl $0x1, %r12d
jb 0xfee4
movb %r14b, -0x2a(%rbp)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq *(%rax)
jmp 0xfeca
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq