// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_kb.c
// Function: lv_kb_create
lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("keyboard create started");

    /*Create the ancestor of keyboard*/
    lv_obj_t * new_kb = lv_btnm_create(par, copy);
    LV_ASSERT_MEM(new_kb);
    if(new_kb == NULL) return NULL;

    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_kb);

    /*Allocate the keyboard type specific extended data*/
    lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    /*Initialize the allocated 'ext' */

    ext->ta         = NULL;
    ext->mode       = LV_KB_MODE_TEXT;
    ext->cursor_mng = 0;

    /*The signal and design functions are not copied so set them here*/
    lv_obj_set_signal_cb(new_kb, lv_kb_signal);

    /*Init the new keyboard keyboard*/
    if(copy == NULL) {
        /* Set a size which fits into the parent.
         * Don't use `par` directly because if the window is created on a page it is moved to the
         * scrollable so the parent has changed */
        lv_obj_set_size(new_kb, lv_obj_get_width_fit(lv_obj_get_parent(new_kb)),
                        lv_obj_get_height_fit(lv_obj_get_parent(new_kb)) / 2);

        lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
        lv_obj_set_event_cb(new_kb, lv_kb_def_event_cb);
        lv_btnm_set_map(new_kb, kb_map_lc);
        lv_btnm_set_ctrl_map(new_kb, kb_ctrl_lc_map);
        lv_obj_set_base_dir(new_kb, LV_BIDI_DIR_LTR);

        /*Set the default styles*/
        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->style.kb.bg);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->style.kb.btn.rel);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->style.kb.btn.pr);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->style.kb.btn.tgl_rel);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->style.kb.btn.tgl_pr);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->style.kb.btn.ina);
        } else {
            /*Let the button matrix's styles*/
        }
    }
    /*Copy an existing keyboard*/
    else {
        lv_kb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->ta                = NULL;
        ext->ta                = copy_ext->ta;
        ext->mode              = copy_ext->mode;
        ext->cursor_mng        = copy_ext->cursor_mng;

        /*Refresh the style with new signal function*/
        lv_obj_refresh_style(new_kb);
    }

    LV_LOG_INFO("keyboard created");

    return new_kb;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
callq 0x20cb8
movq %rax, %rbx
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0xc9ca
testq %rbx, %rbx
je 0xc9db
cmpq $0x0, 0x539b5(%rip)     # 0x602e8
jne 0xc944
movq %rbx, %rdi
callq 0x6a6c
movq %rax, 0x539a4(%rip)     # 0x602e8
movq %rbx, %rdi
movl $0x58, %esi
callq 0x64bc
movq %rax, %r15
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0xc9eb
testq %r15, %r15
je 0xc9db
movq $0x0, 0x48(%r15)
movb $0x0, 0x50(%r15)
andb $-0x2, 0x51(%r15)
leaq 0x18a(%rip), %rsi       # 0xcb0c
movq %rbx, %rdi
callq 0x645c
testq %r14, %r14
je 0xc9fc
movq %r14, %rdi
callq 0x6ad8
movq $0x0, 0x48(%r15)
movq 0x48(%rax), %rcx
movq %rcx, 0x48(%r15)
movb 0x50(%rax), %cl
movb %cl, 0x50(%r15)
movb 0x51(%rax), %al
andb $0x1, %al
movb 0x51(%r15), %cl
andb $-0x2, %cl
orb %al, %cl
movb %cl, 0x51(%r15)
movq %rbx, %rdi
callq 0x5e38
jmp 0xc9dd
leaq 0x3266f(%rip), %rdi     # 0x3f040
movq %rbx, %rsi
callq 0x829e
jmp 0xc9d9
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3264e(%rip), %rdi     # 0x3f040
movq %r15, %rsi
callq 0x829e
jmp 0xc9fa
movq %rbx, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x6753
movl %eax, %ebp
movq %rbx, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x679b
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %edx
sarl %edx
movswl %bp, %esi
movq %rbx, %rdi
callq 0x553f
movq %rbx, %rdi
xorl %esi, %esi
movl $0x5, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x576d
leaq 0x168(%rip), %rsi       # 0xcbb9
movq %rbx, %rdi
callq 0x6344
leaq 0x46650(%rip), %rsi     # 0x530b0
movq %rbx, %rdi
callq 0x21710
leaq 0x32911(%rip), %rsi     # 0x3f380
movq %rbx, %rdi
callq 0x21d48
movq %rbx, %rdi
xorl %esi, %esi
callq 0x61ac
callq 0x2e244
testq %rax, %rax
je 0xc9dd
movq %rax, %r14
movq 0x1b8(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xcf15
movq 0x1c0(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0xcf15
movq 0x1c8(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0xcf15
movq 0x1d0(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0xcf15
movq 0x1d8(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0xcf15
movq 0x1e0(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0xcf15
jmp 0xc9dd