// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_misc/lv_txt.c
// Function: lv_txt_get_size
void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space,
                     lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag)
{
    size_res->x = 0;
    size_res->y = 0;

    if(text == NULL) return;
    if(font == NULL) return;

    if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;

    uint32_t line_start     = 0;
    uint32_t new_line_start = 0;
    lv_coord_t act_line_length;
    uint8_t letter_height = lv_font_get_line_height(font);

    /*Calc. the height and longest line*/
    while(text[line_start] != '\0') {
        new_line_start += lv_txt_get_next_line(&text[line_start], font, letter_space, max_width, flag);
        size_res->y += letter_height;
        size_res->y += line_space;

        /*Calculate the the longest line*/
        act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space, flag);

        size_res->x = LV_MATH_MAX(act_line_length, size_res->x);
        line_start  = new_line_start;
    }

    /*Ma ke the text one line taller if the last character is '\n' or '\r'*/
    if((line_start != 0) && (text[line_start - 1] == '\n' || text[line_start - 1] == '\r')) {
        size_res->y += letter_height + line_space;
    }

    /*Correction with the last line space or set the height manually if the text is empty*/
    if(size_res->y == 0)
        size_res->y = letter_height;
    else
        size_res->y -= line_space;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r10
movq %rdi, 0x8(%rsp)
andl $0x0, (%rdi)
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %sil
orb %al, %sil
jne 0x28857
movb 0x80(%rsp), %al
testb $0x2, %al
movl $0x7c18, %r11d          # imm = 0x7C18
cmovel %r9d, %r11d
movq %rdx, 0x40(%rsp)
movzbl 0x10(%rdx), %edi
movq %r8, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
leal (%r8,%rdi), %edx
movl %edx, 0x4(%rsp)
xorl %edx, %edx
movswl %cx, %ecx
movl %ecx, 0x1c(%rsp)
movswl %r11w, %ecx
movl %ecx, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x14(%rsp)
movq %r10, 0x38(%rsp)
movq 0x40(%rsp), %r14
movl 0x1c(%rsp), %ebx
movl 0x14(%rsp), %r12d
movq 0x8(%rsp), %rbp
movl %edx, %r15d
cmpb $0x0, (%r10,%r15)
je 0x28817
movq %rdx, 0x20(%rsp)
addq %r10, %r15
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl 0x18(%rsp), %ecx
movl %r12d, %r8d
callq 0x28866
movzwl %ax, %r13d
movl 0x4(%rsp), %eax
addw %ax, 0x2(%rbp)
movq %r15, %rdi
movl %r13d, %esi
movq %r14, %rdx
movl %ebx, %ecx
movl %r12d, %r8d
callq 0x28bb3
movzwl (%rbp), %ecx
cmpw %cx, %ax
jle 0x28800
movl %eax, %ecx
movq 0x20(%rsp), %rdx
addl %r13d, %edx
movq 0x8(%rsp), %rax
movw %cx, (%rax)
movq 0x38(%rsp), %r10
jmp 0x287b0
testl %edx, %edx
je 0x28839
decl %edx
movzbl (%r10,%rdx), %eax
cmpl $0xd, %eax
je 0x2882c
cmpl $0xa, %eax
jne 0x28839
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
addw %cx, 0x2(%rax)
movq 0x8(%rsp), %rdx
movzwl 0x2(%rdx), %eax
movl %eax, %ecx
subl 0x30(%rsp), %ecx
testw %ax, %ax
movq 0x28(%rsp), %rax
cmovnel %ecx, %eax
movw %ax, 0x2(%rdx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq