// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_btn.c
// Function: lv_btn_create
lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("button create started");

    lv_obj_t * new_btn;

    new_btn = lv_cont_create(par, copy);
    LV_ASSERT_MEM(new_btn);
    if(new_btn == NULL) return NULL;

    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btn);
    if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_btn);

    /*Allocate the extended data*/
    lv_btn_ext_t * ext = lv_obj_allocate_ext_attr(new_btn, sizeof(lv_btn_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    ext->state = LV_BTN_STATE_REL;

    ext->styles[LV_BTN_STATE_REL]     = &lv_style_btn_rel;
    ext->styles[LV_BTN_STATE_PR]      = &lv_style_btn_pr;
    ext->styles[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
    ext->styles[LV_BTN_STATE_TGL_PR]  = &lv_style_btn_tgl_pr;
    ext->styles[LV_BTN_STATE_INA]     = &lv_style_btn_ina;

    ext->toggle = 0;
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
    ext->ink_in_time   = 0;
    ext->ink_wait_time = 0;
    ext->ink_out_time  = 0;
#endif

    lv_obj_set_signal_cb(new_btn, lv_btn_signal);
    lv_obj_set_design_cb(new_btn, lv_btn_design);

    /*If no copy do the basic initialization*/
    if(copy == NULL) {
        /*Set layout if the button is not a screen*/
        if(par != NULL) {
            lv_btn_set_layout(new_btn, LV_LAYOUT_CENTER);
        }

        lv_obj_set_click(new_btn, true); /*Be sure the button is clickable*/

        /*Set the default styles*/
        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->style.btn.rel);
            lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->style.btn.pr);
            lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->style.btn.tgl_rel);
            lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->style.btn.tgl_pr);
            lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->style.btn.ina);
        } else {
            lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
        }
    }
    /*Copy 'copy'*/
    else {
        lv_btn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->state              = copy_ext->state;
        ext->toggle             = copy_ext->toggle;
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
        ext->ink_in_time   = copy_ext->ink_in_time;
        ext->ink_wait_time = copy_ext->ink_wait_time;
        ext->ink_out_time  = copy_ext->ink_out_time;
#endif
        memcpy((void*) ext->styles, copy_ext->styles, sizeof(ext->styles));

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

    LV_LOG_INFO("button created");

    return new_btn;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x209c8
movq %rax, %rbx
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x1243a
testq %rbx, %rbx
je 0x1244b
cmpq $0x0, 0x4c038(%rip)     # 0x5e360
jne 0x12339
movq %rbx, %rdi
callq 0x66db
movq %rax, 0x4c027(%rip)     # 0x5e360
cmpq $0x0, 0x4c027(%rip)     # 0x5e368
jne 0x12352
movq %rbx, %rdi
callq 0x66ff
movq %rax, 0x4c016(%rip)     # 0x5e368
pushq $0x38
popq %rsi
movq %rbx, %rdi
callq 0x6146
movq %rax, %r12
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x1245a
testq %r12, %r12
je 0x1244b
movq %r12, %r13
addq $0x8, %r13
leaq 0x4bd89(%rip), %rax     # 0x5e110
movq %rax, 0x8(%r12)
leaq 0x4bdc5(%rip), %rax     # 0x5e158
movq %rax, 0x10(%r12)
leaq 0x4be01(%rip), %rax     # 0x5e1a0
movq %rax, 0x18(%r12)
leaq 0x4be3d(%rip), %rax     # 0x5e1e8
movq %rax, 0x20(%r12)
leaq 0x4be79(%rip), %rax     # 0x5e230
movq %rax, 0x28(%r12)
andb $-0x10, 0x30(%r12)
leaq 0x12a(%rip), %rsi       # 0x124f3
movq %rbx, %rdi
callq 0x60e6
leaq 0x307(%rip), %rsi       # 0x126df
movq %rbx, %rdi
callq 0x6116
testq %r14, %r14
je 0x1246b
movq %r14, %rdi
callq 0x6747
movb 0x30(%rax), %cl
andb $0x7, %cl
movb 0x30(%r12), %dl
andb $-0x8, %dl
orb %cl, %dl
movb %dl, 0x30(%r12)
movb 0x30(%rax), %cl
andb $0x8, %cl
andb $-0x9, %dl
orb %cl, %dl
movb %dl, 0x30(%r12)
movq 0x28(%rax), %rcx
movq %rcx, 0x20(%r13)
movups 0x8(%rax), %xmm0
movups 0x18(%rax), %xmm1
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
movq %rbx, %rdi
callq 0x5ae7
jmp 0x1244d
leaq 0x28bff(%rip), %rdi     # 0x3b040
movq %rbx, %rsi
callq 0x7b01
jmp 0x12449
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x28bdf(%rip), %rdi     # 0x3b040
movq %r12, %rsi
callq 0x7b01
jmp 0x12469
testq %r15, %r15
je 0x1247b
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x20bca
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x5c6f
callq 0x2be75
testq %rax, %rax
je 0x124e2
movq %rax, %r14
movq 0x20(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x126f8
movq 0x28(%r14), %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x126f8
movq 0x30(%r14), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x126f8
movq 0x38(%r14), %rdx
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x126f8
movq 0x40(%r14), %rdx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x126f8
jmp 0x1244d
movq (%r13), %rsi
movq %rbx, %rdi
callq 0x5a3d
jmp 0x1244d