// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
callq 0x6ad8
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0xa8(%rax)
js 0x20913
movq %rsp, %r12
jmp 0x2092b
movl 0xa0(%r14), %eax
shrl $0x1f, %eax
addb %al, %al
addb $0x2b, %al
leaq 0x1(%rsp), %r12
movb %al, -0x1(%r12)
testb $0xf, 0xb1(%r14)
je 0x20951
xorl %eax, %eax
movb $0x20, (%r12,%rax)
movzbl 0xb1(%r14), %ecx
andl $0xf, %ecx
incq %rax
cmpl %ecx, %eax
jb 0x20937
addq %rax, %r12
movl 0xa0(%r14), %eax
movl %eax, %edi
negl %edi
cmovsl %eax, %edi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x2af80
movzwl 0xb0(%r14), %ebp
andl $0xf, %ebp
movq %r15, %rdi
callq 0x2070
movl %ebp, %edx
subl %eax, %edx
jle 0x209bc
movzwl %ax, %ecx
movl %edx, %edx
incq %rcx
addq %rsp, %rdx
addq $0x20, %rdx
movb 0x1f(%rsp,%rcx), %sil
movb %sil, -0x1(%rdx,%rcx)
decq %rcx
jg 0x20994
notl %eax
addl %ebp, %eax
incq %rax
leaq 0x20(%rsp), %rdi
movl $0x30, %esi
movq %rax, %rdx
callq 0x20a0
movzwl 0xb0(%r14), %ebp
movl %ebp, %eax
shrl $0x4, %eax
andl $0xf, %eax
andl $0xf, %ebp
testl %eax, %eax
cmovnel %eax, %ebp
testw %bp, %bp
je 0x209f8
movl %ebp, %ecx
xorl %eax, %eax
movb 0x20(%rsp,%rax), %dl
testb %dl, %dl
je 0x209fc
movb %dl, (%r12,%rax)
incq %rax
cmpq %rax, %rcx
jne 0x209dd
addq %rax, %r12
movl %ebp, %eax
jmp 0x209ff
xorl %eax, %eax
jmp 0x209ff
addq %rax, %r12
testb $-0x10, 0xb0(%r14)
je 0x20a44
movb $0x2e, (%r12)
movzwl 0xb0(%r14), %ecx
andl $0xf, %ecx
cmpl %ecx, %eax
jae 0x20a44
movl %eax, %eax
incq %r12
movb 0x20(%rsp,%rax), %cl
testb %cl, %cl
je 0x20a44
movb %cl, (%r12)
incq %rax
movzwl 0xb0(%r14), %ecx
andl $0xf, %ecx
incq %r12
cmpq %rcx, %rax
jb 0x20a22
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x1f39e
movl 0xac(%r14), %edx
movzwl 0xb0(%r14), %eax
movl %eax, %ecx
andb $0xf, %cl
cmpl $0xa, %edx
jl 0x20a80
movl $0xcccccccd, %esi       # imm = 0xCCCCCCCD
movl %edx, %edi
imulq %rsi, %rdi
shrq $0x23, %rdi
decb %cl
cmpl $0x63, %edx
movl %edi, %edx
ja 0x20a6d
movzbl %cl, %ecx
shrl $0x8, %eax
andb $0xf, %al
cmpw %cx, %bp
adcb %al, %cl
movzbl %cl, %esi
movq %rbx, %rdi
callq 0x1edf8
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq