// File: /workspace/github_c_makefile_star2_O2/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 0x1b5d4
movq %rax, %rbx
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x24e13
testq %rbx, %rbx
je 0x24e24
cmpq $0x0, 0x39703(%rip)     # 0x5e478
jne 0x24d86
movq %rbx, %rdi
callq 0x66db
movq %rax, 0x396f2(%rip)     # 0x5e478
pushq $0x40
popq %rsi
movq %rbx, %rdi
callq 0x6146
movq %rax, %r15
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x24e2f
testq %r15, %r15
je 0x24e24
andb $-0x2, 0x3a(%r15)
andw $0x0, 0x3c(%r15)
movq 0x18(%r15), %rax
movq %rax, 0x28(%r15)
movq %rax, 0x30(%r15)
leaq 0xf8(%rip), %rsi        # 0x24ebf
movq %rbx, %rdi
callq 0x60e6
testq %r14, %r14
je 0x24e40
movq %r14, %rdi
callq 0x6747
movups 0x28(%rax), %xmm0
movups %xmm0, 0x28(%r15)
movzwl 0x3c(%rax), %eax
movw %ax, 0x3c(%r15)
movq %rbx, %rdi
callq 0x251da
movzbl %al, %eax
movq 0x28(%r15,%rax,8), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x1c13f
movq %rbx, %rdi
callq 0x5ae7
jmp 0x24e26
leaq 0x16226(%rip), %rdi     # 0x3b040
movq %rbx, %rsi
callq 0x7b01
jmp 0x24e22
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1620a(%rip), %rdi     # 0x3b040
movq %r15, %rsi
callq 0x7b01
jmp 0x24e3e
pushq $0x42
popq %rsi
pushq $0x21
popq %rdx
movq %rbx, %rdi
callq 0x520e
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1c1ae
pushq $0x64
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8bb4
callq 0x2be75
testq %rax, %rax
je 0x24e26
movq %rax, %r14
movq 0xf0(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x25142
movq 0xf8(%r14), %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x25142
movq 0x100(%r14), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x25142
movq 0x108(%r14), %rdx
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x25142
jmp 0x24e26