// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl %r8d, -0x48(%rbp)
movl %ecx, %eax
movl -0x48(%rbp), %ecx
movl %eax, -0x44(%rbp)
movq %rdx, %rax
movl -0x44(%rbp), %edx
movq %rax, -0x40(%rbp)
movq %rsi, %rax
movq -0x40(%rbp), %rsi
movq %rax, -0x38(%rbp)
movq %rdi, %r8
movq -0x38(%rbp), %rdi
movw %r9w, %ax
movb 0x10(%rbp), %r9b
movq %r8, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %dx, -0x1a(%rbp)
movw %cx, -0x1c(%rbp)
movw %ax, -0x1e(%rbp)
movq -0x8(%rbp), %rax
movw $0x0, (%rax)
movq -0x8(%rbp), %rax
movw $0x0, 0x2(%rax)
cmpq $0x0, -0x10(%rbp)
jne 0x4688f
jmp 0x46a0f
cmpq $0x0, -0x18(%rbp)
jne 0x4689b
jmp 0x46a0f
movzbl 0x10(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x468ad
movw $0x7c18, -0x1e(%rbp)    # imm = 0x7C18
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x46a20
movb %al, -0x2b(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x46997
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movw -0x1a(%rbp), %cx
movw -0x1e(%rbp), %ax
movswl %cx, %edx
movswl %ax, %ecx
movzbl 0x10(%rbp), %r8d
callq 0x46a40
movzwl %ax, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movzbl -0x2b(%rbp), %edx
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x2(%rax)
movswl -0x1c(%rbp), %edx
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x2(%rax)
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rdx
movw -0x1a(%rbp), %ax
movzwl %cx, %esi
movswl %ax, %ecx
movzbl 0x10(%rbp), %r8d
callq 0x46bd0
movw %ax, -0x2a(%rbp)
movswl -0x2a(%rbp), %eax
movq -0x8(%rbp), %rcx
movswl (%rcx), %ecx
cmpl %ecx, %eax
jle 0x46975
movswl -0x2a(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x4697f
movq -0x8(%rbp), %rax
movswl (%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, (%rax)
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x468c7
cmpl $0x0, -0x24(%rbp)
je 0x469df
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x469c7
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x469df
movzbl -0x2b(%rbp), %edx
movswl -0x1c(%rbp), %eax
addl %eax, %edx
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x2(%rax)
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x469fd
movzbl -0x2b(%rbp), %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x2(%rax)
jmp 0x46a0f
movswl -0x1c(%rbp), %edx
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %ecx
subl %edx, %ecx
movw %cx, 0x2(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)