// File: /workspace/github_c_makefile_star2_O0/neosploit[P]compiler/libfort/lib/fort.c
// Function: buffer_text_visible_width
FT_INTERNAL
size_t buffer_text_visible_width(const f_string_buffer_t *buffer)
{
    size_t max_length = 0;
    if (buffer->type == CHAR_BUF) {
        size_t n = 0;
        while (1) {
            const char *beg = NULL;
            const char *end = NULL;
            str_n_substring(buffer->str.cstr, '\n', n, &beg, &end);
            if (beg == NULL || end == NULL)
                return max_length;

            max_length = MAX(max_length, (size_t)(end - beg));
            ++n;
        }
#ifdef FT_HAVE_WCHAR
    } else if (buffer->type == W_CHAR_BUF) {
        size_t n = 0;
        while (1) {
            const wchar_t *beg = NULL;
            const wchar_t *end = NULL;
            wstr_n_substring(buffer->str.wstr, L'\n', n, &beg, &end);
            if (beg == NULL || end == NULL)
                return max_length;

            int line_width = mk_wcswidth(beg, (size_t)(end - beg));
            if (line_width < 0) /* For safety */
                line_width = 0;
            max_length = MAX(max_length, (size_t)line_width);

            ++n;
        }
#endif /* FT_HAVE_WCHAR */
#ifdef FT_HAVE_UTF8
    } else if (buffer->type == UTF8_BUF) {
        size_t n = 0;
        while (1) {
            const void *beg = NULL;
            const void *end = NULL;
            utf8_n_substring(buffer->str.u8str, '\n', n, &beg, &end);
            if (beg == NULL || end == NULL)
                return max_length;

            max_length = MAX(max_length, (size_t)utf8_width(beg, end));
            ++n;
        }
#endif /* FT_HAVE_WCHAR */
    }

    return max_length; /* shouldn't be here */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1ab4b
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
movl $0xa, %esi
leaq -0x28(%rbp), %rcx
leaq -0x30(%rbp), %r8
callq 0x1ace0
cmpq $0x0, -0x28(%rbp)
je 0x1aaf8
cmpq $0x0, -0x30(%rbp)
jne 0x1ab05
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1acce
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x1ab23
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x1ab32
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1aabd
movq -0x10(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x1ac09
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
movl $0xa, %esi
leaq -0x40(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x1ad90
cmpq $0x0, -0x40(%rbp)
je 0x1ab9c
cmpq $0x0, -0x48(%rbp)
jne 0x1aba9
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1acce
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rax
subq %rax, %rsi
sarq $0x2, %rsi
callq 0x1ae40
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x1abd1
movl $0x0, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x1abe8
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1abf0
movslq -0x4c(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1ab61
movq -0x10(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jne 0x1acc2
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x58(%rbp), %rdx
movl $0xa, %esi
leaq -0x60(%rbp), %rcx
leaq -0x68(%rbp), %r8
callq 0x1aed0
cmpq $0x0, -0x60(%rbp)
je 0x1ac5a
cmpq $0x0, -0x68(%rbp)
jne 0x1ac64
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1acce
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1af70
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jbe 0x1ac92
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x1aca6
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1af70
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x1ac1f
jmp 0x1acc4
jmp 0x1acc6
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)