// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_font/lv_font_fmt_txt.c
// Function: get_glyph_dsc_id
static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
{
    if(letter == '\0') return 0;

    lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;

    /*Check the cache first*/
    if(letter == fdsc->last_letter) return fdsc->last_glyph_id;

    uint16_t i;
    for(i = 0; i < fdsc->cmap_num; i++) {

        /*Relative code point*/
        uint32_t rcp = letter - fdsc->cmaps[i].range_start;
        if(rcp > fdsc->cmaps[i].range_length) continue;
        uint32_t glyph_id = 0;
        if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY) {
            glyph_id = fdsc->cmaps[i].glyph_id_start + rcp;
        }
        else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL) {
            const uint8_t * gid_ofs_8 = fdsc->cmaps[i].glyph_id_ofs_list;
            glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp];
        }
        else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) {
            uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);

            if(p) {
                lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t *) fdsc->cmaps[i].unicode_list);
                ofs = ofs >> 1;     /*The list stores `uint16_t` so the get the index divide by 2*/
                glyph_id = fdsc->cmaps[i].glyph_id_start + ofs;
            }
        }
        else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_FULL) {
            uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);

            if(p) {
                lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t*) fdsc->cmaps[i].unicode_list);
                ofs = ofs >> 1;     /*The list stores `uint16_t` so the get the index divide by 2*/
                const uint8_t * gid_ofs_16 = fdsc->cmaps[i].glyph_id_ofs_list;
                glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_16[ofs];
            }
        }

        /*Update the cache*/
        fdsc->last_letter = letter;
        fdsc->last_glyph_id = glyph_id;
        return glyph_id;
    }

    fdsc->last_letter = letter;
    fdsc->last_glyph_id = 0;
    return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x41841
movl $0x0, -0x4(%rbp)
jmp 0x41b5d
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jne 0x41868
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x41b5d
movw $0x0, -0x22(%rbp)
movzwl -0x22(%rbp), %eax
movq -0x20(%rbp), %rcx
movw 0x22(%rcx), %cx
andw $0x3ff, %cx             # imm = 0x3FF
movzwl %cx, %ecx
cmpl %ecx, %eax
jge 0x41b41
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movzwl -0x22(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
subl (%rcx), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movzwl -0x22(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movzwl 0x4(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x418c8
jmp 0x41b30
movl $0x0, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzbl 0x1a(%rax), %eax
cmpl $0x0, %eax
jne 0x4190d
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x41b14
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzbl 0x1a(%rax), %eax
cmpl $0x1, %eax
jne 0x41970
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
movq -0x38(%rbp), %rcx
movl -0x28(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x41b12
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzbl 0x1a(%rax), %eax
cmpl $0x2, %eax
jne 0x41a2e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x18(%rax), %edx
leaq -0x28(%rbp), %rdi
movl $0x2, %ecx
leaq 0x642(%rip), %r8        # 0x42010
callq 0x47710
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x41a29
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movzwl -0x22(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shrq %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
addq -0x48(%rbp), %rax
movl %eax, -0x2c(%rbp)
jmp 0x41b10
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzbl 0x1a(%rax), %eax
cmpl $0x3, %eax
jne 0x41b0e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x18(%rax), %edx
leaq -0x28(%rbp), %rdi
movl $0x2, %ecx
leaq 0x584(%rip), %r8        # 0x42010
callq 0x47710
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x41b0c
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movzwl -0x22(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movzwl -0x22(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x41b0e
jmp 0x41b10
jmp 0x41b12
jmp 0x41b14
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x28(%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x41b5d
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
jmp 0x4186e
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x28(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)