// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_label.c
// Function: lv_label_is_char_under_pos
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
{
    LV_ASSERT_OBJ(label, LV_OBJX_NAME);
    LV_ASSERT_NULL(pos);

    const char * txt         = lv_label_get_text(label);
    lv_label_ext_t * ext     = lv_obj_get_ext_attr(label);
    uint32_t line_start      = 0;
    uint32_t new_line_start  = 0;
    lv_coord_t max_w         = lv_obj_get_width(label);
    const lv_style_t * style = lv_obj_get_style(label);
    const lv_font_t * font   = style->text.font;
    uint8_t letter_height    = lv_font_get_line_height(font);
    lv_coord_t y             = 0;
    lv_txt_flag_t flag       = LV_TXT_FLAG_NONE;
    lv_label_align_t align = lv_label_get_align(label);

    if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
    if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
    if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;

    /*If the width will be expanded set the max length to very big */
    if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
        max_w = LV_COORD_MAX;
    }

    /*Search the line of the index letter */;
    while(txt[line_start] != '\0') {
        new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);

        if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/
        y += letter_height + style->text.line_space;

        line_start = new_line_start;
    }

    /*Calculate the x coordinate*/
    lv_coord_t x      = 0;
    lv_coord_t last_x = 0;
    if(align == LV_LABEL_ALIGN_CENTER) {
        lv_coord_t line_w;
        line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag);
        x += lv_obj_get_width(label) / 2 - line_w / 2;
    }
    else if(align == LV_LABEL_ALIGN_RIGHT) {
        lv_coord_t line_w;
        line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag);
        x += lv_obj_get_width(label) - line_w;
    }

    lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;

    uint32_t i           = line_start;
    uint32_t i_current   = i;
    uint32_t letter      = '\0';
    uint32_t letter_next = '\0';

    if(new_line_start > 0) {
        while(i <= new_line_start - 1) {
            /* Get the current letter
             * Be careful 'i' already points to the next character */
            letter = lv_txt_encoded_next(txt, &i);

            /*Get the next letter for kerning*/
            letter_next = lv_txt_encoded_next(&txt[i], NULL);

            /*Handle the recolor command*/
            if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
                if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
                    continue; /*Skip the letter is it is part of a command*/
                }
            }
            last_x = x;
            x += lv_font_get_glyph_width(font, letter, letter_next);
            if(pos->x < x) {
                i = i_current;
                break;
            }
            x += style->text.letter_space;
            i_current = i;
        }
    }

    int32_t max_diff = lv_font_get_glyph_width(font, letter, letter_next) + style->text.letter_space + 1;
    return (pos->x >= (last_x - style->text.letter_space) && pos->x <= (last_x + max_diff));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r13
callq 0x7994
testb %al, %al
je 0x19f0b
movq %rbx, %rdi
callq 0x7994
testb %al, %al
je 0x19f1c
movq %rbx, 0x20(%rsp)
movq %r13, %rdi
callq 0x18db9
movq %rax, %r12
movq %r13, %rdi
callq 0x6747
movq %rax, %rbx
movq %r13, %rdi
callq 0x5308
movl %eax, %r15d
movq %r13, %rdi
callq 0x6316
movq %rax, %r14
movq 0x28(%rax), %rax
movq %rax, 0x10(%rsp)
movzbl 0x10(%rax), %eax
movl %eax, 0x18(%rsp)
movq %r13, 0x30(%rsp)
movq %r13, %rdi
callq 0x18d7f
movzwl 0x18(%rbx), %esi
movl %esi, %ecx
shrb $0x6, %cl
movl %ecx, %edx
andb $0x1, %dl
orb $0x2, %cl
testb %sil, %sil
movzbl %dl, %edx
movzbl %cl, %edi
cmovnsl %edx, %edi
leal 0x4(%rdi), %ecx
movb %al, 0x6(%rsp)
cmpb $0x1, %al
movzbl %cl, %eax
movq %r14, %rbx
movq %rdi, 0x40(%rsp)
movl %edi, %edx
movl %eax, 0x28(%rsp)
cmovel %eax, %edx
testb $0x7, %sil
movl $0x7c18, %eax           # imm = 0x7C18
cmovnel %r15d, %eax
xorl %r14d, %r14d
cwtl
movl %eax, 0xc(%rsp)
movl %edx, 0x2c(%rsp)
movzbl %dl, %ebp
xorl %edx, %edx
movl %edx, %eax
leaq (%r12,%rax), %r15
cmpb $0x0, (%r12,%rax)
je 0x19f2d
movl %edx, %r13d
movswl 0x30(%rbx), %edx
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %ecx
movl %ebp, %r8d
callq 0x28866
movl %r13d, %edx
movzwl %ax, %r13d
addl %edx, %r13d
movq 0x20(%rsp), %rax
movswl 0x2(%rax), %eax
movswl %r14w, %r14d
addl 0x18(%rsp), %r14d
cmpl %eax, %r14d
jge 0x19f30
movzwl 0x32(%rbx), %eax
addl %eax, %r14d
movl %r13d, %edx
jmp 0x19eb6
leaq 0x21232(%rip), %rdi     # 0x3b144
movq %r13, %rsi
callq 0x7b01
jmp 0x19f1a
leaq 0x21221(%rip), %rdi     # 0x3b144
movq %rbx, %rsi
callq 0x7b01
jmp 0x19f2b
movl %edx, %r13d
movb 0x6(%rsp), %al
cmpb $0x1, %al
movq %rbx, 0x38(%rsp)
jne 0x19f85
movl %r13d, %eax
subl %edx, %eax
movswl 0x30(%rbx), %ecx
movzwl %ax, %esi
movq %r15, %rdi
movl %edx, %ebp
movq 0x10(%rsp), %rdx
movl 0x28(%rsp), %r8d
callq 0x28bb3
movl %eax, %ebx
movq 0x30(%rsp), %rdi
callq 0x5308
movw $0x2, %cx
cwtd
idivw %cx
movl %eax, %ecx
movl %ebx, %eax
cwtd
movw $0xfffe, %si            # imm = 0xFFFE
idivw %si
movl %ebp, %edx
addl %ecx, %eax
jmp 0x19fbe
cmpb $0x2, %al
jne 0x19fbc
movl %r13d, %eax
subl %edx, %eax
movswl 0x30(%rbx), %ecx
movzwl %ax, %esi
movzbl 0x40(%rsp), %r8d
movq %r15, %rdi
movl %edx, %ebp
movq 0x10(%rsp), %rdx
callq 0x28bb3
movl %eax, %ebx
movq 0x30(%rsp), %rdi
callq 0x5308
movl %ebp, %edx
subl %ebx, %eax
jmp 0x19fbe
xorl %eax, %eax
movb $0x0, 0x7(%rsp)
movl %edx, 0x8(%rsp)
testl %r13d, %r13d
je 0x1a068
movl %edx, 0xc(%rsp)
decl %r13d
movq $0x0, 0x18(%rsp)
leaq 0x37649(%rip), %r15     # 0x51630
xorl %ebp, %ebp
xorl %ebx, %ebx
movl %eax, %r14d
cmpl %r13d, 0x8(%rsp)
ja 0x1a061
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq *(%r15)
movl %eax, %ebp
movl 0x8(%rsp), %edi
addq %r12, %rdi
xorl %esi, %esi
callq *(%r15)
movl %eax, %ebx
testb $0x1, 0x2c(%rsp)
je 0x1a02e
movl 0x8(%rsp), %eax
movsbl (%r12,%rax), %esi
leaq 0x7(%rsp), %rdi
callq 0x28c9d
testb %al, %al
jne 0x19fee
movq 0x10(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x2603b
addl %r14d, %eax
movq 0x20(%rsp), %rcx
cmpw %ax, (%rcx)
jl 0x1a0bc
movq 0x38(%rsp), %rcx
addw 0x30(%rcx), %ax
movl 0x8(%rsp), %ecx
movl %ecx, 0xc(%rsp)
movq %r14, 0x18(%rsp)
jmp 0x19feb
movq 0x18(%rsp), %r14
jmp 0x1a06f
xorl %r14d, %r14d
xorl %ebp, %ebp
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x2603b
movq 0x38(%rsp), %rcx
movswl 0x30(%rcx), %edx
movq 0x20(%rsp), %rcx
movswl (%rcx), %ecx
movswl %r14w, %esi
movl %esi, %edi
subl %edx, %edi
cmpl %ecx, %edi
jle 0x1a09e
xorl %eax, %eax
jmp 0x1a0ad
movzwl %ax, %eax
addl %eax, %esi
leal (%rdx,%rsi), %eax
incl %eax
cmpl %ecx, %eax
setge %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xc(%rsp), %eax
movl %eax, 0x8(%rsp)
jmp 0x1a06f