// File: /workspace/github_c_makefile_star2_O3/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 0x1d3f8
movq %rax, %rbx
movq %rax, %rdi
callq 0x80e4
testb %al, %al
je 0x271aa
testq %rbx, %rbx
je 0x271bb
cmpq $0x0, 0x3937b(%rip)     # 0x60478
jne 0x2710e
movq %rbx, %rdi
callq 0x6a8b
movq %rax, 0x3936a(%rip)     # 0x60478
movq %rbx, %rdi
movl $0x40, %esi
callq 0x64db
movq %rax, %r15
movq %rax, %rdi
callq 0x80e4
testb %al, %al
je 0x271c6
testq %r15, %r15
je 0x271bb
andb $-0x2, 0x3a(%r15)
movw $0x0, 0x3c(%r15)
movq 0x18(%r15), %rax
movq %rax, 0x28(%r15)
movq %rax, 0x30(%r15)
leaq 0x10e(%rip), %rsi       # 0x27264
movq %rbx, %rdi
callq 0x647b
testq %r14, %r14
je 0x271d7
movq %r14, %rdi
callq 0x6af7
movups 0x28(%rax), %xmm0
movups %xmm0, 0x28(%r15)
movzwl 0x3c(%rax), %eax
movw %ax, 0x3c(%r15)
movq %rbx, %rdi
callq 0x94aa
xorl %ecx, %ecx
cmpw $0x32, %ax
setge %cl
movq 0x28(%r15,%rcx,8), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1dfe8
movq %rbx, %rdi
callq 0x5e54
jmp 0x271bd
leaq 0x17f1f(%rip), %rdi     # 0x3f0d0
movq %rbx, %rsi
callq 0x8294
jmp 0x271b9
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x17f03(%rip), %rdi     # 0x3f0d0
movq %r15, %rsi
callq 0x8294
jmp 0x271d5
movq %rbx, %rdi
movl $0x42, %esi
movl $0x21, %edx
callq 0x5557
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1e059
movq %rbx, %rdi
xorl %esi, %esi
movl $0x64, %edx
callq 0x9397
callq 0x2e91c
testq %rax, %rax
je 0x271bd
movq %rax, %r14
movq 0xf0(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27543
movq 0xf8(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x27543
movq 0x100(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x27543
movq 0x108(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x27543
jmp 0x271bd