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

    /*Create the ancestor of switch*/
    lv_obj_t * new_sw = lv_slider_create(par, copy);
    LV_ASSERT_MEM(new_sw);
    if(new_sw == NULL) return NULL;

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

    /*Allocate the switch type specific extended data*/
    lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(new_sw, sizeof(lv_sw_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    /*Initialize the allocated 'ext' */
    ext->changed = 0;
#if LV_USE_ANIMATION
    ext->anim_time = 0;
#endif
    ext->style_knob_off = ext->slider.style_knob;
    ext->style_knob_on  = ext->slider.style_knob;

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

    /*Init the new switch switch*/
    if(copy == NULL) {
        lv_obj_set_size(new_sw, 2 * LV_DPI / 3, LV_DPI / 3);
        lv_slider_set_knob_in(new_sw, true);
        lv_slider_set_range(new_sw, 0, LV_SW_MAX_VALUE);

        /*Set the default styles*/
        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->style.sw.bg);
            lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->style.sw.indic);
            lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->style.sw.knob_off);
            lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->style.sw.knob_on);
        } else {
            /*Let the slider' style*/
        }

    }
    /*Copy an existing switch*/
    else {
        lv_sw_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->style_knob_off    = copy_ext->style_knob_off;
        ext->style_knob_on     = copy_ext->style_knob_on;
#if LV_USE_ANIMATION
        ext->anim_time = copy_ext->anim_time;
#endif

        if(lv_sw_get_state(new_sw))
            lv_slider_set_style(new_sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_on);
        else
            lv_slider_set_style(new_sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);

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

    LV_LOG_INFO("switch created");

    return new_sw;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
callq 0x1cbf4
movq %rax, %rbx
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x26ae1
testq %rbx, %rbx
je 0x26af2
cmpq $0x0, 0x39a4b(%rip)     # 0x60478
jne 0x26a3e
movq %rbx, %rdi
callq 0x6a6c
movq %rax, 0x39a3a(%rip)     # 0x60478
movq %rbx, %rdi
movl $0x40, %esi
callq 0x64bc
movq %rax, %r15
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x26afd
testq %r15, %r15
je 0x26af2
andb $-0x2, 0x3a(%r15)
movw $0x0, 0x3c(%r15)
movq 0x18(%r15), %rax
movq %rax, 0x28(%r15)
movq %rax, 0x30(%r15)
leaq 0x115(%rip), %rsi       # 0x26b9b
movq %rbx, %rdi
callq 0x645c
testq %r14, %r14
je 0x26b0e
movq %r14, %rdi
callq 0x6ad8
movq 0x28(%rax), %rcx
movq %rcx, 0x28(%r15)
movq 0x30(%rax), %rcx
movq %rcx, 0x30(%r15)
movzwl 0x3c(%rax), %eax
movw %ax, 0x3c(%r15)
movq %rbx, %rdi
callq 0x9525
xorl %ecx, %ecx
cmpw $0x32, %ax
setge %cl
movq 0x28(%r15,%rcx,8), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1d7e4
movq %rbx, %rdi
callq 0x5e38
jmp 0x26af4
leaq 0x18558(%rip), %rdi     # 0x3f040
movq %rbx, %rsi
callq 0x829e
jmp 0x26af0
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1853c(%rip), %rdi     # 0x3f040
movq %r15, %rsi
callq 0x829e
jmp 0x26b0c
movq %rbx, %rdi
movl $0x42, %esi
movl $0x21, %edx
callq 0x553f
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1d855
movq %rbx, %rdi
xorl %esi, %esi
movl $0x64, %edx
callq 0x9419
callq 0x2e244
testq %rax, %rax
je 0x26af4
movq %rax, %r14
movq 0xf0(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x26e68
movq 0xf8(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x26e68
movq 0x100(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x26e68
movq 0x108(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x26e68
jmp 0x26af4