// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_spinbox.c
// Function: lv_spinbox_updatevalue
static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
{
    lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);

    char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
    memset(buf, 0, sizeof(buf));
    char * buf_p = buf;

    if (ext->range_min < 0) { // hide sign if there are only positive values
        /*Add the sign*/
        (*buf_p) = ext->value >= 0 ? '+' : '-';
        buf_p++;
    }

    int32_t i;
    /*padding left*/
    for(i = 0; i < ext->digit_padding_left; i++) {
        (*buf_p) = ' ';
        buf_p++;
    }

    char digits[64];
    /*Convert the numbers to string (the sign is already handled so always covert positive number)*/
    lv_utils_num_to_str(ext->value < 0 ? -ext->value : ext->value, digits);

    /*Add leading zeros*/
    int lz_cnt = ext->digit_count - (int)strlen(digits);
    if(lz_cnt > 0) {
        for(i = (uint16_t)strlen(digits); i >= 0; i--) {
            digits[i + lz_cnt] = digits[i];
        }
        for(i = 0; i < lz_cnt; i++) {
            digits[i] = '0';
        }
    }

    int32_t intDigits;
    intDigits = (ext->dec_point_pos == 0) ? ext->digit_count : ext->dec_point_pos;

    /*Add the decimal part*/
    for(i = 0; i < intDigits && digits[i] != '\0'; i++) {
        (*buf_p) = digits[i];
        buf_p++;
    }

    if(ext->dec_point_pos != 0) {
        /*Insert the decimal point*/
        (*buf_p) = '.';
        buf_p++;

        for(/*Leave i*/; i < ext->digit_count && digits[i] != '\0'; i++) {
            (*buf_p) = digits[i];
            buf_p++;
        }
    }

    /*Refresh the text*/
    lv_ta_set_text(spinbox, (char *)buf);

    /*Set the cursor position*/
    int32_t step    = ext->step;
    uint8_t cur_pos = (uint8_t)ext->digit_count;
    while(step >= 10) {
        step /= 10;
        cur_pos--;
    }

    if(cur_pos > intDigits) cur_pos++; /*Skip teh decimal point*/

    cur_pos += ext->digit_padding_left;

    lv_ta_set_cursor_pos(spinbox, cur_pos);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
callq 0x6747
movq %rax, %r14
andq $0x0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
cmpl $0x0, 0xa8(%rax)
js 0x1f0d1
movq %rsp, %r12
jmp 0x1f0e9
movl 0xa0(%r14), %eax
shrl $0x1f, %eax
addb %al, %al
addb $0x2b, %al
leaq 0x1(%rsp), %r12
movb %al, -0x1(%r12)
movzbl 0xb1(%r14), %eax
andl $0xf, %eax
xorl %ecx, %ecx
cmpl %eax, %ecx
jae 0x1f106
movb $0x20, (%r12)
incq %r12
incl %ecx
jmp 0x1f0f6
movl 0xa0(%r14), %eax
movl %eax, %edi
negl %edi
cmovsl %eax, %edi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x28f4c
movzwl 0xb0(%r14), %ebp
movl %ebp, %r13d
andl $0xf, %r13d
movq %r15, %rdi
callq 0x2070
movl %r13d, %ecx
subl %eax, %ecx
jle 0x1f16a
movzwl %ax, %eax
testl %eax, %eax
js 0x1f157
movl %eax, %edx
movb 0x20(%rsp,%rdx), %dl
leal (%rcx,%rax), %esi
movb %dl, 0x20(%rsp,%rsi)
decl %eax
jmp 0x1f142
movl %ecx, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x1f16a
movb $0x30, 0x20(%rsp,%rcx)
incq %rcx
jmp 0x1f15b
movl %ebp, %eax
shrl $0x4, %eax
andl $0xf, %eax
movl %r13d, %ecx
cmovnel %eax, %ecx
movzwl %cx, %r15d
xorl %eax, %eax
cmpq %rax, %r15
je 0x1f194
movb 0x20(%rsp,%rax), %cl
testb %cl, %cl
je 0x1f199
movb %cl, (%r12,%rax)
incq %rax
jmp 0x1f17e
movq %r15, %rcx
jmp 0x1f19c
movq %rax, %rcx
testb $-0x10, %bpl
je 0x1f1d1
movb $0x2e, (%r12,%rax)
leaq (%rsp,%rcx), %rdx
addq $0x20, %rdx
xorl %esi, %esi
leaq (%rcx,%rsi), %rdi
cmpq %r13, %rdi
jae 0x1f1d1
movb (%rdx,%rsi), %dil
testb %dil, %dil
je 0x1f1d1
leaq (%r12,%rsi), %r8
movb %dil, 0x1(%r8,%rax)
incq %rsi
jmp 0x1f1b1
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x1dc07
movl 0xac(%r14), %eax
movzwl 0xb0(%r14), %ecx
movl %ecx, %esi
andb $0xf, %sil
pushq $0xa
popq %rdi
cmpl $0xa, %eax
jl 0x1f202
xorl %edx, %edx
divl %edi
decb %sil
jmp 0x1f1f4
movzbl %sil, %eax
shrl $0x8, %ecx
andb $0xf, %cl
cmpw %ax, %r15w
adcb %sil, %cl
movzbl %cl, %esi
movq %rbx, %rdi
callq 0x1d679
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq