// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_font/lv_font_fmt_txt.c
// Function: get_kern_value
static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t gid_right)
{
    lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;

    int8_t value = 0;

    if(fdsc->kern_classes == 0) {
        /*Kern pairs*/
        const lv_font_fmt_txt_kern_pair_t * kdsc = fdsc->kern_dsc;
        if(kdsc->glyph_ids_size == 0) {
            /* Use binary search to find the kern value.
             * The pairs are ordered left_id first, then right_id secondly. */
            const uint8_t * g_ids = kdsc->glyph_ids;
            uint16_t g_id_both = (gid_right << 8) + gid_left; /*Create one number from the ids*/
            uint8_t * kid_p = lv_utils_bsearch(&g_id_both, g_ids, kdsc->pair_cnt, 2, kern_pair_8_compare);

            /*If the `g_id_both` were found get its index from the pointer*/
            if(kid_p) {
                lv_uintptr_t ofs = (lv_uintptr_t)(kid_p - g_ids);
                ofs = ofs >> 1;     /*ofs is for pair, divide by 2 to refer as a single value*/
                value = kdsc->values[ofs];
            }
        } else if(kdsc->glyph_ids_size == 1) {
            /* Use binary search to find the kern value.
             * The pairs are ordered left_id first, then right_id secondly. */
            const uint16_t * g_ids = kdsc->glyph_ids;
            lv_uintptr_t g_id_both = (uint32_t)((uint32_t)gid_right << 8) + gid_left; /*Create one number from the ids*/
            uint8_t * kid_p = lv_utils_bsearch(&g_id_both, g_ids, kdsc->pair_cnt, 4, kern_pair_16_compare);

            /*If the `g_id_both` were found get its index from the pointer*/
            if(kid_p) {
                lv_uintptr_t ofs = (lv_uintptr_t) (kid_p - (const uint8_t *)g_ids);
                ofs = ofs >> 4;     /*ofs is 4 byte pairs, divide by 4 to refer as a single value*/
                value = kdsc->values[ofs];
            }

        } else {
            /*Invalid value*/
        }
    } else {
        /*Kern classes*/
        const lv_font_fmt_txt_kern_classes_t * kdsc = fdsc->kern_dsc;
        uint8_t left_class = kdsc->left_class_mapping[gid_left];
        uint8_t right_class = kdsc->left_class_mapping[gid_right];

        /* If class = 0, kerning not exist for that glyph
         * else got the value form `class_pair_values` 2D array*/
        if(left_class > 0 && right_class > 0) {
            value = kdsc->class_pair_values[(left_class-1)* kdsc->right_class_cnt + (right_class-1)];
        }

    }
    return value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x18(%rbp), %rax
movw 0x22(%rax), %ax
shrw $0xd, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x41f8b
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x18, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x41ef9
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x10(%rbp), %eax
shll $0x8, %eax
addl -0xc(%rbp), %eax
movw %ax, -0x32(%rbp)
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x10(%rax), %edx
andl $0xffffff, %edx         # imm = 0xFFFFFF
leaq -0x32(%rbp), %rdi
movl $0x2, %ecx
leaq 0x178(%rip), %r8        # 0x42030
callq 0x47710
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x41ef4
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shrq %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x48(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x19(%rbp)
jmp 0x41f89
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x18, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0x41f85
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x10(%rbp), %eax
shll $0x8, %eax
addl -0xc(%rbp), %eax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x10(%rax), %edx
andl $0xffffff, %edx         # imm = 0xFFFFFF
leaq -0x58(%rbp), %rdi
movl $0x4, %ecx
leaq 0x14a(%rip), %r8        # 0x42090
callq 0x47710
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x41f83
movq -0x60(%rbp), %rax
movq -0x50(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
shrq $0x4, %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x68(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x19(%rbp)
jmp 0x41f87
jmp 0x41f87
jmp 0x41f89
jmp 0x41ff8
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x71(%rbp)
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x10(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x72(%rbp)
movzbl -0x71(%rbp), %eax
cmpl $0x0, %eax
jle 0x41ff6
movzbl -0x72(%rbp), %eax
cmpl $0x0, %eax
jle 0x41ff6
movq -0x70(%rbp), %rax
movq (%rax), %rax
movzbl -0x71(%rbp), %ecx
subl $0x1, %ecx
movq -0x70(%rbp), %rdx
movzbl 0x19(%rdx), %edx
imull %edx, %ecx
movzbl -0x72(%rbp), %edx
subl $0x1, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x19(%rbp)
jmp 0x41ff8
movb -0x19(%rbp), %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)